From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail115-24.sinamail.sina.com.cn (mail115-24.sinamail.sina.com.cn [218.30.115.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 31EEB7ED for ; Mon, 1 Jan 2024 02:28:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.70.64]) by sina.com (10.75.12.45) with ESMTP id 6592229E0000611E; Mon, 1 Jan 2024 10:25:37 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 0876431457826 X-SMAIL-UIID: C39BE61ED4F7499D81D21A62A897F6D6-20240101-102537-1 From: Hillf Danton To: syzbot Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [dri?] [media?] memory leak in get_sg_table Date: Mon, 1 Jan 2024 10:25:25 +0800 Message-Id: <20240101022525.2537-1-hdanton@sina.com> In-Reply-To: <0000000000009e6825060dd6c287@google.com> References: <0000000000009e6825060dd6c287@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sun, 31 Dec 2023 15:38:19 -0800 > HEAD commit: fbafc3e621c3 Merge tag 'for_linus' of git://git.kernel.org.. > git tree: upstream > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15e8171ae80000 #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master --- x/drivers/dma-buf/udmabuf.c +++ y/drivers/dma-buf/udmabuf.c @@ -153,7 +153,12 @@ static int begin_cpu_udmabuf(struct dma_ int ret = 0; if (!ubuf->sg) { - ubuf->sg = get_sg_table(dev, buf, direction); + static DEFINE_MUTEX(lock); + + mutex_lock(&lock); + if (!ubuf->sg) + ubuf->sg = get_sg_table(dev, buf, direction); + mutex_unlock(&lock); if (IS_ERR(ubuf->sg)) { ret = PTR_ERR(ubuf->sg); ubuf->sg = NULL; --