Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2840261ybb; Sun, 22 Mar 2020 08:58:24 -0700 (PDT) X-Google-Smtp-Source: ADFU+vslsGF8RSZct0ZU5dR81xZ6T7h7srIPSOBo1aXc/FzlQWAFRHc7ihNXuryKYbAv7/hzXni6 X-Received: by 2002:aca:d446:: with SMTP id l67mr14505190oig.115.1584892704520; Sun, 22 Mar 2020 08:58:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584892704; cv=none; d=google.com; s=arc-20160816; b=QWeWs87njvsVYEmr+j1CcjUtZHC5NFpyzCf58UgH7Q3jnE8ZCMtNbzKRpFbh3uxbVS Scjvr4ti/J3iYyLcemsdfbgQEIP5MRSGmnp2lnN7qpGNfDP2bVYwxSZVn6FAM9SZOoy3 L/mpIHaXng2DKq8Pans3nxbIwm7mN8mNkK/4Eh9gMZyq0vdXJGPoQmeF1W4EPLX0NvIg Bs1z8R05KPgEypHdFTo8N3L0vxSFCBxN+7N0XOuG76MPyaHnULyqvzalonT3AtaexW+z nxxKsjlc/sdYTNxENb+qlrb26HCMsD9YOy4J9BNib0nnLosZrHLPcDoiOT36Wg6doW5o EaWQ== 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=8RnZHD+OG30WVGAVrJhmU0tIJrgAxGcnl+YdZyrQ92I=; b=bivb6nXYCLqk5MIIz7pMaLA2nb+u6NzSZdIGZuaKbgYzxWLa5nf+fXQCIbzhaCQmV1 /axYKQfla21pZa+Kb16iq+umvVOPgnoYSX3nsXevbQ2yHCGnup7w0GdSyf5qWjBQhNHi 5W+9K0AI4EMJTC8y2jD+Uc96O9A0shq/Tomk29zhysumwtoXDJWIqVSDP86TekyVLkdd 9ssdkYimZ8aHC6uN+FOSu2t/YRZCnJ5yHK116xb1uZLO7WSczT4SsZNVbQBwHTlwJ7yH myZaoj0Y99iTRRfVOEL+GpDq8htnD6imiUENf/FiwArFGKe89fTcISx5PfirxS3pnL7E /Cuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k22si6594531otn.272.2020.03.22.08.58.12; Sun, 22 Mar 2020 08:58:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726748AbgCVP44 (ORCPT + 99 others); Sun, 22 Mar 2020 11:56:56 -0400 Received: from sauhun.de ([88.99.104.3]:51134 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725785AbgCVP4z (ORCPT ); Sun, 22 Mar 2020 11:56:55 -0400 Received: from localhost (p54B33042.dip0.t-ipconnect.de [84.179.48.66]) by pokefinder.org (Postfix) with ESMTPSA id 6400C2C0064; Sun, 22 Mar 2020 16:56:53 +0100 (CET) Date: Sun, 22 Mar 2020 16:56:52 +0100 From: Wolfram Sang To: Xu Wang Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] i2c: Fix a potential use after free Message-ID: <20200322155652.GC1091@ninjato> References: <1577439272-10362-1-git-send-email-vulab@iscas.ac.cn> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="H8ygTp4AXg6deix2" Content-Disposition: inline In-Reply-To: <1577439272-10362-1-git-send-email-vulab@iscas.ac.cn> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --H8ygTp4AXg6deix2 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 27, 2019 at 09:34:32AM +0000, Xu Wang wrote: > Free the adap structure only after we are done using it. > This patch just moves the put_device() down a bit to avoid the > use after free. >=20 > Signed-off-by: Xu Wang Do you have a testcase to reproduce it? I wonder because we are freeing the device structure which is embedded inside the adap structure, not the adap structure itself. Or? > --- > drivers/i2c/i2c-core-base.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/i2c/i2c-core-base.c b/drivers/i2c/i2c-core-base.c > index 9f8dcd3..160d43e 100644 > --- a/drivers/i2c/i2c-core-base.c > +++ b/drivers/i2c/i2c-core-base.c > @@ -2301,8 +2301,8 @@ void i2c_put_adapter(struct i2c_adapter *adap) > if (!adap) > return; > =20 > - put_device(&adap->dev); > module_put(adap->owner); > + put_device(&adap->dev); > } > EXPORT_SYMBOL(i2c_put_adapter); > =20 > --=20 > 2.7.4 >=20 --H8ygTp4AXg6deix2 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEOZGx6rniZ1Gk92RdFA3kzBSgKbYFAl53isAACgkQFA3kzBSg KbYjVQ//YLOOhtSoKVw5BP0gfEP0MKQ3+62E6Jt3VnIw9lP/6HPEuLg47deiPSaq cz1bI+JD3u+TlFemJtWKbFn/41I5musXXfDYzmOWrDa3iGJ4M2fTE6BuVkN87pvy L3v7Lpbd8yvsA8QPX0UOgyuG0TURtw9T2ZYT3XVnjBeojTbISFaOPz0qyRuVQovn S2Ov5aGgRtrHPfsVOfSCKF9Wdq5dfjvQAeQVA7uiHILTvYjVLglUD4ugHjVl7jt+ Wpy2VAGfz+Ero6V3qSCuOQ7i628NZsg2XQ6dA1Awi8SbiUfE9/LzAfDjRT2ot91U JNfLSWQvGCOUfQzLZjkk4WzkF2Q91ocuzpHNatnusnwb+CRAeH9VYsFjVC3qVHMD bSWet/OpsbP3b0sz2U0VHmHvdStkwjw9Oczt3u8EC3RoiskUCdLDWDJKcbG8HUyx giEmgXaEHKKZw/0Hx4Z1BircivOPboGohzO5mShLuVY69WbQAptjLC+EO2zw5fgg rHwhKfc0lTZyfPV81ijcJqDHqMsnLsQLDfsU3h4W8fqGrw/Nr9AJu3FpkeCv1f6U 0R7QUWbA7SATR4MCGosdCfngwPAHZQ1FOQsOnfwICeXgbNrzuH5srHs4jm5pyOI2 WhM1EBvqtI2xCLiqNNUuLNT4QPF4VdxsdUdiE2xULM+IMsTkp9c= =Urp0 -----END PGP SIGNATURE----- --H8ygTp4AXg6deix2--