Page MenuHomePhabricator

Firejail fails due to blacklist of /run
Closed, ResolvedPublic

Description

Now that /run is blacklisted by default, firejail fails to start up in my local test install:

> print MediaWiki\Shell\Shell::command('echo','hello')->execute()->getStderr();
Error disable file: fs.c:135 disable_file: No such file or directory
Error: proc 8964 cannot sync with peer: unexpected EOF
Peer 8965 unexpectedly exited with status 1

strace shows that firejail is using /run for its own purposes, specifically as a place to store the source of bind mounts:

[pid  9246] mount("/run/firejail/firejail.ro.dir", "/run", 0x557700818051, MS_BIND, 0x557700810729) = 0
[pid  9246] mount("/run/firejail/firejail.ro.file", "/etc/shadow", 0x557700818051, MS_BIND, 0x557700810729) = -1 ENOENT (No such file or directory)

The only mystery is how/why it works in production. I'm using firejail 0.9.52 and production is using 0.9.44, but the code looks pretty similar and strace shows them doing the same mounts. It's just that the mount somehow works in production:

[pid 31227] mount("/run/firejail/firejail.ro.dir", "/run", 0x564bc10bce80, MS_BIND, 0x564bc10b598c) = 0
[pid 31227] mount("/run/firejail/firejail.ro.file", "/etc/shadow", 0x564bc10bce80, MS_BIND, 0x564bc10b598c) = 0

Perhaps it is a kernel change. I'm using 5.4.0 (specifically linux-generic 5.4.0.45.49 from Ubuntu 20.04) whereas production is using 4.9.0.

I normally run MediaWiki inside systemd-nspawn, but I ruled this out as a cause by testing it on the host, with firejail 0.9.62:

$ firejail --profile=includes/shell/firejail.profile echo hello
Reading profile includes/shell/firejail.profile
Parent pid 103898, child pid 103899
Error disable file: fs.c:141 disable_file: No such file or directory
Error: proc 103898 cannot sync with peer: unexpected EOF
Peer 103899 unexpectedly exited with status 1

Event Timeline

I figured out a workaround, patch will be up shortly.

Change 626047 had a related patch set uploaded (by Tim Starling; owner: Tim Starling):
[mediawiki/core@master] shell: Don't blacklist /run/firejail

https://gerrit.wikimedia.org/r/626047

Change 626047 merged by jenkins-bot:
[mediawiki/core@master] shell: Don't blacklist /run/firejail

https://gerrit.wikimedia.org/r/626047

Change 629509 had a related patch set uploaded (by Legoktm; owner: Tim Starling):
[mediawiki/core@REL1_35] shell: Don't blacklist /run/firejail

https://gerrit.wikimedia.org/r/629509

Change 629509 merged by jenkins-bot:
[mediawiki/core@REL1_35] shell: Don't blacklist /run/firejail

https://gerrit.wikimedia.org/r/629509

Legoktm assigned this task to tstarling.