* [PATCH] driver core: avoid klist_remove() on unattached knode_driver @ 2026-08-20 5:55 Nguyen Quang Le Kien 2026-08-20 6:05 ` [PATCH v2] " Nguyen Quang Le Kien 0 siblings, 1 reply; 9+ messages in thread From: Nguyen Quang Le Kien @ 2026-08-20 5:55 UTC (permalink / raw) To: gregkh, rafael, dakr Cc: driver-core, linux-usb, linux-kernel, Nguyen Quang Le Kien, syzbot+87188222c77c0dbbdb4d usb_driver_claim_interface() sets dev->driver directly and skips device_bind_driver() when the interface is not yet registered, so the device can reach teardown with dev->driver set but knode_driver never added to the driver's klist_devices. __device_release_driver() then unconditionally calls klist_remove() on the unattached node, which dereferences a NULL klist pointer in klist_put() and crashes. Guard the klist_remove() with klist_node_attached(), mirroring the existing check in bus_remove_device() for knode_bus. Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com> --- drivers/base/dd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 60c005223..14752a5e5 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1354,7 +1354,8 @@ static void __device_release_driver(struct device *dev, struct device *parent) device_unbind_cleanup(dev); device_links_driver_cleanup(dev); - klist_remove(&dev->p->knode_driver); + if (klist_node_attached(&dev->p->knode_driver)) + klist_remove(&dev->p->knode_driver); device_pm_check_callbacks(dev); bus_notify(dev, BUS_NOTIFY_UNBOUND_DRIVER); -- 2.34.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH v2] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 5:55 [PATCH] driver core: avoid klist_remove() on unattached knode_driver Nguyen Quang Le Kien @ 2026-08-20 6:05 ` Nguyen Quang Le Kien 2026-08-20 6:40 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Nguyen Quang Le Kien @ 2026-08-20 6:05 UTC (permalink / raw) To: gregkh, rafael, dakr Cc: driver-core, linux-usb, linux-kernel, Nguyen Quang Le Kien, syzbot+87188222c77c0dbbdb4d usb_driver_claim_interface() sets dev->driver directly and skips device_bind_driver() when the interface is not yet registered, so the device can reach teardown with dev->driver set but knode_driver never added to the driver's klist_devices. __device_release_driver() then unconditionally calls klist_remove() on the unattached node, which dereferences a NULL klist pointer in klist_put() and crashes. Only remove the node if the device is actually bound, mirroring the check device_is_bound() already provides for the driver core. This matches the existing guard on knode_bus in bus_remove_device(). Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com> --- drivers/base/dd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 60c005223..4154b4499 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1354,7 +1354,8 @@ static void __device_release_driver(struct device *dev, struct device *parent) device_unbind_cleanup(dev); device_links_driver_cleanup(dev); - klist_remove(&dev->p->knode_driver); + if (device_is_bound(dev)) + klist_remove(&dev->p->knode_driver); device_pm_check_callbacks(dev); bus_notify(dev, BUS_NOTIFY_UNBOUND_DRIVER); -- 2.34.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v2] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 6:05 ` [PATCH v2] " Nguyen Quang Le Kien @ 2026-08-20 6:40 ` Greg KH 2026-08-20 6:56 ` Nguyen Quang Le Kien 2026-08-20 7:45 ` [PATCH v3] " Nguyen Quang Le Kien 0 siblings, 2 replies; 9+ messages in thread From: Greg KH @ 2026-08-20 6:40 UTC (permalink / raw) To: Nguyen Quang Le Kien, eadavis Cc: rafael, dakr, driver-core, linux-usb, linux-kernel, syzbot+87188222c77c0dbbdb4d On Thu, Aug 20, 2026 at 02:05:23PM +0800, Nguyen Quang Le Kien wrote: > usb_driver_claim_interface() sets dev->driver directly and skips > device_bind_driver() when the interface is not yet registered, so the > device can reach teardown with dev->driver set but knode_driver never > added to the driver's klist_devices. __device_release_driver() then > unconditionally calls klist_remove() on the unattached node, which > dereferences a NULL klist pointer in klist_put() and crashes. > > Only remove the node if the device is actually bound, mirroring the > check device_is_bound() already provides for the driver core. This > matches the existing guard on knode_bus in bus_remove_device(). > > Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d > Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com> > --- > drivers/base/dd.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) What changed from v1? And why did you send the same patch as Edward Adam Davis <eadavis@qq.com> just did: https://lore.kernel.org/r/tencent_0B76C5676E3DA13640962637444B28743709@qq.com What is suddenly causing people to care about syzbot bugs for USB? thanks, greg k-h ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 6:40 ` Greg KH @ 2026-08-20 6:56 ` Nguyen Quang Le Kien 2026-08-20 7:05 ` Greg Kroah-Hartman 2026-08-20 7:45 ` [PATCH v3] " Nguyen Quang Le Kien 1 sibling, 1 reply; 9+ messages in thread From: Nguyen Quang Le Kien @ 2026-08-20 6:56 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-kernel, linux-usb, driver-core, Nguyen Quang Le Kien Hi Greg, v1 used klist_node_attached(&dev->p->knode_driver). v1 passed the syzbot test, but after reviewing the code again I realized klist_node_attached() isn't really the right check at that level -- it's a raw klist API. device_is_bound() is what driver core uses to ask whether a device is bound, and it also handles the NULL dev->p case. So I switched to that in v2. Nothing else changed. As for syzbot -- it's just where I find kernel bugs, and it can test my patches for me. That's all. Thanks, Kien ^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH v2] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 6:56 ` Nguyen Quang Le Kien @ 2026-08-20 7:05 ` Greg Kroah-Hartman 0 siblings, 0 replies; 9+ messages in thread From: Greg Kroah-Hartman @ 2026-08-20 7:05 UTC (permalink / raw) To: Nguyen Quang Le Kien; +Cc: linux-kernel, linux-usb, driver-core On Thu, Aug 20, 2026 at 02:56:06PM +0800, Nguyen Quang Le Kien wrote: > Hi Greg, Please provide email context when responding, some of us get 1000+ emails a day. > v1 used klist_node_attached(&dev->p->knode_driver). v1 passed the syzbot > test, but after reviewing the code again I realized klist_node_attached() > isn't really the right check at that level -- it's a raw klist API. Then please document this in the proper place, for v2, as required. thanks, greg k-h ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v3] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 6:40 ` Greg KH 2026-08-20 6:56 ` Nguyen Quang Le Kien @ 2026-08-20 7:45 ` Nguyen Quang Le Kien 2026-08-20 8:23 ` Greg Kroah-Hartman 1 sibling, 1 reply; 9+ messages in thread From: Nguyen Quang Le Kien @ 2026-08-20 7:45 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-kernel, linux-usb, driver-core, syzbot+87188222c77c0dbbdb4d, Nguyen Quang Le Kien usb_driver_claim_interface() sets dev->driver directly and skips device_bind_driver() when the interface is not yet registered, so the device can reach teardown with dev->driver set but knode_driver never added to the driver's klist_devices. __device_release_driver() then unconditionally calls klist_remove() on the unattached node, which dereferences a NULL klist pointer in klist_put() and crashes. Only remove the node if the device is actually bound. Use device_is_bound() rather than klist_node_attached() directly: the latter is a raw klist API and does not NULL-check dev->p, while device_is_bound() is the standard bound-state check used throughout driver core (driver_bound(), __device_attach()). Fixes: 94e7b1c5ff20 ("[PATCH] Add a klist to struct device_driver for the devices bound to it.") Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com> --- drivers/base/dd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 60c005223..4154b4499 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1354,7 +1354,8 @@ static void __device_release_driver(struct device *dev, struct device *parent) device_unbind_cleanup(dev); device_links_driver_cleanup(dev); - klist_remove(&dev->p->knode_driver); + if (device_is_bound(dev)) + klist_remove(&dev->p->knode_driver); device_pm_check_callbacks(dev); bus_notify(dev, BUS_NOTIFY_UNBOUND_DRIVER); -- 2.34.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v3] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 7:45 ` [PATCH v3] " Nguyen Quang Le Kien @ 2026-08-20 8:23 ` Greg Kroah-Hartman 2026-08-20 8:45 ` [PATCH v4] " Nguyen Quang Le Kien 0 siblings, 1 reply; 9+ messages in thread From: Greg Kroah-Hartman @ 2026-08-20 8:23 UTC (permalink / raw) To: Nguyen Quang Le Kien Cc: linux-kernel, linux-usb, driver-core, syzbot+87188222c77c0dbbdb4d On Thu, Aug 20, 2026 at 03:45:38PM +0800, Nguyen Quang Le Kien wrote: > usb_driver_claim_interface() sets dev->driver directly and skips > device_bind_driver() when the interface is not yet registered, so the > device can reach teardown with dev->driver set but knode_driver never > added to the driver's klist_devices. __device_release_driver() then > unconditionally calls klist_remove() on the unattached node, which > dereferences a NULL klist pointer in klist_put() and crashes. > > Only remove the node if the device is actually bound. Use > device_is_bound() rather than klist_node_attached() directly: the > latter is a raw klist API and does not NULL-check dev->p, while > device_is_bound() is the standard bound-state check used throughout > driver core (driver_bound(), __device_attach()). > > Fixes: 94e7b1c5ff20 ("[PATCH] Add a klist to struct device_driver for the devices bound to it.") > Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d > Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com> > --- > drivers/base/dd.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > index 60c005223..4154b4499 100644 > --- a/drivers/base/dd.c > +++ b/drivers/base/dd.c > @@ -1354,7 +1354,8 @@ static void __device_release_driver(struct device *dev, struct device *parent) > device_unbind_cleanup(dev); > device_links_driver_cleanup(dev); > > - klist_remove(&dev->p->knode_driver); > + if (device_is_bound(dev)) > + klist_remove(&dev->p->knode_driver); > device_pm_check_callbacks(dev); > > bus_notify(dev, BUS_NOTIFY_UNBOUND_DRIVER); > -- > 2.34.1 > > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this. - You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this. - You have sent patches very very quickly, with no time to have others review them. Slow down, there is no rush here, and no deadlines. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot ^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH v4] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 8:23 ` Greg Kroah-Hartman @ 2026-08-20 8:45 ` Nguyen Quang Le Kien 2026-08-20 8:56 ` Greg KH 0 siblings, 1 reply; 9+ messages in thread From: Nguyen Quang Le Kien @ 2026-08-20 8:45 UTC (permalink / raw) To: gregkh Cc: rafael, dakr, driver-core, linux-kernel, Nguyen Quang Le Kien, syzbot+87188222c77c0dbbdb4d, stable usb_driver_claim_interface() sets dev->driver directly and skips device_bind_driver() when the interface is not yet registered, so the device can reach teardown with dev->driver set but knode_driver never added to the driver's klist_devices. __device_release_driver() then unconditionally calls klist_remove() on the unattached node, which dereferences a NULL klist pointer in klist_put() and crashes. Only remove the node if the device is actually bound. Use device_is_bound() rather than klist_node_attached() directly: the latter is a raw klist API and does not NULL-check dev->p, while device_is_bound() is the standard bound-state check used throughout driver core (driver_bound(), __device_attach()). Fixes: 94e7b1c5ff20 ("[PATCH] Add a klist to struct device_driver for the devices bound to it.") Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d Cc: stable@vger.kernel.org Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com> --- Changes in v4: - add a changelog below the --- line, as required by submitting-patches.rst - add Cc: stable@vger.kernel.org, Fixes: points to a released kernel Changes in v3: - document in the commit message why device_is_bound() is used instead of klist_node_attached() - add Fixes: tag Changes in v2: - use device_is_bound() instead of klist_node_attached() as the bound check, per review --- drivers/base/dd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/dd.c b/drivers/base/dd.c index 60c005223..4154b4499 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -1354,7 +1354,8 @@ static void __device_release_driver(struct device *dev, struct device *parent) device_unbind_cleanup(dev); device_links_driver_cleanup(dev); - klist_remove(&dev->p->knode_driver); + if (device_is_bound(dev)) + klist_remove(&dev->p->knode_driver); device_pm_check_callbacks(dev); bus_notify(dev, BUS_NOTIFY_UNBOUND_DRIVER); -- 2.34.1 ^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH v4] driver core: avoid klist_remove() on unattached knode_driver 2026-08-20 8:45 ` [PATCH v4] " Nguyen Quang Le Kien @ 2026-08-20 8:56 ` Greg KH 0 siblings, 0 replies; 9+ messages in thread From: Greg KH @ 2026-08-20 8:56 UTC (permalink / raw) To: Nguyen Quang Le Kien Cc: rafael, dakr, driver-core, linux-kernel, syzbot+87188222c77c0dbbdb4d, stable On Thu, Aug 20, 2026 at 04:45:57PM +0800, Nguyen Quang Le Kien wrote: > usb_driver_claim_interface() sets dev->driver directly and skips > device_bind_driver() when the interface is not yet registered, so the > device can reach teardown with dev->driver set but knode_driver never > added to the driver's klist_devices. __device_release_driver() then > unconditionally calls klist_remove() on the unattached node, which > dereferences a NULL klist pointer in klist_put() and crashes. > > Only remove the node if the device is actually bound. Use > device_is_bound() rather than klist_node_attached() directly: the > latter is a raw klist API and does not NULL-check dev->p, while > device_is_bound() is the standard bound-state check used throughout > driver core (driver_bound(), __device_attach()). > > Fixes: 94e7b1c5ff20 ("[PATCH] Add a klist to struct device_driver for the devices bound to it.") > Reported-by: syzbot+87188222c77c0dbbdb4d@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=87188222c77c0dbbdb4d > Cc: stable@vger.kernel.org > Signed-off-by: Nguyen Quang Le Kien <khiemtranzo532001@gmail.com> > --- > Changes in v4: > - add a changelog below the --- line, as required by submitting-patches.rst > - add Cc: stable@vger.kernel.org, Fixes: points to a released kernel Please slow down. As my bot said, there is no rush, no deadline, and it's the middle of the merge window and we can't even do anything with this anyway. At the least, wait a week between patch revisions. If you wish to see patches reviewed faster, then help out with actual reviews of patches from others. Constantly resending stuff like this doesn't make anyone want to review this at all. thanks, greg k-h ^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-08-20 8:56 UTC | newest] Thread overview: 9+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-08-20 5:55 [PATCH] driver core: avoid klist_remove() on unattached knode_driver Nguyen Quang Le Kien 2026-08-20 6:05 ` [PATCH v2] " Nguyen Quang Le Kien 2026-08-20 6:40 ` Greg KH 2026-08-20 6:56 ` Nguyen Quang Le Kien 2026-08-20 7:05 ` Greg Kroah-Hartman 2026-08-20 7:45 ` [PATCH v3] " Nguyen Quang Le Kien 2026-08-20 8:23 ` Greg Kroah-Hartman 2026-08-20 8:45 ` [PATCH v4] " Nguyen Quang Le Kien 2026-08-20 8:56 ` Greg KH
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox