mirror of
https://github.com/netblue30/firejail.git
synced 2026-05-15 14:16:14 -06:00
[GH-ISSUE #4633] Higher argument limits? (Error: too many arguments) #2732
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#2732
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 @Artefact2 on GitHub (Oct 23, 2021).
Original GitHub issue: https://github.com/netblue30/firejail/issues/4633
It seems that firejail has much lower limits for the number of arguments it supports (or the total size of argv), compared to other standard programs. This makes using firejail with long file lists a painful process, as standard tools like
find -execorxargswon't work out of the box.Here's a simple way to reproduce:
For additionnal reference:
Relates to:
@kmk3 commented on GitHub (Oct 23, 2021):
@Artefact2 commented on Oct 23:
Current limit:
That's been the case from the beginning it seems:
Main usage:
@netblue30 Is there any specific reason for this limit?
It seems that something like the following could be done instead:
Anyway, I'm currently already working on 2 other things, so if anyone wants to
take it, feel free to do so.
@rusty-snake commented on GitHub (Oct 23, 2021):
Even if you would use malloc:
efbf74e124/src/firejail/main.c (L1005-L1008)@kmk3 commented on GitHub (Oct 23, 2021):
@rusty-snake commented on Oct 23:
MAX_ARGScan be replaced withARG_MAX.Relates to #4583.
@kmk3 commented on GitHub (Oct 23, 2021):
On second thought, I don't know why a limit on argc would be needed (there is
none defined by POSIX at least); I think it would only matter on argv, because
of e.g.: memory usage.
@topimiettinen commented on GitHub (Oct 23, 2021):
It's a security feature: argv (and environment) could be used to fill the stack area so that stack smashing would be easier. Similar check exists for environment variables too. Raising the limit to ARG_MAX (524288) wouldn't be a good idea, but 128 could be raised a bit higher.
In general, portability to POSIX isn't very interesting for Firejail, since it depends on Linux-only features like mount namespaces, seccomp and capabilities. Without them Firejail would be useless. I don't think BSDs have anything comparable.
@kmk3 commented on GitHub (Oct 23, 2021):
topimiettinen commented on Oct 23:
I see, that makes sense. But still, wouldn't it make more sense to check only
for argv (regardless of the specific upper bound number that would be chosen)
rather than argc?
Off-topic discussion
Never thought I'd get an appropriate occasion to do it, but:
I'd just like to interject for a moment. What you're referring to as Linux, is
in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux.
Linux is not an operating system unto itself, but rather another free component
of a fully functioning GNU system made useful by the GNU corelibs, shell
utilities and vital system components comprising a full OS as defined by POSIX.
The examples listed are kernel-level features, but limits.h is system-defined
and thus can be overridden by e.g.: other OS components. #4583 is a great
example of that, as glibc overrides what Linux defines in limits.h, but musl
doesn't. So keeping POSIX in mind in this case could help with libc
portability (rather than kernel portability). There is also #4293, which was
intended to make the configure script portable between different
POSIX-compliant shells (e.g.: bash and dash).
Anyway, POSIX was just an example in my previous comment; it's the only thing
that I know that explicitly defines such limits. What I meant is that
Linux/glibc/musl define related limits using the macro names specified by
POSIX, but neither Linux/glibc/musl nor POSIX define any limits for argc AFAIK.
@topimiettinen commented on GitHub (Oct 23, 2021):
The important thing is actually the size, or the sum of all arguments.
Off-topic discussion
I think calling a system GNU is exaggerating, there are many other non-GNU components in the system too and the distros also put a lot of effort to integration. The most important piece these days is the browser, which isn't GNU and a lot of old UNIX-like GNU or POSIX stuff with text UIs isn't very cool anymore. It isn't fair calling the phone systems 'Android' either, but calling it 'Linux/Bionic' would be silly.
Good points with portability to musl. Though does any distro use it for real?
@reinerh commented on GitHub (Oct 23, 2021):
Alpine comes to mind. And many embedded distributions like OpenWrt.
@kmk3 commented on GitHub (Oct 24, 2021):
topimiettinen commented on Oct 23:
So something like this?
Off-topic discussion
The copypasta was posted mostly in jest to point out that there is more to the
OS than the kernel (and to POSIX than the kernel-related functions and the C
extensions). I think that the main point is to remind people that the shell,
coreutils, make and the compiler are essential parts of the OS (as in, you
couldn't even build the Linux kernel without them), which are also all
specified by POSIX. You can have a "complete" (i.e.: self-bootstrapping) Linux
software distribution (GNU or not) without a web browser, but probably not
without the aforementioned tools. That is, everything else could be considered
an application built on top of the OS, not the OS itself.
As for Android, it takes an absurd amount of disk space (in the realm of
multiple GiB with all the tooling last I checked) just to build a normal
application, let alone the entire system (it requires dozens of GiB AFAIK).
And I'm not sure that all of the necessary tools are even available under FLOSS
licenses, let alone packaged in their entirety on e.g.: Debian. And that is
just to effectively cross-compile it from another system; I doubt it's even
feasible to completely do it on a conventional Android device itself, let alone
to be able to actually boot the result. AFAICT the unix-y portions of it are
mostly buried under layers and layers of frameworks and abstractions.
System-wise it is as far from a conventional Linux or BSD software distribution
as it gets and should indeed probably just be considered its own (incomplete)
thing.
Now, something similar could be said about the complexity of gcc/clang (either
of which is currently required to build the kernel AFAIK), though there is work
being done to enable smaller (and C-based) alternatives, but even disregarding
that, I would consider gcc/clang to be at least more familiar beasts than the
Java runtimes and what not.
Off the top of my head, from the distros that either do or did package firejail
(from README.md):
Alpine is known for being small and so is often used on Docker containers.
postmarketOS is based on Alpine and is intended for phones (and so is much
closer to a conventional distro than Android).
Void is the one that officially supports the most BSD-y userland of the list
that I know of. Examples: runit, seatd, sndio.
Also, the main KISS Linux build is musl-based, but I'm not aware of any
firejail build recipe.
@topimiettinen commented on GitHub (Oct 24, 2021):
Yes. The calculation could also consider environment variables. Maybe simply (knowing the layout of argv/env/auxv in stack) just check that stack isn't used too much.
Off-topic discussion
We're approaching the point where shell and other utils aren't used very much for lauching apps in for the typical installation: kernel -> systemd -> sddm -> 'systemd --user' -> app (browser etc.). Also the development is done more and more in the cloud, like this GitHub. With vscode.dev it's probably possible to do all development, including editing, remotely.
With Meson build system, a shell isn't necessary when compiling and it's much saner (and faster) than Make. Perhaps Firejail should switch to Meson at some point.
I've actually long wanted a system, which would have two operating modes:
Requiring a reboot to switch modes or even switch Secure Boot on/off from UEFI BIOS could be OK. Maybe the production image could be even produced by a CI job far away.
It's also very interesting from security point of view. Android uses a combination of UIDs and SELinux categories (or sensitivies) for each app. This makes a lot of sense, there's typically no need for app A to look at files for app B. Firejail helps a lot here by using mount namespaces and by rearranging the apps' views to the contents of $HOME, but it would be better if the OS also did something Android-like. There could be also snaps/appimages/flatpaks, but produced locally from distro packages with some distro-supported automatics.
Thanks. On Debian, musl is available, but it can't be used for pretty much anything, so I thought it's not ready for production.
@Antiz96 commented on GitHub (Feb 6, 2025):
Do I understand correctly that we currently have no way to override / get round this hardcoded limit (apart from patching it at build time)?
I'm also hit by this when building Arch Linux packages containing a huge number of split packages (> 128) on our build server. Indeed,
rsyncfails with e.g.Error: too many arguments: argc (307) >= MAX_ARGS (128)when trying to download files once the build is over (https://gitlab.archlinux.org/archlinux/devtools/-/issues/267).@Antiz96 commented on GitHub (Feb 6, 2025):
Seeing that the current limit seems to cause some issues for people (see also https://github.com/netblue30/firejail/issues/3851) it'd indeed be great to raise it higher (if that's still reasonable regarding the security feature it covers) 😃
@hlein commented on GitHub (May 18, 2025):
Just ran into this again, a number of packages can't compile on Gentoo when various
*sumtools are firejailed, they'll die like:Same for various others.
_multilib_header_cksumis defined ineclass/multilib-build.eclassand it does afind ... -exec chksum {} +- behaves similar toxargs.chksumis wrapped byfirecfgby default.So this points out anything that uses
find ... -exec ... {} +orxargsand runs a firejail'ed process is prone to failure. When bulding a couple hundred packages, these all failed this way:The largest of which being:
Of course this is just one set of examples. Even if we lifted
MAX_ARGSto something higher, any time it doesn't match what other tools on the system likefindandxargswould see/determine, it's unsafe tofirejailbasically anything that is used in a pipeline like that.It looks like
xargslimits by max argument-string length of 128KiB.That doesn't mean 128KiB max args, since each one is a string so needs a null terminator. So 64KiB
MAX_ARGSwould be required to not cause unexpected failures withxargs.And in a quick test
find ... -exec {} +with gobs of input files, it started splitting at about 113581 bytes worth of filenames w/trailing-nulls. You couldn't get more than 64KiB unique filenames, you'd need multi-character filenames and/or subdirs. So if we raisedMAX_ARGSto 64KiB for the sake ofxargs, it would be enough forfind ... -exec {} +as well.So then I wonder, should
MAX_ARGSsimply be raised, or should this be something tunable in profiles, so any program that can't reasonably be used in an invocation like this, can impose a lower limit for itself? I could see enforcing a low limit for any X apps, for example, maybe curses apps, etc.@kmk3 commented on GitHub (May 19, 2025):
Thanks for the details.
I also have had issues with some basic tools being inadvertently firejailed
while building packages, for example:
I think it would make sense to disable all
*sumtools in firecfg.(And maybe also all other POSIX utils/coreutils that need to access files)
This would probably defeat the point of having the limit, as it seems to be
intended to reduce potential damage from just running firejail itself with a
custom profile / arguments.
@kmk3 commented on GitHub (May 20, 2025):
Besides Gentoo/hashers, there was a build issue affecting Arch/archivers:
It looks like the potential issues with package building and checksum tools was
discussed in the PR that added them:
@hlein commented on GitHub (May 22, 2025):
Oh, interesting, you mean as self-protection for firejail itself? Or do you just mean that if not otherwise stated, the limit should default to low? That sounds like a better approach, could have a low default and a
max-argsprofile setting that can raise it?I saw https://github.com/netblue30/firejail/pull/6755/commits/e4365a8bc725ea3b73932c5a49e3638a8f90e029 and I think that's the right call for now regardless; it is too bad that this means we can't have any firejail protections in these cases, but it'll reduce surprise failures which will be good overall.
@kmk3 commented on GitHub (May 23, 2025):
The former; see the comments from 2021 in this thread.
See also:
Maybe it could be configurable in firejail.config.
Though currently it is used for a compile-time array-size:
Which is used for the restricted shell feature:
@kmk3 commented on GitHub (Oct 22, 2025):
With the following PR, the limit is configurable in firejail.config:
If anybody is interested in this, please build/test the PR and report any
issues in the PR.
Example:
@Antiz96 commented on GitHub (Oct 22, 2025):
I assume you meant https://github.com/netblue30/firejail/pull/6878?
I will build and test it later this week (this evening if I'm able to) and report back. Thanks :)
@kmk3 commented on GitHub (Oct 22, 2025):
Good catch; fixed.
Sounds good, thanks.