From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D164C17B50A for ; Sat, 15 Aug 2026 12:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.70 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786798076; cv=none; b=OFookW105tVMJ4FRdnvVVS20g58QdY1p9VaCkS9gbA/DIu31E0TFR+Hml9I2+uQs29PfqQxW/PojmhqbrqyKJwG5jjTF035hiRDskyV2Q6w7dAkPRxNb9nO+RWgqoU4LMQsrPoQftqzxHtbKUlxMI1jnAwZpZNezme+KmhEKzfk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786798076; c=relaxed/simple; bh=GJkAjGBxNjtXYFSFGeECzyrfl63LkrOkOKBzZeWwfoU=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=O6ZdzDkdZC3sjQVaOguMtNO2DZ/pNoMsTIB0sMRZ1TYKjSaKA3o5PvY6/S5AsxwFNaSZSSWIvwyRpxoHJkig4Fa3Or39TbyhJZ1oWYLb91N+EH0ULqxxEM3wAXgrdA3iY9a/Lhu8YX3gjJTS3muIxyjOWNdy7XzZybgTUInj68w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.70 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f70.google.com with SMTP id 46e09a7af769-7eb6a8c61deso1494924a34.3 for ; Sat, 15 Aug 2026 05:47:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786798074; x=1787402874; h=content-type:to:from:subject:message-id:in-reply-to:date :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=e9koJRbzN4t12kpozZYjirCLZVQvguthwzWRUbNeKqA=; b=nAIimbhmEYtUXbAq+rBJN54VNlkAZoyks3EA09hEgfqpXqXB7BGgSwcHfVF5NOlvLu IHFSh4ZuEAK9tIpZZx5miRhQUbtvhB6Q1mCLKaDd1br2lnU5BvDkIVwYJ0BdWl363WAJ IjvYDQAqi2foQTj6Q4LKPcA7eFnYSu93WCFjS65WBf4S/eFGeP5Z+ufwRmiFTpAbO5Zq VdvBxv1zQfCRP+JF1COY7zSHdhf1/txIx+0ZQ9KpG0FFcUF578LGNkmrDWh5L0oH8I/z UYs/4gImKyJDaZ6EOkmWUlfSLbLoUSMHs3R+1gW2xqZGzBZejbisFzXLyF5MdcNnRiGE ZXdg== X-Gm-Message-State: AOJu0YxwmTmerrSF6OFkUWhnTeYjCE41iFdBEnQswXizTUYHBsECBDkD GhbvzPVfsRX191C1ZVfggbwJDDsOAnj+bJjGTwU48SbjH4y2m3J1su6h5+P5QdwyNmfiDI2h3BP CNvbr/EhXHau0yTsW9tIGY/amuYBfJ8Ban8DK924DjpXYW5OH7XJ48wYmotY= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:4dfa:b0:6ae:42c7:ef95 with SMTP id 006d021491bc7-6b0d6139d00mr10611912eaf.13.1786798073871; Sat, 15 Aug 2026 05:47:53 -0700 (PDT) Date: Sat, 15 Aug 2026 05:47:53 -0700 In-Reply-To: <6a7ee0b6.91706f20.9568a.0005.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a805ff9.dbb3a75c.20434b.0017.GAE@google.com> Subject: Forwarded: [PATCH] usbip: vhci_hcd: fix UAF in attach_store() during unbind From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] usbip: vhci_hcd: fix UAF in attach_store() during unbind Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master vhci_hcd_remove() frees the SS hcd via usb_put_hcd() before the HS hcd's vhci_stop() removes the sysfs attribute group, since the group removal is guarded by usb_hcd_is_primary_hcd(). A concurrent write to the attach attribute can therefore reach vhci->vhci_hcd_ss after it has been freed. Remove the attribute group at the start of vhci_hcd_remove(), before either hcd reference is dropped. sysfs_remove_group() drains in-flight store callbacks, so no writer can be inside attach_store() once it returns. Reported-by: syzbot+8753715f05759f1a10de@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=8753715f05759f1a10de Signed-off-by: Deepanshu Kartikey --- drivers/usb/usbip/vhci_hcd.c | 39 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 39e8faf4c18c..3ce8893729b1 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -1252,18 +1252,11 @@ static int vhci_start(struct usb_hcd *hcd) static void vhci_stop(struct usb_hcd *hcd) { struct vhci_hcd *vhci_hcd = hcd_to_vhci_hcd(hcd); - int id, rhport; + int rhport; usbip_dbg_vhci_hc("stop VHCI controller\n"); - /* 1. remove the userland interface of vhci_hcd */ - id = hcd_name_to_id(hcd_name(hcd)); - if (id == 0 && usb_hcd_is_primary_hcd(hcd)) { - sysfs_remove_group(&hcd_dev(hcd)->kobj, &vhci_attr_group); - vhci_finish_attr_group(); - } - - /* 2. shutdown all the ports of vhci_hcd */ + /* shutdown all the ports of vhci_hcd */ for (rhport = 0; rhport < VHCI_HC_PORTS; rhport++) { struct vhci_device *vdev = &vhci_hcd->vdev[rhport]; @@ -1421,20 +1414,34 @@ static int vhci_hcd_probe(struct platform_device *pdev) static void vhci_hcd_remove(struct platform_device *pdev) { struct vhci *vhci = *((void **)dev_get_platdata(&pdev->dev)); + struct usb_hcd *hcd_hs = vhci_hcd_to_hcd(vhci->vhci_hcd_hs); + struct usb_hcd *hcd_ss = vhci_hcd_to_hcd(vhci->vhci_hcd_ss); + + /* + * Remove the userland interface before dropping the hcd references. + * sysfs_remove_group() waits for in-flight attach_store()/detach_store() + * callers to return and rejects new ones, so neither hcd can be reached + * from sysfs by the time it is freed below. + */ + if (pdev->id == 0) { + sysfs_remove_group(&pdev->dev.kobj, &vhci_attr_group); + vhci_finish_attr_group(); + } + + vhci->vhci_hcd_hs = NULL; + vhci->vhci_hcd_ss = NULL; + /* * Disconnects the root hub, * then reverses the effects of usb_add_hcd(), * invoking the HCD's stop() methods. */ - usb_remove_hcd(vhci_hcd_to_hcd(vhci->vhci_hcd_ss)); - usb_put_hcd(vhci_hcd_to_hcd(vhci->vhci_hcd_ss)); - - usb_remove_hcd(vhci_hcd_to_hcd(vhci->vhci_hcd_hs)); - usb_put_hcd(vhci_hcd_to_hcd(vhci->vhci_hcd_hs)); + usb_remove_hcd(hcd_ss); + usb_put_hcd(hcd_ss); - vhci->vhci_hcd_hs = NULL; - vhci->vhci_hcd_ss = NULL; + usb_remove_hcd(hcd_hs); + usb_put_hcd(hcd_hs); } #ifdef CONFIG_PM -- 2.43.0