xref: /aosp_15_r20/external/crosvm/third_party/minijail/syscall_wrapper.c (revision 4b9c6d91573e8b3a96609339b46361b5476dd0f9)
1*4b9c6d91SCole Faust /* Copyright 2016 The ChromiumOS Authors
2*4b9c6d91SCole Faust  * Use of this source code is governed by a BSD-style license that can be
3*4b9c6d91SCole Faust  * found in the LICENSE file.
4*4b9c6d91SCole Faust  */
5*4b9c6d91SCole Faust 
6*4b9c6d91SCole Faust #include "syscall_wrapper.h"
7*4b9c6d91SCole Faust 
8*4b9c6d91SCole Faust #define _GNU_SOURCE
9*4b9c6d91SCole Faust #include <sys/syscall.h>
10*4b9c6d91SCole Faust #include <unistd.h>
11*4b9c6d91SCole Faust 
12*4b9c6d91SCole Faust /*
13*4b9c6d91SCole Faust  * Older glibc builds predate seccomp inclusion.  These arches are the ones
14*4b9c6d91SCole Faust  * AOSP needs and doesn't provide anything newer.  All other targets can upgrade
15*4b9c6d91SCole Faust  * their kernel headers.
16*4b9c6d91SCole Faust  */
17*4b9c6d91SCole Faust #ifndef SYS_seccomp
18*4b9c6d91SCole Faust # if defined(__x86_64__)
19*4b9c6d91SCole Faust #  define SYS_seccomp 317
20*4b9c6d91SCole Faust # elif defined(__i386__)
21*4b9c6d91SCole Faust #  define SYS_seccomp 354
22*4b9c6d91SCole Faust # elif defined(__aarch64__)
23*4b9c6d91SCole Faust #  define SYS_seccomp 277
24*4b9c6d91SCole Faust # elif defined(__arm__)
25*4b9c6d91SCole Faust #  define SYS_seccomp 383
26*4b9c6d91SCole Faust # else
27*4b9c6d91SCole Faust #  error "Update your kernel headers"
28*4b9c6d91SCole Faust # endif
29*4b9c6d91SCole Faust #endif
30*4b9c6d91SCole Faust 
sys_seccomp(unsigned int operation,unsigned int flags,void * args)31*4b9c6d91SCole Faust int sys_seccomp(unsigned int operation, unsigned int flags, void *args)
32*4b9c6d91SCole Faust {
33*4b9c6d91SCole Faust 	return syscall(SYS_seccomp, operation, flags, args);
34*4b9c6d91SCole Faust }
35