From: Johan Hovold <johan@kernel.org> To: Oliver Neukum <oneukum@suse.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>, stable@vger.kernel.org, Alexey Khoroshilov <khoroshilov@ispras.ru> Subject: [PATCH v2 2/8] USB: cdc-acm: fix use-after-free after probe failure Date: Mon, 22 Mar 2021 16:53:12 +0100 Message-ID: <20210322155318.9837-3-johan@kernel.org> (raw) In-Reply-To: <20210322155318.9837-1-johan@kernel.org> If tty-device registration fails the driver would fail to release the data interface. When the device is later disconnected, the disconnect callback would still be called for the data interface and would go about releasing already freed resources. Fixes: c93d81955005 ("usb: cdc-acm: fix error handling in acm_probe()") Cc: stable@vger.kernel.org # 3.9 Cc: Alexey Khoroshilov <khoroshilov@ispras.ru> Acked-by: Oliver Neukum <oneukum@suse.com> Signed-off-by: Johan Hovold <johan@kernel.org> --- drivers/usb/class/cdc-acm.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c index d75a78ad464d..dfc2480add91 100644 --- a/drivers/usb/class/cdc-acm.c +++ b/drivers/usb/class/cdc-acm.c @@ -1503,6 +1503,11 @@ static int acm_probe(struct usb_interface *intf, return 0; alloc_fail6: + if (!acm->combined_interfaces) { + /* Clear driver data so that disconnect() returns early. */ + usb_set_intfdata(data_interface, NULL); + usb_driver_release_interface(&acm_driver, data_interface); + } if (acm->country_codes) { device_remove_file(&acm->control->dev, &dev_attr_wCountryCodes); -- 2.26.3
next prev parent reply index Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-03-22 15:53 [PATCH v2 0/8] USB: cdc-acm: probe fixes Johan Hovold 2021-03-22 15:53 ` [PATCH v2 1/8] USB: cdc-acm: fix double free on probe failure Johan Hovold 2021-03-22 15:53 ` Johan Hovold [this message] 2021-03-22 15:53 ` [PATCH v2 3/8] USB: cdc-acm: drop redundant driver-data assignment Johan Hovold 2021-03-22 15:53 ` [PATCH v2 4/8] USB: cdc-acm: drop redundant driver-data reset Johan Hovold 2021-03-22 15:53 ` [PATCH v2 5/8] USB: cdc-acm: clean up probe error labels Johan Hovold 2021-03-22 15:53 ` [PATCH v2 6/8] USB: cdc-acm: use negation for NULL checks Johan Hovold 2021-03-22 15:53 ` [PATCH v2 7/8] USB: cdc-acm: always claim data interface Johan Hovold 2021-03-22 15:53 ` [PATCH v2 8/8] USB: cdc-acm: do not log successful probe on later errors Johan Hovold 2021-03-23 12:27 ` [PATCH v2 0/8] USB: cdc-acm: probe fixes Greg Kroah-Hartman
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210322155318.9837-3-johan@kernel.org \ --to=johan@kernel.org \ --cc=gregkh@linuxfoundation.org \ --cc=khoroshilov@ispras.ru \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-usb@vger.kernel.org \ --cc=oneukum@suse.com \ --cc=stable@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Linux-USB Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-usb/0 linux-usb/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-usb linux-usb/ https://lore.kernel.org/linux-usb \ linux-usb@vger.kernel.org public-inbox-index linux-usb Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-usb AGPL code for this site: git clone https://public-inbox.org/public-inbox.git