Skip to content

[GStreamer] plugin scanner not available in bwrap sandbox #40320

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

Merged
merged 1 commit into from
Jun 29, 2025

Conversation

philn
Copy link
Member

@philn philn commented Feb 9, 2025

526ec66

[GStreamer] plugin scanner not available in bwrap sandbox
https://bugs.webkit.org/show_bug.cgi?id=287368

Reviewed by Michael Catanzaro.

On UsrMerge systems where /lib64 is a symlink to /usr/lib64 and where the GStreamer registry
attempts to load the plugin-scanner from /lib64/ the path needs to be allow-listed in the sandbox.

* Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
(WebKit::bindGStreamerData):

Canonical link: https://commits.webkit.org/296779@main

b6d2cdc

Misc iOS, visionOS, tvOS & watchOS macOS Linux Windows
✅ 🧪 style ✅ 🛠 ios ✅ 🛠 mac ✅ 🛠 wpe ✅ 🛠 win
✅ 🛠 ios-sim ✅ 🛠 mac-AS-debug ✅ 🧪 wpe-wk2 ⏳ 🧪 win-tests
✅ 🧪 webkitperl ✅ 🧪 ios-wk2 ✅ 🧪 api-mac ✅ 🧪 api-wpe
✅ 🧪 ios-wk2-wpt ✅ 🛠 wpe-cairo
✅ 🧪 api-ios ✅ 🧪 mac-wk2 ✅ 🛠 gtk
✅ 🛠 vision ✅ 🧪 mac-AS-debug-wk2 🧪 gtk-wk2
✅ 🛠 vision-sim ✅ 🧪 mac-wk2-stress ❌ 🧪 api-gtk
✅ 🛠 🧪 merge ✅ 🧪 vision-wk2 ✅ 🧪 mac-intel-wk2 ✅ 🛠 playstation
✅ 🛠 tv ✅ 🛠 mac-safer-cpp
✅ 🛠 tv-sim
✅ 🛠 watch
✅ 🛠 watch-sim

@philn philn requested a review from a team as a code owner February 9, 2025 20:05
@philn philn self-assigned this Feb 9, 2025
@philn philn added the Platform Portability improvements and other general platform improvements not driven directly by site bugs. label Feb 9, 2025
Copy link
Contributor

@mcatanzaro mcatanzaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to click Approve, but I do wonder if this is really significantly easier than just adding some more symlinks to sandboxArgs in bubblewrapSpawn to fix things for more than just GStreamer?

We could test if /lib64 is a symlink on the host, and if so, then do "--symlink", "/lib64", "/usr/lib64", and that should probably fix this? Then we don't need to wonder what else besides GStreamer might be broken.

I checked what flatpak does. flatpak_run_setup_usr_links() creates symlinks for abs_usrmerged_dirs which is defined in flatpak-exports.c to be /bin, /lib, /lib32, /lib64, and /sbin. That's not so many locations; doesn't seem too hard?

@mcatanzaro
Copy link
Contributor

CC @TingPing

@philn
Copy link
Member Author

philn commented Feb 10, 2025

Yeah, I suppose we can use the same approach as flatpak. I can rework this, thanks for the review/feedback.

@philn
Copy link
Member Author

philn commented Feb 10, 2025

I tried this, but ... bwrap: execvp /usr/bin/xdg-dbus-proxy: No such file or directory.

@philn philn marked this pull request as draft February 10, 2025 20:40
Comment on lines 405 to 406
auto symLink = makeString("/usr"_s, directory, '/');
args.appendVector(Vector<CString> { "--symlink", directory.utf8(), symLink.utf8() });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is backwards, which would explain why /usr/bin/xdg-dbus-proxy is missing:

Suggested change
auto symLink = makeString("/usr"_s, directory, '/');
args.appendVector(Vector<CString> { "--symlink", directory.utf8(), symLink.utf8() });
auto linkTarget = makeString("/usr"_s, directory, '/');
args.appendVector(Vector<CString> { "--symlink", linkTarget.utf8(), directory.utf8() });

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried both ways, didn't notice an improvement either way.

Comment on lines 408 to 409
auto symLink = makeString("/usr"_s, directory);
args.appendVector(Vector<CString> { "--ro-bind-try", symLink.utf8(), symLink.utf8() });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails on non-usrmerged systems, e.g. if /bin is not a symlink then it won't be bound.

What I would do is bind normally here instead:

Suggested change
auto symLink = makeString("/usr"_s, directory);
args.appendVector(Vector<CString> { "--ro-bind-try", symLink.utf8(), symLink.utf8() });
args.appendVector(Vector<CString> { "--ro-bind", directory.utf8(), directory.utf8() });

That will take care of binding any paths not under /usr, like /bin or /lib. But we also need to bind the paths under /usr, like /usr/bin or /usr/lib. We could do that above, in the if (fileType == FileSystem::FileType::SymbolicLink) condition, but that would fail if the symlinks ever get removed (you never know, it could happen 50 years from now!), so probably best to just restore the use of --ro-bind-try that you removed for the locations under /usr?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason the current wip patch is like this is that --ro-bind* and --symlink don't seem to play well together. If I keep both I get this bwrap: Can't make symlink at /bin: destination exists and is not a symlink.

I think this needs the attention of someone actually familiar with the bwrap options.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The options do exactly what you tell them to. It's either create a symlink or mount a directory. The error message indicates exactly what is wrong: this is a usrmerged system and /bin is supposed to be a symlink to /usr/bin, so BubblewrapLauncher.cpp shouldn't be trying to --ro-bind the host /bin. But we do need to --ro-bind it on non-usrmerged systems. We need to do one of create symlink or bind host directory -- never both -- for each of these locations. That error message indicates your code is doing both. It's probably a simple mistake?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: I notice the existing sandbox intentionally skips binding /bin except in the enableDebugPermissions case. We should probably maintain that behavior and just altogether remove /bin and /sbin from this function. We could create the symlinks in the enableDebugPermissions codepath if you want, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You realize you contradict yourself then? You said "so probably best to just restore the use of --ro-bind-try that you removed for the locations under /usr?" and now "We need to do one of create symlink or bind host directory -- never both -- for each of these locations".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use --ro-bind-try in the non-usrmerge condition, when /bin is not a symlink.

@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Feb 11, 2025
@philn philn removed the merging-blocked Applied to prevent a change from being merged label Jun 29, 2025
@philn
Copy link
Member Author

philn commented Jun 29, 2025

I'm landing the initial version of this patch, which is simple and less invasive than the broken WIP I couldn't make work :(

@philn philn marked this pull request as ready for review June 29, 2025 08:49
@philn philn added the merge-queue Applied to send a pull request to merge-queue label Jun 29, 2025
https://bugs.webkit.org/show_bug.cgi?id=287368

Reviewed by Michael Catanzaro.

On UsrMerge systems where /lib64 is a symlink to /usr/lib64 and where the GStreamer registry
attempts to load the plugin-scanner from /lib64/ the path needs to be allow-listed in the sandbox.

* Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
(WebKit::bindGStreamerData):

Canonical link: https://commits.webkit.org/296779@main
@webkit-commit-queue
Copy link
Collaborator

Committed 296779@main (526ec66): https://commits.webkit.org/296779@main

Reviewed commits have been landed. Closing PR #40320 and removing active labels.

@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jun 29, 2025
@philn philn deleted the eng/287368 branch June 29, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants