Compositor: Allow GPU driver executable mappings on Linux

Let the Linux Compositor sandbox permit writable executable mappings
used lazily by GPU drivers after WebGL context creation. Keep this
allowance scoped to the Compositor process so WebContent retains the
existing memory mapping restrictions.
This commit is contained in:
Andreas Kling 2026-06-19 17:01:21 +02:00 committed by Alexander Kalenik
parent 523cdab7d9
commit b759954486
3 changed files with 30 additions and 0 deletions

View file

@ -1061,6 +1061,32 @@ void SeccompPolicy::allow_executable_memory_mappings()
append(SECCOMP_LOAD_SYSCALL_NR);
}
void SeccompPolicy::allow_writable_executable_memory_mappings()
{
append(BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_mmap, 0, 5));
append(SECCOMP_LOAD_ARGUMENT(2));
append(BPF_STMT(BPF_ALU | BPF_AND | BPF_K, PROT_WRITE | PROT_EXEC));
append(BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, PROT_WRITE | PROT_EXEC, 0, 1));
append(SECCOMP_ALLOW);
append(SECCOMP_LOAD_SYSCALL_NR);
#ifdef __NR_mmap2
append(BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_mmap2, 0, 5));
append(SECCOMP_LOAD_ARGUMENT(2));
append(BPF_STMT(BPF_ALU | BPF_AND | BPF_K, PROT_WRITE | PROT_EXEC));
append(BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, PROT_WRITE | PROT_EXEC, 0, 1));
append(SECCOMP_ALLOW);
append(SECCOMP_LOAD_SYSCALL_NR);
#endif
append(BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, __NR_mprotect, 0, 5));
append(SECCOMP_LOAD_ARGUMENT(2));
append(BPF_STMT(BPF_ALU | BPF_AND | BPF_K, PROT_WRITE | PROT_EXEC));
append(BPF_JUMP(BPF_JMP | BPF_JEQ | BPF_K, PROT_WRITE | PROT_EXEC, 0, 1));
append(SECCOMP_ALLOW);
append(SECCOMP_LOAD_SYSCALL_NR);
}
void SeccompPolicy::allow_threads()
{
#ifdef __NR_clone

View file

@ -27,6 +27,7 @@ public:
void allow_network();
void allow_memory_without_executable_mappings();
void allow_executable_memory_mappings();
void allow_writable_executable_memory_mappings();
void allow_threads();
void allow_signals();
void allow_clocks();

View file

@ -70,6 +70,9 @@ ErrorOr<void> apply_sandbox()
policy.allow_gpu_device_operations();
policy.allow_common_runtime();
policy.allow_executable_memory_mappings();
// Some GPU drivers allocate writable executable code heaps lazily after
// context creation, including while handling WebGL commands.
policy.allow_writable_executable_memory_mappings();
TRY(policy.install());
return {};