summaryrefslogtreecommitdiff
path: root/src/common/sandbox.c
AgeCommit message (Collapse)Author
2015-12-16Merge branch 'maint-0.2.7'Nick Mathewson
2015-12-16... and fix another backtrace_symbols_fd call in sandbox.cNick Mathewson
2015-12-15Merge branch 'maint-0.2.7'Nick Mathewson
2015-12-15Fix backtrace compilation on FreeBSDcypherpunks
On FreeBSD backtrace(3) uses size_t instead of int (as glibc does). This causes integer precision loss errors when we used int to store its results. The issue is fixed by using size_t to store the results of backtrace(3). The manual page of glibc does not mention that backtrace(3) returns negative values. Therefore, no unsigned integer wrapping occurs when its result is stored in an unsigned data type.
2015-12-08Add support for getrandom() and getentropy() when availableYawning Angel
Implements feature #13696.
2015-10-15Fix compilation of sandbox.[ch] under musl-libcNick Mathewson
Patch from jamestk; fix on 0.2.5.1-alpha. Fixes 17347.
2015-10-15Fix compilation of sandbox.[ch] under musl-libcNick Mathewson
Patch from jamestk; fix on 0.2.5.1-alpha. Fixes 17347.
2015-06-15Fix another seccomp2 issueNick Mathewson
Allow pipe() and pipe2() syscalls; we need these when eventfd2() support is missing. Fixes bug 16363; bugfix on 0.2.6.3-alpha. Patch from "teor".
2015-06-02Fix sandboxing to work when running as a relayPeter Palfrader
This includes correctly allowing renaming secret_id_key and allowing the eventfd2 and futex syscalls. Fixes bug 16244; bugfix on 0.2.6.1-alpha.
2015-05-28Fix sandbox use with systemd. bug 16212.Nick Mathewson
2015-03-04Merge remote-tracking branch 'public/bug15088_025' into maint-0.2.6Nick Mathewson
2015-03-04Add wait4 to the seccomp2 sandbox allowable syscall listNick Mathewson
fixes bug 15088. patch from sanic.
2015-02-23Let AF_UNIX connections through the sandboxNick Mathewson
Fixes bug 15003; bugfix on 0.2.6.3-alpha.
2015-02-11Fix crash on glibc __libc_message()Nick Mathewson
__libc_message() tries to open /dev/tty with O_RDWR, but the sandbox catches that and calls it a crash. Instead, I'm making the sandbox setenv LIBC_FATAL_STDERR_, so that glibc uses stderr instead. Fix for 14759, bugfix on 0.2.5.1-alpha
2015-01-02Bump copyright dates to 2015, in case someday this matters.Nick Mathewson
2014-12-30Fix a memory leak in tor-resolveNick Mathewson
Resolves bug 14050
2014-12-23tweak whitespace; log bad socket family if bug occursNick Mathewson
2014-12-23Add the transparent proxy getsockopt to the sandboxFrancisco Blas Izquierdo Riera (klondike)
When receiving a trasnsparently proxied request with tor using iptables tor dies because the appropriate getsockopt calls aren't enabled on the sandbox. This patch fixes this by adding the two getsockopt calls used when doing transparent proxying with tor to the sandbox for the getsockopt policy. This patch is released under the same license as the original file as long as the author is credited. Signed-off-by: Francisco Blas Izquierdo Riera (klondike) <klondike@gentoo.org>
2014-10-28Add another year to our copyright dates.Nick Mathewson
Because in 95 years, we or our successors will surely care about enforcing the BSD license terms on this code. Right?
2014-09-29Merge remote-tracking branch 'origin/maint-0.2.5'Nick Mathewson
2014-09-29Don't use the getaddrinfo sandbox cache from tor-resolveNick Mathewson
Fixes bug 13295; bugfix on 0.2.5.3-alpha. The alternative here is to call crypto_global_init() from tor-resolve, but let's avoid linking openssl into tor-resolve for as long as we can.
2014-09-02Another clang analyzer complaint wrt HT_GENERATENick Mathewson
We're calling mallocfn() and reallocfn() in the HT_GENERATE macro with the result of a product. But that makes any sane analyzer worry about overflow. This patch keeps HT_GENERATE having its old semantics, since we aren't the only project using ht.h. Instead, define a HT_GENERATE2 that takes a reallocarrayfn.
2014-08-25Fix another memory leak case in sandbox.c:prot_strings()Nick Mathewson
This is related to the rest of 523587a5cf62119baa01822e2e783925726a790b
2014-08-24Remove the non-implemented versions of the sandbox _array() functionsNick Mathewson
2014-08-24Whitespace fixesNick Mathewson
2014-08-21fix memory leak on failure in sandbox.c:prot_strings()Nick Mathewson
[CID 1205014]
2014-08-21Store sandbox params as char *, since that's what they are.Nick Mathewson
This allows coverity to infer that we aren't leaking them. [Fixes a lot of CIDs]
2014-06-11Fix a 32-big conversion warning in 11970 fixNick Mathewson
2014-06-11Merge remote-tracking branch 'public/bug11970'Nick Mathewson
2014-06-11Yield a real error in the bug case of sandbox_getaddrinfo()Nick Mathewson
2014-06-08Spell getrlimit correctly.Nick Mathewson
Fixes bug in b0c1c700114aa8d4dfc180d85870c5bbe15fcacb; bug 12229. Bugfix not in any released Tor. Patch from "alphawolf".
2014-05-29sandbox: allow enough setsockopt to make ConstrainedSockets workNick Mathewson
fixes bug 12139; bugfix on 0.2.5.1-alpha
2014-05-27sandbox: permit listen(2)Nick Mathewson
Fix for 12115; bugfix on 0.2.5.1-alpha
2014-05-27Log the errno value if seccomp_load() fails.Nick Mathewson
(This is how I found out I was trying to test with a kernel too old for seccomp. I think.)
2014-05-27Make sandbox.c compile on armNick Mathewson
This is a minimal set of changes for compilation; I need a more recent kernel to test this stuff.
2014-05-22sandbox: revamp sandbox_getaddrinfo cacheingNick Mathewson
The old cache had problems: * It needed to be manually preloaded. (It didn't remember any address you didn't tell it to remember) * It was AF_INET only. * It looked at its cache even if the sandbox wasn't turned on. * It couldn't remember errors. * It had some memory management problems. (You can't use memcpy to copy an addrinfo safely; it has pointers in.) This patch fixes those issues, and moves to a hash table. Fixes bug 11970; bugfix on 0.2.5.1-alpha.
2014-05-20sandbox: permit gettid, sched_getaffinityNick Mathewson
These are needed under some circumstances if we are running with expensive-hardening and sandbox at the same time. fixes 11477, bugfix on 0.2.5.4-alpha (where we introduced expensive-hardening)
2014-05-20sandbox: Disallow options which would make us call exec()Nick Mathewson
None of the things we might exec() can possibly run under the sanbox, so rather than crash later, we have to refuse to accept the configuration nice and early. The longer-term solution is to have an exec() helper, but wow is that risky. fixes 12043; bugfix on 0.2.5.1-alpha
2014-04-25resolve a typo: sanboxing->sandboxing.Nick Mathewson
2014-04-18Improved message when running sandbox on Linux without libseccompNick Mathewson
Previously we said "Sandbox is not implemented on this platform" on Linux boxes without libseccomp. Now we say that you need to build Tor built with libseccomp. Fixes bug 11543; bugfix on 0.2.5.1-alpha.
2014-04-17Remove spurious libevent include in sandbox.cNick Mathewson
2014-04-16Log the name of the failing syscall on failureNick Mathewson
2014-04-16Sandbox: permit O_NONBLOCK and O_NOCTTY for files we refuseNick Mathewson
OpenSSL needs this, or RAND_poll() will kill the process. Also, refuse with EACCESS, not errno==-1 (!).
2014-04-16Don't allow change to ConnLimit while sandbox is activeNick Mathewson
2014-04-16Use SCMP_CMP_MASKED_EQ to allow flags, not force themNick Mathewson
Older versions of Libevent are happy to open SOCK_DGRAM sockets non-cloexec and non-nonblocking, and then set those flags afterwards. It's nice to be able to allow a flag to be on or off in the sandbox without having to enumerate all its values. Also, permit PF_INET6 sockets. (D'oh!)
2014-04-16Get Libevent's PRNG functioning under the linux sandboxNick Mathewson
Libevent uses an arc4random implementation (I know, I know) to generate DNS transaction IDs and capitalization. But it liked to initialize it either with opening /dev/urandom (which won't work under the sandbox if it doesn't use the right pointer), or with sysctl({CTL_KERN,KERN_RANDOM,RANDOM_UUIC}). To make _that_ work, we were permitting sysctl unconditionally. That's not such a great idea. Instead, we try to initialize the libevent PRNG _before_ installing the sandbox, and make sysctl always fail with EPERM under the sandbox.
2014-04-16Introduce arg-counting macros to wrap seccomp_rule_add()Nick Mathewson
The compiler doesn't warn about this code: rc = seccomp_rule_add(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat), 1, SCMP_CMP(0, SCMP_CMP_EQ, AT_FDCWD), SCMP_CMP(1, SCMP_CMP_EQ, param->value), SCMP_CMP(2, SCMP_CMP_EQ, O_RDONLY|...)); but note that the arg_cnt argument above is only 1. This means that only the first filter (argument 0 == AT_FDCWD) is actually checked! This patch also fixes the above error in the openat() filter. Earlier I fixed corresponding errors in filters for rename() and mprotect().
2014-04-16Fix sandbox protection for renameNick Mathewson
(We were only checking the first parameter of each rename call.)
2014-04-16Upgrade warning about missing interned string for sandboxNick Mathewson
2014-04-16Have sandbox string protection include multi-valued parmeters.Nick Mathewson