* [PATCH v2] USB: usbip: fix null-ptr-deref in status_show_vhci()
@ 2025-01-22 12:15 Qasim Ijaz
2025-01-22 12:30 ` Greg KH
0 siblings, 1 reply; 2+ messages in thread
From: Qasim Ijaz @ 2025-01-22 12:15 UTC (permalink / raw)
To: valentina.manea.m, shuah, i, gregkh, sergei.shtylyov
Cc: linux-usb, linux-kernel, syzbot
If usb_add_hcd() fails in vhci_hcd_probe() (i.e., a probe failure),
the error path calls usb_remove_hcd() and also sets
pdev->dev.driver_data to NULL.
Consequently, any subsequent call to platform_get_drvdata(pdev)
(which returns pdev->dev.driver_data) may yield NULL, causing a
crash if that pointer is dereferenced.
Fix this by adding a sanity check to ensure "hcd" is non-NULL
before proceeding with further operations.
Reported-by: syzbot <syzbot+83976e47ec1ef91e66f1@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=83976e47ec1ef91e66f1
Tested-by: syzbot <syzbot+83976e47ec1ef91e66f1@syzkaller.appspotmail.com>
Fixes: 03cd00d538a6 ("usbip: vhci-hcd: Set the vhci structure up to work")
Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
---
drivers/usb/usbip/vhci_sysfs.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index d5865460e82d..d4a1aa6d06b2 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -76,6 +76,9 @@ static ssize_t status_show_vhci(int pdev_nr, char *out)
}
hcd = platform_get_drvdata(pdev);
+ if (!hcd)
+ return 0;
+
vhci_hcd = hcd_to_vhci_hcd(hcd);
vhci = vhci_hcd->vhci;
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] USB: usbip: fix null-ptr-deref in status_show_vhci()
2025-01-22 12:15 [PATCH v2] USB: usbip: fix null-ptr-deref in status_show_vhci() Qasim Ijaz
@ 2025-01-22 12:30 ` Greg KH
0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2025-01-22 12:30 UTC (permalink / raw)
To: Qasim Ijaz
Cc: valentina.manea.m, shuah, i, sergei.shtylyov, linux-usb,
linux-kernel, syzbot
On Wed, Jan 22, 2025 at 12:15:29PM +0000, Qasim Ijaz wrote:
> If usb_add_hcd() fails in vhci_hcd_probe() (i.e., a probe failure),
> the error path calls usb_remove_hcd() and also sets
> pdev->dev.driver_data to NULL.
>
> Consequently, any subsequent call to platform_get_drvdata(pdev)
> (which returns pdev->dev.driver_data) may yield NULL, causing a
> crash if that pointer is dereferenced.
>
> Fix this by adding a sanity check to ensure "hcd" is non-NULL
> before proceeding with further operations.
>
> Reported-by: syzbot <syzbot+83976e47ec1ef91e66f1@syzkaller.appspotmail.com>
> Closes: https://syzkaller.appspot.com/bug?extid=83976e47ec1ef91e66f1
> Tested-by: syzbot <syzbot+83976e47ec1ef91e66f1@syzkaller.appspotmail.com>
> Fixes: 03cd00d538a6 ("usbip: vhci-hcd: Set the vhci structure up to work")
> Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
> ---
> drivers/usb/usbip/vhci_sysfs.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
> index d5865460e82d..d4a1aa6d06b2 100644
> --- a/drivers/usb/usbip/vhci_sysfs.c
> +++ b/drivers/usb/usbip/vhci_sysfs.c
> @@ -76,6 +76,9 @@ static ssize_t status_show_vhci(int pdev_nr, char *out)
> }
>
> hcd = platform_get_drvdata(pdev);
> + if (!hcd)
> + return 0;
> +
> vhci_hcd = hcd_to_vhci_hcd(hcd);
> vhci = vhci_hcd->vhci;
>
> --
> 2.39.5
>
>
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.
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] 2+ messages in thread
end of thread, other threads:[~2025-01-22 12:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-22 12:15 [PATCH v2] USB: usbip: fix null-ptr-deref in status_show_vhci() Qasim Ijaz
2025-01-22 12:30 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).