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

Firejail not tearing down sandbox after closing VLC #3224

Open
Futureknows opened this issue Feb 14, 2020 · 11 comments
Open

Firejail not tearing down sandbox after closing VLC #3224

Futureknows opened this issue Feb 14, 2020 · 11 comments

Comments

@Futureknows
Copy link

Futureknows commented Feb 14, 2020

I've noticed a few apps do this when jailed. The app appears to close, but upon inspection the sandbox is still running. With VLC it prevents a new instance from launching until I manually kill the sandbox or the orphaned process.

Has anyone else noticed this behaviour?

@jonleivent
Copy link

I have seen this with zombie processes. Firejail keeps jails open if the app that was originally jailed created zombies when it was shut down. These are easy to spot with firetools fstat tool - they show up as jailed processes that use no memory.

@Futureknows
Copy link
Author

Thanks. I wonder what might help prevent it, maybe loosening the sandbox? I'll look for common parameters in the offending firejails.

@jonleivent
Copy link

I strongly doubt that changing the sandbox parameters will have any effect. If it is a zombie process, then the fault lies with the app itself, not with firejail. There might be a way to enhance firejail itself so that when it notices it has zombie children, it removes them - but that is not a behavior that can be achieved by altering sandbox parameters.

@Futureknows
Copy link
Author

Futureknows commented Feb 14, 2020 via email

@jonleivent
Copy link

That is probably because the linux init process already has the ability to deal with zombies that it directly inherits, which is what normally happens when zombies are created . But, if the zombie process is created in a firejail sandbox, then it never gets directly inherited by the linux init process. Not allowing processes to escape a sandbox is normally considered a major firejail feature, but in the case of zombies it is admittedly a nuisance.

I do think it is possible for firejail to handle zombies itself, but it would not be something achievable merely by altering the existing sandboxing parameters. It might require firejail to have some kind of daemon running that watches for the presence of zombie processes in sandboxes. But I'll leave that determination to the firejail developers.

@Futureknows
Copy link
Author

I see, thanks for the detailed explanation. I suppose the simplest workaround would be to force firejail to launch VLC in a new sandbox on each instance. Is this possible from firejail's command line?

@glitsj16
Copy link
Collaborator

I suppose the simplest workaround would be to force firejail to launch VLC in a new sandbox on each instance. Is this possible from firejail's command line?

Not directly no. You can use a simple shell script wrapper to shutdown any lingering VLC sandbox prior to starting a new one. Here's a basic run-down:

  • name the VLC sandbox for easy killing (firejail --shutdown=vlc)
    $ echo "name vlc" >> ${HOME}/.config/firejail/vlc.local

  • create the wrapper script

$ cat fj.vlc
#!/bin/sh    
## shutdown potentially lingering VLC sandbox
#+ try native shutdown first
firejail --shutdown=vlc 2> /dev/null || _err=1
#+ try fallback via killall
[ "$_err" ] && killall --quiet --ns 0 vlc
## start a new VLC sandbox
if [ -L /usr/local/bin/vlc ]; then
    #+ using the (firecfg generated) firejail symlink
    /usr/local/bin/vlc &
else
    #+ manually
    firejail /usr/bin/vlc &
fi
exit 0

Place fj.vlc (or whatever you named it) somewhere it gets picked-up first by your PATH, e.g. ${HOME}/bin or /usr/local/bin. If you use a firecfg generated ${HOME}/.local/share/applications/vlc.desktop, make sure to edit the Exec= line, now referencing the fj.vlc command.

@rusty-snake
Copy link
Collaborator

Do we want to implement any zombie handling?

@Futureknows
Copy link
Author

Futureknows commented May 8, 2020 via email

@rusty-snake
Copy link
Collaborator

Has anyone else noticed this behaviour?

When I wrote the wps profiles, I noticed such a behaviour if seccomp was used. There where no violations in the syslog and it had even happen with seccomp.drop @swap.

@rusty-snake
Copy link
Collaborator

Do we want to implement any zombie handling?

I think we want. It shouldn't be complicated.

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

4 participants