Out-of-process WSL plugin runtime

Open
#41,967 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp

Research direction

Start by reading the WSL plugin loading and runtime entry points; the issue does not name specific files or tests. The proposal requires designing process isolation, lifecycle control, restart behavior, and plugin initialization events. Done would mean agreeing on an architecture that supports those capabilities without restarting the WSL service.

Written by the indexing model from the issue text.

Description

feature

Problem

Currently, a WSL plugin is a DLL directly loaded into the wslservice.exe process when it starts. There is no way to manage the lifecycle of that library other than that, which is quite inconvenient.

Indeed, when installing the file at a certain path and then registering it in the right Registry key, then it is not possible to instruct the WSL runtime to load it immediately. Similarly, when updating it, there is no way to instruct the runtime to unload it and load the new one. This makes it hard to handle the basics of software integration.

Also, having the library directly loaded into a central process poses a few risks that cannot be managed externally:

  • if some of its code crashes, then the WSL service crashes as well;
  • if it gets stuck, then it is not possible to "unstick" it by for example killing it without actually killing the WSL service process;
  • potentially-vulnerable code gets brought into the WSL service process, thus enabling some attack surface;
  • ...

Solution

The ideal would be to move plugins into processes, one per plugin, dedicated to handling their execution with respect to the global runtime that would communicate with them. This would be effectively similar to COM servers in spirit. Some control over these service-like processes would be nice too.

This way, if a crash occurs in a plugin, then only its dedicated runtime process would crash, thus improving safety. Then, upon such an event, the global WSL runtime could detect that this process died and automatically restart it. Also, it would enable managing plugins externally: it would become possible to just stop a plugin process, update its library and instruct the runtime to load it again without restarting the entire WSL service.

Upon a load, it would be nice to also add some kind of event the plugin could react to in order to be able to call the API and perform any initialization/update of what it performs in the Linux space. Alternatively, an already-existing event or series of events recorded until load time could be fired at the newly-loaded plugin to achieve the same end result.

Alternatives

  • Just some control over the load and unload of the plugins, but I'm not sure if that's really possible with loader APIs.
  • Just restarting the WSL service upon installing or updating a plugin, but that is extremely aggressive and may very well result in data loss, especially considering how WSL2 and WSLG are used mostly interactively by end users.
Dominant language
C++
Stars
34.4k
Forks
1.9k
Avg merge
1d 23h
Merged PRs (30d)
166

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/WSL

All issues in microsoft/WSL

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.