Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2959587pxa; Tue, 18 Aug 2020 02:41:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKlvq9j7u8yUiM7/2KjKm41l6Lq2opakWOKHOjwQtW1HhfkVHaHfFlXzY8s1hUzFnZZs1Z X-Received: by 2002:a17:907:94ce:: with SMTP id dn14mr18673144ejc.351.1597743711690; Tue, 18 Aug 2020 02:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597743711; cv=none; d=google.com; s=arc-20160816; b=L2W8Xbj1SbkDoGPr+k8jW+NKks/Tul9SC9M1EpocJhxX5KZY+S1+dG3cbPmreIghQ3 2PVqy/ypYF37j8T1DLwH795BOIC446mBsLlCTulQQSvl+Q2WaVn5RtC7L6XSAiPEvCMt aAdEORQS1tYZOUdZCGO/HQdF4Vl+2HZrKeBnnpGY6xJ7hPIhqDVmp2xXnR4cBLkvNRQ1 TMlX7/4aJXa1lirgqe/7ylShyAgpZd/gZJ4XsJqRfJfGbs//iJNm/dEySf8/Ip7B1lWl 4ymaydjdQBDPq1IMAqBhZivtKG2SesDP4hs+p5ZvQQR/elGCRjpFrxKBOAe4xjyZiBhJ +BXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=arsmtd/UJ6aypUpHCpBYKWsYEW9Lghw3pLd2/ApyRU8=; b=jSp+xdzS3dXAPHdvO0kz8n7NXJjXCNPUijhMfxmK8fW4oXZmQNPYDiAztfwkkL4Sha tOesuDvU+i9RiL10Yt7umfN/PKB1v1JEU4ThJXCDsoY8n/ERh2A3nQYmfpegNs40F8D3 igvuV1n/j2TrtooiTFGHTFC+IWHumwNDG93hOtsGgdYkp57S9ngSWHoHN+aqsgCoXNpP OFPaqDGI1YJ/Q43MlfJ++nvCT2N8u7B23SJGKlx+vBhoI8Pd2hzY19BdJ0b7jyITpe8q KQoO6q+YXKHEqU6+52kXtHc/dbB3r+TG41Rr3ei08AOw6G54XA0EIVXe+X1GwIDVY7G7 drNA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si15682530ejl.306.2020.08.18.02.41.28; Tue, 18 Aug 2020 02:41:51 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726552AbgHRJkd (ORCPT + 99 others); Tue, 18 Aug 2020 05:40:33 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:48018 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726374AbgHRJk3 (ORCPT ); Tue, 18 Aug 2020 05:40:29 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id AC5A41C0BB6; Tue, 18 Aug 2020 11:40:26 +0200 (CEST) Date: Tue, 18 Aug 2020 11:40:25 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+96414aa0033c363d8458@syzkaller.appspotmail.com, Lihong Kou , Marcel Holtmann , Sasha Levin Subject: Re: [PATCH 4.19 027/168] Bluetooth: add a mutex lock to avoid UAF in do_enale_set Message-ID: <20200818094024.GB10974@amd> References: <20200817143733.692105228@linuxfoundation.org> <20200817143735.099152549@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="98e8jtXdkpgskNou" Content-Disposition: inline In-Reply-To: <20200817143735.099152549@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --98e8jtXdkpgskNou Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Lihong Kou >=20 > [ Upstream commit f9c70bdc279b191da8d60777c627702c06e4a37d ] >=20 > In the case we set or free the global value listen_chan in > different threads, we can encounter the UAF problems because > the method is not protected by any lock, add one to avoid > this bug. For this to be safe, bt_6lowpan_exit() needs same handling, no? Signed-off-by: Pavel Machek (CIP) diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c index 9a75f9b00b51..2402ef5ac072 100644 --- a/net/bluetooth/6lowpan.c +++ b/net/bluetooth/6lowpan.c @@ -1304,10 +1304,12 @@ static void __exit bt_6lowpan_exit(void) debugfs_remove(lowpan_enable_debugfs); debugfs_remove(lowpan_control_debugfs); =20 + mutex_lock(&set_lock); if (listen_chan) { l2cap_chan_close(listen_chan, 0); l2cap_chan_put(listen_chan); } + mutex_unlock(&set_lock); =20 disconnect_devices(); =20 --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --98e8jtXdkpgskNou Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl87ogYACgkQMOfwapXb+vLXHQCdF5AaFPo+xALJJPE8kIFePbu0 AqUAn3XCRYpjpqB671mtKEkGruvlVKB8 =sLE0 -----END PGP SIGNATURE----- --98e8jtXdkpgskNou--