Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error running modprobe for vhci_hcd kernel module #1050

Open
pdietl opened this issue Nov 3, 2024 · 1 comment
Open

Error running modprobe for vhci_hcd kernel module #1050

pdietl opened this issue Nov 3, 2024 · 1 comment

Comments

@pdietl
Copy link

pdietl commented Nov 3, 2024

So I built my own WSL kernel and accidentally set some kernel modules to M instead of Y and so they became modules rather than built directly into the kernel. Thus, I stumbled upon the code here

wslResult = await RunWslAsync((distribution, "/"), null, false, cancellationToken, "modprobe", "vhci_hcd");
that tries to remedy the situation by calling modprobe. I kept getting this error:

PS C:\Users\peted> usbipd.exe attach --wsl --busid 7-1
usbipd: info: Using WSL distribution 'Ubuntu-24.04' to attach; the device will be available in all WSL 2 distributions.
usbipd: info: Loading vhci_hcd module.
usbipd: error: Loading vhci_hcd failed.

To investigate this, I tried running C:\Windows\System32\wsl.exe --distribution Ubuntu-24.04 --user root --cd / --exec modprobe and got this result: <3>WSL (77192) ERROR: CreateProcessCommon:559: execvpe(modprobe) failed: No such file or directory. From there, I tried running C:\Windows\System32\wsl.exe --distribution Ubuntu-24.04 --user root --cd / -- ls and curiously, that worked just fine.

After some fiddling around, I finally found my answer in the documentation for execvpe:

p - execlp(), execvp(), execvpe()
These functions duplicate the actions of the shell in searching
for an executable file if the specified filename does not contain
a slash (/) character. The file is sought in the colon-separated
list of directory pathnames specified in the PATH environment
variable. If this variable isn't defined, the path list defaults
to a list that includes the directories returned by
confstr(_CS_PATH) (which typically returns the value
"/bin:/usr/bin") and possibly also the current working directory;
see VERSIONS for further details.

   execvpe() searches for the program using the value of PATH from
   the caller's environment, not from the envp argument.

   If the specified filename includes a slash character, then PATH
   is ignored, and the file at the specified pathname is executed.

So, the command after the --exec argument is indeed executed with an environ containing no PATH entry, but because of how execvpe works, the argument gets looked for in /bin and in /usr/bin. Crucially in Ubuntu at least, modprobe is installed in /usr/sbin/modprobe, and thus was not found.

As for how to go about fixing this, there are several possibilities:

  1. Also try executing /usr/sbin/modprobe explicitly.
  2. Execute modprobe with the --exec argument, which runs it in a shell which probably has its PATH variable set properly.
  3. Something else
@pdietl
Copy link
Author

pdietl commented Nov 21, 2024

@dorssel could you take a look at this? I can do all of the work; I just would like your input on my approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant