You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think I found the right syscalls for this issue: ptrace,clone3 (and
optionally) process_vm_readv.
I had journalctl -f | grep "kernel" running, looking for syscalls lutris
was using I need to whitelist just ptrace and clone3, journalctl did list
for process_vm_ready when a game was running, but it didn't crash the game.
#ifdefSYS_clone3// cannot inspect clone3 argument because// seccomp does not dereference pointersBPF_JUMP(BPF_JMP+BPF_JEQ+BPF_K, SYS_clone3, 0, 1),
RETURN_ERRNO(ENOSYS), // hint to use clone instead#endif
#include<linux/sched.h>/* Definition of struct clone_args */#include<sched.h>/* Definition of CLONE_* constants */#include<sys/syscall.h>/* Definition of SYS_* constants */#include<stdio.h>#include<unistd.h>intmain()
{
structclone_argsargs= { .flags=CLONE_NEWUSER };
pid_tpid=syscall(SYS_clone3, &args, sizeof(structclone_args));
if (pid<0) {
perror("clone3");
return1;
}
if (pid!=0) {
printf("PID: %d\n", pid);
}
return0;
}
$ gcc -Wall -Wextra main.c -o main
$ ./mainPID: 1234
$ firejail --quiet --noprofile --seccomp.drop=clone3 ./mainclone3: Operation not permitted
$ firejail --quiet --noprofile --seccomp.drop=clone3 --restrict-namespaces ./mainclone3: Operation not permitted
$ firejail --quiet --noprofile --restrict-namespaces ./mainclone3: Function not implemented
Proposal
It seems understandable that a given program would treat ENOSYS as clone3 not
existing and then fall back to normal clone and that it would treat EPERM as
clone3 simply failing for whatever reason and considering that an unrecoverable
error.
So I think it would make sense to do the following:
Allow clone3 where needed
Make seccomp always return ENOSYS for clone3
Make seccomp always return ENOSYS for other syscalls in similar situations,
if any (that is, when it is incompatible with certain options + there is a
fallback syscall available)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Background
@nutta-git on Oct 5:
@nutta-git on Oct 24:
@rusty-snake on Oct 25:
To clarify the issue, clone3(2) has the following signature:
And the namespaces are specified in
*cl_args
, which means thatrestrict-namespaces
cannot restrict them because seccomp cannot dereferencepointers.
Relevant firejail code for
restrict-namespaces
:Testing
From my testing of how firejail handles clone3:
seccomp.drop clone3
->EPERM
seccomp.drop clone3
+restrict-namespaces
->EPERM
restrict-namespaces
->ENOSYS
Test code
Proposal
It seems understandable that a given program would treat
ENOSYS
as clone3 notexisting and then fall back to normal clone and that it would treat
EPERM
asclone3 simply failing for whatever reason and considering that an unrecoverable
error.
So I think it would make sense to do the following:
ENOSYS
for clone3ENOSYS
for other syscalls in similar situations,if any (that is, when it is incompatible with certain options + there is a
fallback syscall available)
Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions