Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756899AbbLAU5L (ORCPT ); Tue, 1 Dec 2015 15:57:11 -0500 Received: from mail-yk0-f173.google.com ([209.85.160.173]:35671 "EHLO mail-yk0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756007AbbLAU5J (ORCPT ); Tue, 1 Dec 2015 15:57:09 -0500 Subject: Re: [PATCH] xen-pciback: fix up cleanup path when alloc fails To: Konrad Rzeszutek Wilk References: <1448569959-7245-1-git-send-email-cardoe@cardoe.com> <20151201164717.GA5032@char.us.oracle.com> <20151201193517.GA32573@char.us.oracle.com> Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Bob Liu , Paul Durrant , Wei Liu , David Vrabel , Boris Ostrovsky , Jonathan Creekmore From: Doug Goldstein X-Enigmail-Draft-Status: N1110 Message-ID: <565E0909.2010009@cardoe.com> Date: Tue, 1 Dec 2015 14:54:33 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151201193517.GA32573@char.us.oracle.com> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="FJrWDUfBwJuGdXCK968KuCSHXDM2OXEV7" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3655 Lines: 107 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --FJrWDUfBwJuGdXCK968KuCSHXDM2OXEV7 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable On 12/1/15 1:35 PM, Konrad Rzeszutek Wilk wrote: > On Tue, Dec 01, 2015 at 11:47:17AM -0500, Konrad Rzeszutek Wilk wrote: >> On Thu, Nov 26, 2015 at 02:32:39PM -0600, Doug Goldstein wrote: >>> When allocating a pciback device fails, avoid the possibility of a >>> use after free. >> >> Reviewed-by: Konrad Rzeszutek Wilk >> >> Ugh, and it looks like xen-blkfront has the same issue. >=20 > Nope. No problems there. >=20 > The ->probe if it fails (so xenbus_dev_probe returns the error) > ends up in the 'probe_failed' label in really_probe which takes care by= doing: >=20 > dev_set_drvdata(dev, NULL); >=20 > Wheew! >=20 > either way the patch should go in, but the 'possibility' should > be perhaps removed? Unless there is some other path I missed? I put 'possibility' in there because it will only happen when the function returns failure. I was also trying to not make it sound panicky I guess. I can resubmit the patch with that word dropped if that's desirable. >=20 >> >>> >>> Reported-by: Jonathan Creekmore >>> Signed-off-by: Doug Goldstein >>> --- >>> drivers/xen/xen-pciback/xenbus.c | 4 +++- >>> 1 file changed, 3 insertions(+), 1 deletion(-) >>> >>> diff --git a/drivers/xen/xen-pciback/xenbus.c b/drivers/xen/xen-pciba= ck/xenbus.c >>> index 98bc345..4843741 100644 >>> --- a/drivers/xen/xen-pciback/xenbus.c >>> +++ b/drivers/xen/xen-pciback/xenbus.c >>> @@ -44,7 +44,6 @@ static struct xen_pcibk_device *alloc_pdev(struct x= enbus_device *xdev) >>> dev_dbg(&xdev->dev, "allocated pdev @ 0x%p\n", pdev); >>> =20 >>> pdev->xdev =3D xdev; >>> - dev_set_drvdata(&xdev->dev, pdev); >>> =20 >>> mutex_init(&pdev->dev_lock); >>> =20 >>> @@ -58,6 +57,9 @@ static struct xen_pcibk_device *alloc_pdev(struct x= enbus_device *xdev) >>> kfree(pdev); >>> pdev =3D NULL; >>> } >>> + >>> + dev_set_drvdata(&xdev->dev, pdev); >>> + >>> out: >>> return pdev; >>> } >>> --=20 >>> 2.4.10 >>> --=20 Doug Goldstein --FJrWDUfBwJuGdXCK968KuCSHXDM2OXEV7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0 iQJ8BAEBCgBmBQJWXgkLXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRBNTM5MEQ2RTNFMTkyNzlCNzVDMzIwOTVB MkJDMDNEQzg3RUQxQkQ0AAoJEKK8A9yH7RvUj30P/0clTylhvvCchX6m0OZhUqG6 rbdKyFqhiYX7w+tK0BASp07AHvIx5hnoU9HQ/9QALaJrCcTEZp37aON8zvpM0GIV nky/1aFYl/vgjPUtCyZISPp/CA+dPsBHj31gTTo9YBooxMBcU57Gp9WgsOEXi7al FpvKgP/QafZQ9TDvXB2OxqyF2AywQfRHMLMTJuw67G1CN5hdmiZhWMpmrggLJDlB tw9iivFGnJQWaRpPuVH46F/V4KDe7ZLHU3v0BUH2pnikHkVM3KU+Cr5f6pjlKFAD 6mway2DlM7GrDT2jVbMsNsZ+B8S1piyNM6ZRMbCa9ZkOKPvVMaCOzepJq1lg8Ne7 UVNJo4fjulLsB99VEtGwaBsr0KD37lbYXHWtb1w/NtMm8TYfneucFtyRAxjSzn+k leAiQwpAFOfmT9Vu912LeSDuWq3DcNS4OaZ1OX/1EVSeLoH9zyr1u5Ol/KCYWgTD hZm2myS66ir2lAjvFxAkDv7J6E5z3tAaatyLy+Uu6K5YWkVhW95WhxyCwRDsWir6 Shynf060s+ePkGCAjH34swYVmXBLJepWv+cqCMOFMs0tbek9jWg9eBC3OVe1+ik7 p/lBlYFBgcbZS/6JLF0yP8o7xoxXgZb4i6prWGcBd4lX4mWU/uc/j5v5o5bmYL9g Wb6z9IpOOKZWhfj0WTp+ =yuwn -----END PGP SIGNATURE----- --FJrWDUfBwJuGdXCK968KuCSHXDM2OXEV7-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/