Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2232035pxb; Tue, 12 Oct 2021 02:08:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwVmDOrpgIDgr3+9MSrk287zAkHJFNMXcROI8UUYr4JEKcE0Xh+6VAJhYCNCa9aO01PhAn X-Received: by 2002:aa7:c38b:: with SMTP id k11mr8967728edq.79.1634029715554; Tue, 12 Oct 2021 02:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634029715; cv=none; d=google.com; s=arc-20160816; b=ou2GrYzsQjLLaDmQ9R16K+scWKwlkXZGQDQB+yL/Z3lc73hvYP1v3C9uuK7vJCm7HK /8kybm54rKiBgNukPg5lEo5BkCfwrG4aPRvYAlW3aEciNKC0EDhsSSRf9glNccp0yXfz z3QOL6SvyVwOqmwx4l0m/FJV1nlvUQNNWflN/1P5Tn2pWMBfmHVCygwHUP2T/WJ4YYvj xpk9x3HTFTmhPs+ZcyyUlDroFA6eFLr0izmaAKS00HkjwBKJH5w9L7YgX5eRUqXTsG3X cZZPbsFx68qtr6Ju4yMSHuVCLXS7BLVd7R+yMjBc3BEvoOjd7BfGXZtcf/7eWXaPn+J+ ahfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ttcjvqCrL9KrpQZYFN2z9bXE5QO+BMPV+0AeMhOrI2k=; b=R6wMBwGMQORScsAymo8FACFSmrDAkSypJXUPlnZwWEiY1lbyThRydPxJZgqbyPA3j0 4FJuUNoUU/FCg92x/ASrBHUYIfN0AYknvz/6jRhRb6qCX2MysgzZnRxvzujgAAp48U5q M4j8J/IoY2+3k5rWXCpfJ0gZB18ymnxR+Niq1QKA2HjRa9vrOWnmqLD+/Jy2Oxg8Pj7g wYYN0+5KE7Mw4CmPwLzXM6ad2hvmlgPTmAoQEEvWSLTvzBeBOIGzCGN2qdpy9zGYGqUw VhKWK9dOHnMEcMj26ouDbHjnJJL08B6kB8X8ArB7ql4+ATh4ptwlwWcVvhtNadgd1mkU ERqw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bh21si15878740ejb.428.2021.10.12.02.08.12; Tue, 12 Oct 2021 02:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235654AbhJLJIS (ORCPT + 99 others); Tue, 12 Oct 2021 05:08:18 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:43800 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S235515AbhJLJIL (ORCPT ); Tue, 12 Oct 2021 05:08:11 -0400 X-UUID: 7ab4f167e4e14508a0f398268e47d28f-20211012 X-UUID: 7ab4f167e4e14508a0f398268e47d28f-20211012 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1131730382; Tue, 12 Oct 2021 17:06:04 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Tue, 12 Oct 2021 17:06:03 +0800 Received: from mszswglt01.gcn.mediatek.inc (10.16.20.20) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 12 Oct 2021 17:06:02 +0800 From: To: CC: , , , , , , , , , , Guangming Cao Subject: Re: [PATCH v2] dma-buf: acquire name lock before read/write dma_buf.name Date: Tue, 12 Oct 2021 17:07:55 +0800 Message-ID: <20211012090755.177441-1-guangming.cao@mediatek.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <169957a7-302b-1de9-39b0-415c4675743a@amd.com> References: <169957a7-302b-1de9-39b0-415c4675743a@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Guangming Cao > Am 08.10.21 um 09:54 schrieb guangming.cao@mediatek.com: > > From: Guangming Cao > > > > Because dma-buf.name can be freed in func: "dma_buf_set_name", > > so, we need to acquire lock first before we read/write dma_buf.name > > to prevent Use After Free(UAF) issue. > > > > Signed-off-by: Guangming Cao > > Reviewed-by: Christian König > > Going to push that upstream if nobody else objects. > > Thanks, > Christian. I'm sorry to disturb you, actually I need this patch to solve our issues. Is there any question about it? seems it hasn't been merged into mainline. Thanks, Guangming. > > > --- > > drivers/dma-buf/dma-buf.c | 3 +++ > > 1 file changed, 3 insertions(+) > > > > diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c > > index 511fe0d217a0..a7f6fd13a635 100644 > > --- a/drivers/dma-buf/dma-buf.c > > +++ b/drivers/dma-buf/dma-buf.c > > @@ -1372,6 +1372,8 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) > > if (ret) > > goto error_unlock; > > > > + > > + spin_lock(&buf_obj->name_lock); > > seq_printf(s, "%08zu\t%08x\t%08x\t%08ld\t%s\t%08lu\t%s\n", > > buf_obj->size, > > buf_obj->file->f_flags, buf_obj->file->f_mode, > > @@ -1379,6 +1381,7 @@ static int dma_buf_debug_show(struct seq_file *s, void *unused) > > buf_obj->exp_name, > > file_inode(buf_obj->file)->i_ino, > > buf_obj->name ?: ""); > > + spin_unlock(&buf_obj->name_lock); > > > > robj = buf_obj->resv; > > fence = dma_resv_excl_fence(robj);