Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2222500pxb; Thu, 28 Oct 2021 19:18:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygvl+tW0Q9QIvk1xkDeHNnOt1Ade9pLRon7/QWet5Xaar+7ak7TB5t98ekHbV+rPgxR4qy X-Received: by 2002:a05:6402:22da:: with SMTP id dm26mr6127564edb.208.1635473880910; Thu, 28 Oct 2021 19:18:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635473880; cv=none; d=google.com; s=arc-20160816; b=VR/vqVNNK34xXjQmAsPWfPsLzO4h5wmLBv211W9RAFz/jWWbBkHTr2Ji8PuL8zNXWu LT5pfl/mnbheo04zIuxuflsUoKIYVBIOtRbxQDbqro5jFjbopI/h0Jk4wy2btqbtKdCE 1OM5ywed5ABdItSi7McTjvPEe4iaM8Kl+81OmN0i3EU+6VTH+BNPUoE1pG6lTZJKn7Uo YyH6nvnWe2ia3U6Q36lho+BGIwG7YHdL3NwtRtQKJeSxM1oy9O0hTZGE1K01bcPFEr7i E7U6RmtQiNEBRiy5QQ04fI4heAH3mK3kAn4T44TnNBAhSfhKP38P5S5coWnarhlyQuMi gfdw== 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=2P0U8ZD4UbLGzm0SKp4KktgoTdhbidRmCoy9HrMLEic=; b=aflfS71ZAB3ai0dLykYsWDSI14wmVXFf3HUJ5BwasjZqzmS1nNWdQlsnIBuo9H/2EP yWpoi23uPIygHJcc4pknE27n7l8rS2c2w1joI/819vVlVnbUVhfhwPhN7vaf3Ay51/uA LDvivK5diNcUOIsu1hMqUkBJsE812DjKTLW1YuAQ55n/S+ghaoGrxy+aA6kntQBkUyfq wPfClmRB4X8AFz0sMaNB4tKpvL2LwW3rZ7yeO9+xGOhcN3KJr+dnaNujzemi6zEPY1bO hDxunrqMwMQXWzMpJ43VzQfkYzJvgjt7afCmnLN6qOn3NxmIygOSG2ENKS00XS22fLpT o0OA== 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 hs4si8725819ejc.266.2021.10.28.19.17.36; Thu, 28 Oct 2021 19:18:00 -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 S231551AbhJ2CSH (ORCPT + 99 others); Thu, 28 Oct 2021 22:18:07 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:49988 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S231356AbhJ2CSG (ORCPT ); Thu, 28 Oct 2021 22:18:06 -0400 X-UUID: 3dbb02fceea44252b69af4643ae51e22-20211029 X-UUID: 3dbb02fceea44252b69af4643ae51e22-20211029 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 180424326; Fri, 29 Oct 2021 10:15:35 +0800 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 29 Oct 2021 10:15:33 +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; Fri, 29 Oct 2021 10:15:33 +0800 From: To: CC: , , , , , , , , , , Guangming Cao Subject: Re: [PATCH v2] dma-buf: acquire name lock before read/write dma_buf.name Date: Fri, 29 Oct 2021 10:15:41 +0800 Message-ID: <20211029021541.101157-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 On Fri, 2021-10-08 at 12:24 +0200, Christian König wrote: > 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. Just a gentle ping for this patch, please kindly let me know how is it going. > > > --- > > 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); > > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek