aboutsummaryrefslogtreecommitdiff
path: root/src/lib/sandbox
AgeCommit message (Collapse)Author
2023-09-18Merge branch 'sandbox-aarch64-riscv-fixes' into 'main'David Goulet
Fix sandbox on AArch64, RISC-V Closes #24454 See merge request tpo/core/tor!446
2023-05-31Merge branch 'maint-0.4.7'David Goulet
2023-05-31Update CI builds to Debian Bullseye, fix associated compatibility bugsMicah Elizabeth Scott
This is a change intended for 0.4.7 maintenance as well as main. The CI builds use Debian Buster which is now end of life, and I was experiencing inconsistent CI failures with accessing its security update server. I wanted to update CI to a distro that isn't EOL, and Bullseye is the current stable release of Debian. This opened up a small can of worms that this commit also deals with. In particular there's a docker engine bug that we work around by removing the docker-specific apt cleanup script if it exists, and there's a new incompatibility between tracing and sandbox support. The tracing/sandbox incompatibility itself had two parts: - The membarrier() syscall is used to deliver inter-processor synchronization events, and the external "userspace-rcu" data structure library would make assumptions that if membarrier is available at initialization it always will be. This caused segfaults in some cases when running trace + sandbox. Resolved this by allowing membarrier entirely, in the sandbox. - userspace-rcu also assumes it can block signals, and fails hard if this can't be done. We already include a similar carveout to allow this in the sandbox for fragile-hardening, so I extended that to cover tracing as well. Addresses issue #40799 Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2023-05-10sandbox: allow stack mmap with prot_noneMicah Elizabeth Scott
This fixes a failure that was showing up on i386 Debian hosts with sandboxing enabled, now that cpuworker is enabled on clients. We already had allowances for creating threads and creating stacks in the sandbox, but prot_none (probably used for a stack guard) was not allowed so thread creation failed. Signed-off-by: Micah Elizabeth Scott <beth@torproject.org>
2022-12-20Enable IP_BIND_ADDRESS_NO_PORT if supportedAlex Xu (Hello71)
Signed-off-by: David Goulet <dgoulet@torproject.org>
2022-06-15Enable IP_BIND_ADDRESS_NO_PORT if supportedAlex Xu (Hello71)
2022-06-13sandbox: Allow use with fragile hardening on AArch64 and elsewhereSimon South
Update the sandbox implementation to allow its use with fragile hardening enabled on AArch64 (ARM64) and other architectures that use Linux's generic syscall interface. Note that in this configuration the sandbox is completely unable to filter requests to open files and directories. Update the sandbox unit tests to match.
2022-06-13sandbox: Filter "fchownat" on systems using generic syscallsSimon South
On architectures that use Linux's generic syscall interface the legacy "chown" call is not available; on these systems glibc uses "fchownat" instead. Modify the sandbox implementation to match.
2022-06-13sandbox: Filter "fchmodat" on systems using generic syscallsSimon South
On architectures that use Linux's generic syscall interface the legacy "chmod" call is not available; on these systems glibc uses "fchmodat" instead. Modify the sandbox implementation to match.
2022-06-13sandbox: Filter "newfstatat" on systems using generic syscallsSimon South
On architectures that use Linux's generic syscall interface the legacy "stat" and "stat64" calls may not be available; on these systems glibc uses "newfstatat" instead. Modify the sandbox implementation to match. Note that on these architectures as on others glibc 2.33 uses "newfstatat" in a way the sandbox cannot filter, so preserve in add_noparam_filter() the code that allows the use of this syscall without restriction when glibc version 2.33 is in use.
2022-06-13sandbox: Filter "renameat", "renameat2" where "rename" unavailableSimon South
On architectures where Linux does not provide the legacy "rename" syscall it offers one or both of "renameat" and "renameat2" instead. Follow glibc's logic in selecting which syscall to filter.
2022-06-13sandbox: Assume "openat" syscall is used where "open" is unavailableSimon South
On architectures where Linux does not provide the legacy "open" syscall glibc necessarily uses "openat" instead. Omit the unnecessary glibc-version check on these systems.
2022-05-09Merge branch 'maint-0.4.6' into maint-0.4.7Alexander Færøy
2022-05-09Merge branch 'maint-0.4.7'Alexander Færøy
2022-05-09Merge branch 'maint-0.4.5' into maint-0.4.6Alexander Færøy
2022-05-09sandbox: Permit rseq syscall as wellpmu-ipf
This was found to be necessary in conjunction with glibc 2.35 on Linux. Signed-off-by: Peter Müller <peter.mueller@ipfire.org>
2022-05-04sandbox: replace SCMP_CMP_NEG with masked equality checksPierre Bourdon
For some syscalls the kernel ABI uses 32 bit signed integers. Whether these 32 bit integer values are sign extended or zero extended to the native 64 bit register sizes is undefined and dependent on the {arch, compiler, libc} being used. Instead of trying to detect which cases zero-extend and which cases sign-extend, this commit uses a masked equality check on the lower 32 bits of the value.
2022-04-30sandbox: filter {chown,chmod,rename} via their *at variant on Aarch64Pierre Bourdon
The chown/chmod/rename syscalls have never existed on AArch64, and libc implements the POSIX functions via the fchownat/fchmodat/renameat syscalls instead. Add new filter functions for fchownat/fchmodat/renameat, not made architecture specific since the syscalls exists everywhere else too. However, in order to limit seccomp filter space usage, we only insert rules for one of {chown, chown32, fchownat} depending on the architecture (resp. {chmod, fchmodat}, {rename, renameat}).
2022-04-30sandbox: fix openat filtering on AArch64Pierre Bourdon
New glibc versions not sign-extending 32 bit negative constants seems to not be a thing on AArch64. I suspect that this might not be the only architecture where the sign-extensions is happening, and the correct fix might be instead to use a proper 32 bit comparison for the first openat parameter. For now, band-aid fix this so the sandbox can work again on AArch64.
2022-03-28Merge branch 'maint-0.4.6'David Goulet
2022-03-28Merge branch 'maint-0.4.5' into maint-0.4.6David Goulet
2022-03-28Merge branch 'tor-gitlab/mr/556' into maint-0.4.5David Goulet
2022-03-27Sandbox: Permit the clone3 system callNick Mathewson
Apparently glibc-2.34 uses clone3, when previously it just used clone. Closes ticket #40590.
2021-11-05sandbox: Allow "statx" syscall on i386 for glibc 2.33Simon South
glibc versions 2.33 and newer use the modern "statx" system call in their implementations of stat() and opendir() for Linux on i386. Prevent failures in the sandbox unit tests by modifying the sandbox to allow this system call without restriction on i386 when it is available, and update the test suite to skip the "sandbox/stat_filename" test in this case as it is certain to fail.
2021-11-05sandbox: Allow "clock_gettime64" syscall where definedSimon South
On 32-bit architectures where Linux provides the "clock_gettime64" system call, including i386, glibc uses it in place of "clock_gettime". Modify the sandbox implementation to match, to prevent Tor's monotonic-time functions (in src/lib/time/compat_time.c) failing when the sandbox is active.
2021-11-05sandbox: Filter "chown32" syscall on i386Simon South
On i386 glibc uses the "chown32" system call instead of "chown". Prevent attempts to filter calls to chown() on this architecture from failing by modifying the sandbox implementation to match.
2021-10-14Merge remote-tracking branch 'tor-gitlab/mr/433' into mainAlexander Færøy
2021-09-28sandbox: Allow use with fragile hardeningSimon South
When building with --enable-fragile-hardening, add or relax Linux seccomp rules to allow AddressSanitizer to execute normally if the process terminates with the sandbox active. Further resolves issue 11477.
2021-09-09Fix compilation error when __NR_time is not defined. #40465Daniel Pinto
2021-05-07Merge branch 'maint-0.4.5' into maint-0.4.6Nick Mathewson
2021-05-07Merge branch 'maint-0.4.6'Nick Mathewson
2021-05-07Add a sandbox workaround for Glibc 2.33Nick Mathewson
This change permits the newfstatat() system call, and fixes issues 40382 (and 40381). This isn't a free change. From the commit: // Libc 2.33 uses this syscall to implement both fstat() and stat(). // // The trouble is that to implement fstat(fd, &st), it calls: // newfstatat(fs, "", &st, AT_EMPTY_PATH) // We can't detect this usage in particular, because "" is a pointer // we don't control. And we can't just look for AT_EMPTY_PATH, since // AT_EMPTY_PATH only has effect when the path string is empty. // // So our only solution seems to be allowing all fstatat calls, which // means that an attacker can stat() anything on the filesystem. That's // not a great solution, but I can't find a better one.
2021-03-12Run "make autostyle" in advance of new series.Nick Mathewson
2021-03-12Update copyrights to 2021, using "make update-copyright"Nick Mathewson
2020-12-08Fix a couple of documentation comments related to #40094Nick Mathewson
2020-11-12When handling includes, detect missing interned strings earlier.Nick Mathewson
There were three separate places where we were hitting a sandbox Bug warning before we actually exited. Fixes #40094; bugfix on 0.3.1.1-alpha when %includes were introduced.
2020-08-12Merge remote-tracking branch 'tor-gitlab/mr/62'Nick Mathewson
2020-07-29Merge branch 'maint-0.4.4'Nick Mathewson
2020-07-29Merge remote-tracking branch 'tor-gitlab/mr/68' into maint-0.4.4Nick Mathewson
2020-07-29Fix startup crash with seccomp sandbox enabled #40072Daniel Pinto
Fix crash introduced in #40020. On startup, tor calls check_private_dir on the data and key directories. This function uses open instead of opendir on the received directory. Data and key directoryes are only opened here, so the seccomp rule added should be for open instead of opendir, despite the fact that they are directories.
2020-07-21Merge branch 'maint-0.4.4'Nick Mathewson
2020-07-21Merge remote-tracking branch 'tor-gitlab/mr/68' into maint-0.4.4Nick Mathewson
2020-07-21Merge branch 'maint-0.4.4'Nick Mathewson
2020-07-21Merge remote-tracking branch 'tor-gitlab/mr/67' into maint-0.4.4Nick Mathewson
2020-07-20Fix seccomp sandbox rules for openat #27315Daniel Pinto
The need for casting negative syscall arguments depends on the glibc version. This affects the rules for the openat syscall which uses the constant AT_FDCWD that is defined as a negative number. This commit adds logic to only apply the cast when necessary, on glibc versions from 2.27 onwards.
2020-07-20Fix seccomp sandbox rules for opening directories #40020Daniel Pinto
Different versions of glibc use either open or openat for the opendir function. This commit adds logic to use the correct rule for each glibc version, namely: - Until 2.14 open is used - From 2.15 to to 2.21 openat is used - From 2.22 to 2.26 open is used - From 2.27 onwards openat is used
2020-07-20Fix seccomp sandbox rules for openat #27315Daniel Pinto
The need for casting negative syscall arguments depends on the glibc version. This affects the rules for the openat syscall which uses the constant AT_FDCWD that is defined as a negative number. This commit adds logic to only apply the cast when necessary, on glibc versions from 2.27 onwards.
2020-07-15Add support for patterns on %include #25140Daniel Pinto
Also adds generic tor_glob function to expand globs.
2020-07-14Rename blacklist and whitelist wordingDavid Goulet
Closes #40033 Signed-off-by: David Goulet <dgoulet@torproject.org>
2020-07-01Merge branch 'maint-0.4.3' into maint-0.4.4George Kadianakis