mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sergey Shtylyov <sergei.shtylyov@gmail.com>
To: Qasim Ijaz <qasdev00@gmail.com>,
	valentina.manea.m@gmail.com, shuah@kernel.org, i@zenithal.me,
	gregkh@linuxfoundation.org
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	syzbot <syzbot+83976e47ec1ef91e66f1@syzkaller.appspotmail.com>
Subject: Re: [PATCH] USB: usbip: fix null-ptr-deref in status_show_vhci()
Date: Wed, 22 Jan 2025 11:56:34 +0300	[thread overview]
Message-ID: <352b31e8-f8ef-4207-81a7-0aa22c984aeb@gmail.com> (raw)
In-Reply-To: <20250121203648.23775-1-qasdev00@gmail.com>

On 1/21/25 11:36 PM, 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 | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
> index d5865460e82d..a5e6c3c4af06 100644
> --- a/drivers/usb/usbip/vhci_sysfs.c
> +++ b/drivers/usb/usbip/vhci_sysfs.c
> @@ -76,6 +76,10 @@ static ssize_t status_show_vhci(int pdev_nr, char *out)
>  	}
>  
>  	hcd = platform_get_drvdata(pdev);
> +

   Empty line net really needed here...

> +	if (!hcd)
> +		return 0;
> +
>  	vhci_hcd = hcd_to_vhci_hcd(hcd);
>  	vhci = vhci_hcd->vhci;
>  

MBR, Sergey


  reply	other threads:[~2025-01-22  8:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-21 20:36 Qasim Ijaz
2025-01-22  8:56 ` Sergey Shtylyov [this message]
2025-01-22 12:23 Qasim Ijaz

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=352b31e8-f8ef-4207-81a7-0aa22c984aeb@gmail.com \
    --to=sergei.shtylyov@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=i@zenithal.me \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=qasdev00@gmail.com \
    --cc=shuah@kernel.org \
    --cc=syzbot+83976e47ec1ef91e66f1@syzkaller.appspotmail.com \
    --cc=valentina.manea.m@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®