From: Greg KH <gregkh@linuxfoundation.org>
To: Zongmin Zhou <min_halo@163.com>
Cc: skhan@linuxfoundation.org, i@zenithal.me,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
valentina.manea.m@gmail.com,
Zongmin Zhou <zhouzongmin@kylinos.cn>
Subject: Re: [PATCH v2] usbip: tools: Add usbip host driver availability check
Date: Thu, 26 Mar 2026 09:43:08 +0100 [thread overview]
Message-ID: <2026032615-donated-chaps-9eac@gregkh> (raw)
In-Reply-To: <1fdab10a-86f0-454a-af10-396a53169ea7@163.com>
On Thu, Mar 26, 2026 at 11:10:02AM +0800, Zongmin Zhou wrote:
>
> On 2026/3/25 16:58, Greg KH wrote:
> > On Wed, Mar 25, 2026 at 10:26:34AM +0800, Zongmin Zhou wrote:
> > > From: Zongmin Zhou <zhouzongmin@kylinos.cn>
> > >
> > > Currently, usbip_generic_driver_open() doesn't verify that the required
> > > kernel module (usbip-host or usbip-vudc) is actually loaded.
> > > The function returns success even when no driver is present,
> > > leading to usbipd daemon run success without driver loaded.
> > >
> > > So add a check function to ensure usbip host driver has been loaded.
> > >
> > > Suggested-by: Shuah Khan <skhan@linuxfoundation.org>
> > > Signed-off-by: Zongmin Zhou <zhouzongmin@kylinos.cn>
> > > ---
> > > Changes in v2:
> > > - Use system calls directly instead of checking sysfs dir.
> > >
> > > tools/usb/usbip/libsrc/usbip_device_driver.c | 7 +++++--
> > > tools/usb/usbip/libsrc/usbip_host_driver.c | 8 ++++++--
> > > 2 files changed, 11 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/tools/usb/usbip/libsrc/usbip_device_driver.c b/tools/usb/usbip/libsrc/usbip_device_driver.c
> > > index 927a151fa9aa..45ab647ef241 100644
> > > --- a/tools/usb/usbip/libsrc/usbip_device_driver.c
> > > +++ b/tools/usb/usbip/libsrc/usbip_device_driver.c
> > > @@ -136,10 +136,13 @@ static int usbip_device_driver_open(struct usbip_host_driver *hdriver)
> > > hdriver->ndevs = 0;
> > > INIT_LIST_HEAD(&hdriver->edev_list);
> > > - ret = usbip_generic_driver_open(hdriver);
> > > - if (ret)
> > > + if (system("/sbin/lsmod | grep -q usbip_vudc")){
> > What happens if the module is built into the kernel?
> >
> > > err("please load " USBIP_CORE_MOD_NAME ".ko and "
> > > USBIP_DEVICE_DRV_NAME ".ko!");
> > > + return -1;
> > > + }
> > > +
> > > + ret = usbip_generic_driver_open(hdriver);
> > > return ret;
> > > }
> > > diff --git a/tools/usb/usbip/libsrc/usbip_host_driver.c b/tools/usb/usbip/libsrc/usbip_host_driver.c
> > > index 573e73ec36bd..f0ac941d4f6e 100644
> > > --- a/tools/usb/usbip/libsrc/usbip_host_driver.c
> > > +++ b/tools/usb/usbip/libsrc/usbip_host_driver.c
> > > @@ -31,10 +31,14 @@ static int usbip_host_driver_open(struct usbip_host_driver *hdriver)
> > > hdriver->ndevs = 0;
> > > INIT_LIST_HEAD(&hdriver->edev_list);
> > > - ret = usbip_generic_driver_open(hdriver);
> > > - if (ret)
> > > + if (system("/sbin/lsmod | grep -q usbip_host")){
> > Same here, what happens if it is built in?
> Thank you for pointing this out.
> I apologize for not considering the built-in module case.
>
> You are right that using lsmod | grep would incorrectly fail when usbip_host
> is built into the kernel (CONFIG_USBIP_HOST=y).
> Usbip has always been built as a loadable module (.ko) by default, which led
> to this oversight.
>
> To address this issue, would the following approach be acceptable?
Wait, what "issue" are you trying to fix here? Why can't you just check
for opening the correct device node when the host opens the file and if
that fails, report an error? Doesn't that happen today already?
> 1. Uses /sys/module/usbip_host to check wehther had been loaded, which
> exists for both loadable modules and built-in drivers.
> 2. Attempts to load the module via modprobe if it is not already loaded.
Don't do module autoloading, that might surprise users that previously
were not expecting it.
thanks,
greg k-h
next prev parent reply other threads:[~2026-03-26 8:43 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 8:17 [PATCH] usbip: tools: Add usbip host driver availability check Zongmin Zhou
2026-03-10 22:28 ` Shuah Khan
2026-03-12 2:17 ` Zongmin Zhou
2026-03-23 19:17 ` Shuah Khan
2026-03-25 2:26 ` [PATCH v2] " Zongmin Zhou
2026-03-25 8:58 ` Greg KH
2026-03-26 3:10 ` Zongmin Zhou
2026-03-26 8:43 ` Greg KH [this message]
2026-03-26 18:43 ` Shuah Khan
2026-03-27 8:39 ` Zongmin Zhou
2026-03-27 17:51 ` Shuah Khan
2026-03-27 18:29 ` Shuah Khan
2026-03-30 3:10 ` Zongmin Zhou
2026-03-11 12:13 ` [PATCH] " Greg KH
2026-03-12 2:17 ` Zongmin Zhou
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=2026032615-donated-chaps-9eac@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=i@zenithal.me \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=min_halo@163.com \
--cc=skhan@linuxfoundation.org \
--cc=valentina.manea.m@gmail.com \
--cc=zhouzongmin@kylinos.cn \
/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