Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3153389yba; Sat, 18 May 2019 10:19:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzuSivJ2cbsQ5XllqiK+c6m+d/9Rc6H9Xi/NdiQVwJQvZjYKt6r12ZGD8T+dteASsxY8m12 X-Received: by 2002:a17:902:848c:: with SMTP id c12mr15443960plo.17.1558199966321; Sat, 18 May 2019 10:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558199966; cv=none; d=google.com; s=arc-20160816; b=PnSMp9ZVmh2+8xLemybtGsM6yCYtXjGuZQFopfiAnH2gdrKM5lD63BRR8INMGPdHSX wD9+LrjxfyR7djCXIfT+jKZVl+hEJlXdmRHiLZ/IvNkWNblnXP4WLJsLHucT0Icd5fS4 Y9MeoZqQHN84VG8JePDTMb6GpB/5YB7NJfeFKk4rCJVLSFKo8pHUNPxz0pqaKvd0fGCH ps1PadiyFRrA4K4I1km4YVi25S3TSu7EjBomqbByRxyStiGPOExbnNELUoAgQofFMlSw YlrWtzlIU3zQEapj6/8dzdHMUb6/XZY2xL8Nm7oY9EGHU8iPM1dfzbHfJ1R5tpLxeUTw NqeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date; bh=mso3X6cOmB5y2Q+FLhroWeIR/45tkJ4Qf4ri9+DAJ10=; b=RH0ehvJUeoKPtQQplcmkynJh4IsuiPmaQYSDKxMAaAX0GHwdXa2jBO9kwUi/Z5CPjW aRgrpu5vq1uWKW7545wnLQQ4Jahn7YOLxyl96H36MGYBcfbZFWPxjoJEi64pswzPCmXH puyySBgOD5g1GiRy0RR/Qj3TUNpoo4TVYwKFQplNfgSFELax/1kl4qJn6pLFDeS/s0EW 6/gPmWCi9WdcTwQaXcNd1o6sEiCAGtdNlsrUcxMHbKj+LaOuNE40Q565Yn1NEtZxbkMd d59cVkD4mIlVoXl2FmRJv8Kg+xcSdkneICsQBSoRkwMEfqDBQ13BgvS4YaJYp/6PAgwq vdsw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-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 m14si7235262pls.393.2019.05.18.10.19.02; Sat, 18 May 2019 10:19:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729263AbfERRBo (ORCPT + 99 others); Sat, 18 May 2019 13:01:44 -0400 Received: from netrider.rowland.org ([192.131.102.5]:57385 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1728028AbfERRBo (ORCPT ); Sat, 18 May 2019 13:01:44 -0400 Received: (qmail 10625 invoked by uid 500); 18 May 2019 13:01:43 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 18 May 2019 13:01:43 -0400 Date: Sat, 18 May 2019 13:01:43 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: syzbot cc: andreyknvl@google.com, , , , , , , , , , Subject: Re: KASAN: use-after-free Read in p54u_load_firmware_cb In-Reply-To: <00000000000043a1f905892c4a1f@google.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Sat, 18 May 2019, syzbot wrote: > Hello, > > syzbot tried to test the proposed patch but build/boot failed: One of these times I'll get it right... Alan Stern #syz test: https://github.com/google/kasan.git usb-fuzzer drivers/net/wireless/intersil/p54/p54usb.c | 37 +++++++++++------------------ 1 file changed, 15 insertions(+), 22 deletions(-) Index: usb-devel/drivers/net/wireless/intersil/p54/p54usb.c =================================================================== --- usb-devel.orig/drivers/net/wireless/intersil/p54/p54usb.c +++ usb-devel/drivers/net/wireless/intersil/p54/p54usb.c @@ -33,6 +33,8 @@ MODULE_ALIAS("prism54usb"); MODULE_FIRMWARE("isl3886usb"); MODULE_FIRMWARE("isl3887usb"); +static struct usb_driver p54u_driver; + /* * Note: * @@ -921,9 +923,9 @@ static void p54u_load_firmware_cb(const { struct p54u_priv *priv = context; struct usb_device *udev = priv->udev; + struct usb_interface *intf = priv->intf; int err; - complete(&priv->fw_wait_load); if (firmware) { priv->fw = firmware; err = p54u_start_ops(priv); @@ -932,23 +934,19 @@ static void p54u_load_firmware_cb(const dev_err(&udev->dev, "Firmware not found.\n"); } - if (err) { - struct device *parent = priv->udev->dev.parent; - - dev_err(&udev->dev, "failed to initialize device (%d)\n", err); - - if (parent) - device_lock(parent); + complete(&priv->fw_wait_load); + /* + * At this point p54u_disconnect may have already freed + * the "priv" context. Do not use it anymore! + */ + priv = NULL; - device_release_driver(&udev->dev); - /* - * At this point p54u_disconnect has already freed - * the "priv" context. Do not use it anymore! - */ - priv = NULL; + if (err) { + dev_err(&intf->dev, "failed to initialize device (%d)\n", err); - if (parent) - device_unlock(parent); + usb_lock_device(udev); + usb_driver_release_interface(&p54u_driver, intf); + usb_unlock_device(udev); } usb_put_dev(udev); @@ -1011,8 +1009,6 @@ static int p54u_probe(struct usb_interfa skb_queue_head_init(&priv->rx_queue); init_usb_anchor(&priv->submitted); - usb_get_dev(udev); - /* really lazy and simple way of figuring out if we're a 3887 */ /* TODO: should just stick the identification in the device table */ i = intf->altsetting->desc.bNumEndpoints; @@ -1053,10 +1049,8 @@ static int p54u_probe(struct usb_interfa priv->upload_fw = p54u_upload_firmware_net2280; } err = p54u_load_firmware(dev, intf); - if (err) { - usb_put_dev(udev); + if (err) p54_free_common(dev); - } return err; } @@ -1072,7 +1066,6 @@ static void p54u_disconnect(struct usb_i wait_for_completion(&priv->fw_wait_load); p54_unregister_common(dev); - usb_put_dev(interface_to_usbdev(intf)); release_firmware(priv->fw); p54_free_common(dev); }