Merge bitcoin/bitcoin#23196: util: Make syscall sandbox compilable with kernel 4.4.0

ac402e749c util: Conditionalize some syscalls in syscall name table (W. J. van der Laan)
64085b37f8 util: Add __NR_copy_file_range syscall constant for sandbox (W. J. van der Laan)

Pull request description:

  Make the new syscall sandbox compilable with kernel 4.4.0.
  This defines a further syscall constant `__NR_copy_file_range` to make sure all syscalls used in the profile are available even if not defined in the kernel headers.

  Also, make a few syscalls optional in the syscall name table:

  - `__NR_pkey_alloc`
  - `__NR_pkey_free`
  - `__NR_pkey_mprotect`
  - `__NR_preadv2`
  - `__NR_pwritev2`

ACKs for top commit:
  practicalswift:
    cr ACK ac402e749c

Tree-SHA512: be6c55bf0a686bcdfad0b80b950d0d7d77a559ac234fc997b47514bdba44865a371c96dd8d34a811ba46424a84f410e23f75485b9b1e69e529b7d40e0b4b91b8
pull/826/head
W. J. van der Laan 3 years ago
commit 6334ff7364
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D

@ -58,6 +58,10 @@ bool g_syscall_sandbox_log_violation_before_terminating{false};
#define __NR_membarrier 324 #define __NR_membarrier 324
#endif #endif
#ifndef __NR_copy_file_range
#define __NR_copy_file_range 326
#endif
// This list of syscalls in LINUX_SYSCALLS is only used to map syscall numbers to syscall names in // This list of syscalls in LINUX_SYSCALLS is only used to map syscall numbers to syscall names in
// order to be able to print user friendly error messages which include the syscall name in addition // order to be able to print user friendly error messages which include the syscall name in addition
// to the syscall number. // to the syscall number.
@ -268,15 +272,23 @@ const std::map<uint32_t, std::string> LINUX_SYSCALLS{
{__NR_pipe, "pipe"}, {__NR_pipe, "pipe"},
{__NR_pipe2, "pipe2"}, {__NR_pipe2, "pipe2"},
{__NR_pivot_root, "pivot_root"}, {__NR_pivot_root, "pivot_root"},
#ifdef __NR_pkey_alloc
{__NR_pkey_alloc, "pkey_alloc"}, {__NR_pkey_alloc, "pkey_alloc"},
#endif
#ifdef __NR_pkey_free
{__NR_pkey_free, "pkey_free"}, {__NR_pkey_free, "pkey_free"},
#endif
#ifdef __NR_pkey_mprotect
{__NR_pkey_mprotect, "pkey_mprotect"}, {__NR_pkey_mprotect, "pkey_mprotect"},
#endif
{__NR_poll, "poll"}, {__NR_poll, "poll"},
{__NR_ppoll, "ppoll"}, {__NR_ppoll, "ppoll"},
{__NR_prctl, "prctl"}, {__NR_prctl, "prctl"},
{__NR_pread64, "pread64"}, {__NR_pread64, "pread64"},
{__NR_preadv, "preadv"}, {__NR_preadv, "preadv"},
#ifdef __NR_preadv2
{__NR_preadv2, "preadv2"}, {__NR_preadv2, "preadv2"},
#endif
{__NR_prlimit64, "prlimit64"}, {__NR_prlimit64, "prlimit64"},
{__NR_process_vm_readv, "process_vm_readv"}, {__NR_process_vm_readv, "process_vm_readv"},
{__NR_process_vm_writev, "process_vm_writev"}, {__NR_process_vm_writev, "process_vm_writev"},
@ -285,7 +297,9 @@ const std::map<uint32_t, std::string> LINUX_SYSCALLS{
{__NR_putpmsg, "putpmsg"}, {__NR_putpmsg, "putpmsg"},
{__NR_pwrite64, "pwrite64"}, {__NR_pwrite64, "pwrite64"},
{__NR_pwritev, "pwritev"}, {__NR_pwritev, "pwritev"},
#ifdef __NR_pwritev2
{__NR_pwritev2, "pwritev2"}, {__NR_pwritev2, "pwritev2"},
#endif
{__NR_query_module, "query_module"}, {__NR_query_module, "query_module"},
{__NR_quotactl, "quotactl"}, {__NR_quotactl, "quotactl"},
{__NR_read, "read"}, {__NR_read, "read"},

Loading…
Cancel
Save