mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #6450] Crash when mountinfo contains line over 4096 bytes #3278
Labels
No labels
LTS merge
LTS merge
bug
bug
converted-to-discussion
doc-todo
documentation
duplicate
enhancement
file-transfer
firecfg
firejail-in-firejail
firetools
graphics
help wanted
information_old
installation
invalid
modif
moved
needinfo
networking
notabug
notourbug
old-version
overlayfs
packaging
profile-request
pull-request
question
question_old
removal
runtime-permissions
sandbox-ipc
security
stale
wiki
wiki
wontfix
wordpress
workaround
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/firejail#3278
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @warptozero on GitHub (Aug 25, 2024).
Original GitHub issue: https://github.com/netblue30/firejail/issues/6450
Description
Firejail crashes with
Error: cannot read /proc/self/mountinfowhen an overlayfs is mounted with a lot of lowerdirs.Steps to Reproduce
firejail --noprofile bashoverlayfs_test.fish
Note that this uses the newer
lowerdir+syntax to add lowerdirs one by one, which is only supported since kernel version 6.7 or 6.8.Additional context
It seems to be related to a 4096 byte limit somewhere and not the amount of lowerdirs.
mountsyntax of appending lowerdirs withlowerdir=d1:d2:d...stopped working for lines longer then 256 bytes. This is why the newerlowerdir+option is needed.LIBMOUNT_FORCE_MOUNT2=alwaysand is limited to a longer option length of max 4096 bytes.lowerdir+syntax allows to create a much longer entry in/proc/self/mountinfothen was previously possible.See https://github.com/util-linux/util-linux/issues/2287 and https://github.com/util-linux/util-linux/issues/1992#issuecomment-1486475153.
Environment
Compile time support
Checklist
/usr/bin/vlc) "fixes" it).Log
Output of
env LC_ALL=C firejail --noprofile bashOutput of
env LC_ALL=C firejail --debug --noprofile bash@warptozero commented on GitHub (Aug 26, 2024):
Note that this is not about overlayfs support in firejail, but failing to start when an existing overlayfs is mounted. This might also happen with other mounts that create a very long line in mountinfo.
Unfortunately
x-*options don't show up in mountinfo so I haven't found a way to test this yet.@rusty-snake commented on GitHub (Aug 26, 2024):
@warptozero commented on GitHub (Aug 26, 2024):
Thanks, I could reproduce this with a long path length.
Looking at the code a quick fix is to simply increase
MAX_BUFin mountinfo.c.xargs --show-limitsreports the actually used max command buffer as 131072 (128 * 1024). So to be able to handle a mount command near this size I had to setMAX_BUFto 129 * 1024.Starting a firejail with a long mountinfo line of 131112 bytes takes around 241ms instead of the normal 6.4ms without it mounted. So this probably needs a better solution in the parser.
@tsankuanglee commented on GitHub (Apr 16, 2025):
I'm seeing the same error as well.
I have a few Docker containers running. Docker's overlays are typically very long (with its many layers and each using hashes in the path) for bind mounts, and can easily go over the current limit.
If I bring down the containers, those long mountinfo lines are gone, and firejail works.
Some ideas:
If increasing
MAX_BUF's performance impact is a one-time 234.6 ms, can we consider this fix?Or is it possible to ignore any lines with
dockerorpodmanin them? The keywords happen early in the line. Here's one example (this is an image built upon tensorflow notebook container):mountinfo? That way, users can custom trim it.