Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10121628pxu; Tue, 29 Dec 2020 14:44:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyUsjeh0W0M/VPMt7cv2AwCktG2RPIQbvYvjQwh8hRa6UNZSgi0peeX1M+sYaC26zxHcxSj X-Received: by 2002:a17:906:9888:: with SMTP id zc8mr46311468ejb.42.1609281873408; Tue, 29 Dec 2020 14:44:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609281873; cv=none; d=google.com; s=arc-20160816; b=SSFb06iv65r7+bjDuwTtPAqqU80AVao8egIuMh75dMspOyI0n0iG/G9lbT14D0MAMy aSBKqYi9T7V9uAlEZwXSANqZZtm425Gv1AFO9Z5SUhx9OgxlF57fhGltYMvkQ+kEc2HB YTSpXwRdsiCcc/T2DyDGY/Ne7QXiGV6SMN5koq7L5cvFu2ru89nqBix4yi0o5J2Lyb6R /2mVsD/qLZnw/ijmvKnDRzdeThx3OdmB8s1G+hCJYPQS1mnAzGHGHYnK4D7Z96kA2Wlz zj0+WgZeE7FolfLguFbJnuF6BJ6riR9J53q3Ff35QZOxfOaW7FEpavTximIYkE3Xvm0W zdBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=AOAbGxReTuayRM7jS1zbY+XkMwGRKahN5mE70EumkLM=; b=UyVh6hNr1SRH1pIRWw5+Grc8cW1+NGScwm52GWmU1/YhylGUXqlzS9/UcCb5YtNBTo rGJjxH06paPHRMGNR0Kl+yAGsYGb2fW0aDT3nd1iM+xHLhd+J3igsaA96Nf5YXXe0py3 tmEs3EnU0xTVJBvr1qd6Y5ig8j6szpdxRI4cz13XQTnmCoGh2EAILV+CQUwv00RetbcZ HYdnqMWtYUbzKyKXsaCEFewQiUMNEpTrqMiBIsu9sB4QrOLaD3YXKtmfOrPV5rFBEfjl S+g2XElIdzA9SL1VcJfP7ilYU4knlURLjPW3UPq98FZKFOtlQrs5MoXMAu1Y4jg/potY 27Bg== 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 w6si21749786edt.581.2020.12.29.14.44.11; Tue, 29 Dec 2020 14:44:33 -0800 (PST) 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 S1726203AbgL2Wmq (ORCPT + 99 others); Tue, 29 Dec 2020 17:42:46 -0500 Received: from jabberwock.ucw.cz ([46.255.230.98]:40628 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726144AbgL2Wmq (ORCPT ); Tue, 29 Dec 2020 17:42:46 -0500 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 477B61C0B7C; Tue, 29 Dec 2020 23:42:03 +0100 (CET) Date: Tue, 29 Dec 2020 23:42:02 +0100 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Hulk Robot , Qinglang Miao , Ulf Hansson , Sasha Levin Subject: Re: [PATCH 5.10 191/717] memstick: fix a double-free bug in memstick_check Message-ID: <20201229224202.GA32501@amd> References: <20201228125020.963311703@linuxfoundation.org> <20201228125030.121361557@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline In-Reply-To: <20201228125030.121361557@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > From: Qinglang Miao >=20 > [ Upstream commit e3e9ced5c93803d5b2ea1942c4bf0192622531d6 ] >=20 > kfree(host->card) has been called in put_device so that > another kfree would raise cause a double-free bug. > +++ b/drivers/memstick/core/memstick.c > @@ -468,7 +468,6 @@ static void memstick_check(struct work_struct *work) > host->card =3D card; > if (device_register(&card->dev)) { > put_device(&card->dev); > - kfree(host->card); > host->card =3D NULL; > } Does the host->card =3D NULL need to be removed, too (and following code refactored)? put_device() needs that pointer to be able to free it and it can do so asynchronously. This will cause crashes; they should be easy to reproduce with CONFIG_DEBUG_KOBJECT_RELEASE due to delay in kobject_release() AFAICT. Best regards, Pavel --=20 http://www.livejournal.com/~pavelmachek --EVF5PPMfhYS0aIcm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl/rsLoACgkQMOfwapXb+vIp9QCgiGA7sg6njdUTVICgURx0nQY6 cNYAoK2WHpH/AHlOPo/11nbX/0tb9GJO =50XO -----END PGP SIGNATURE----- --EVF5PPMfhYS0aIcm--