aboutsummaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* libsandbox: new ia64 ptrace portMike Frysinger2015-12-201-0/+1
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: avoid mixing stderr & output pipesMike Frysinger2015-12-201-1/+1
| | | | | | | | | | | | The various debug helpers were changed to write out to a dedicated message path, but some of the trace code still uses stderr directly. When mixing these methods, the direct prints would sometimes be lost. Convert the few users to a new raw print function so they all route through the same file. We might want to extract this a bit more out in the future so it's easier to write to them, but this should be fine for now. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: switch to PTRACE_O_TRACEEXECMike Frysinger2015-12-191-45/+23
| | | | | | | | | | Rather than try to deal with the inconsistent cross-arch behavior when it comes to tracking exec behavior, use the PTRACE_O_TRACEEXEC option. This means we only support ptrace on linux-2.6+ systems, but that's fine as we have been requiring that for a long time now. It also means the code is much simpler and stable across arches. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: do not abort when the target uses bad pointersMike Frysinger2015-09-201-0/+14
| | | | | | | | | | | If the target passes a bad pointer to the kernel, then trying to extract the data via ptrace will also throw an error. The tracing code should not abort though as there's no valid address to check, and kernel itself will return an error for us. Simply return and move on. URL: https://bugs.gentoo.org/560396 Reported-by: Jeroen Roovers <jer@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: fix process_vm_readv addresses/lengthsMike Frysinger2015-09-201-14/+14
| | | | | | | | | | | | | The current logic calculates the lengths/base addresses incorrectly leading to some kernels/mappings to reject accesses. Make sure we calculate the initial length properly, and then increment the base by that value later on. With those fixes in place, we can clean up the warning/exit paths. URL: https://bugs.gentoo.org/560396 Reported-by: Jeroen Roovers <jer@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: use memchr to speed up NUL byte searchMike Frysinger2015-09-201-3/+2
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: work around process_vm_readv EFAULTsv2.8Mike Frysinger2015-09-201-2/+15
| | | | | | | | | | | Some people are seeing this call fail, but it's not clear why. Include more debugging output so as to improve the reports, and let the code fall back to the existing ptrace logic since that seems to work. This will at least unblock people's builds. URL: https://bugs.gentoo.org/560396 Reported-by: Jeroen Roovers <jer@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: avoid leaking memory when extracting stringsMike Frysinger2015-09-151-2/+3
| | | | | | | | | If userland supports process_vm_readv, but the kernel does not (newer kernel headers & C lib than kernel), then we leak a bit of memory when we fallback to the ptrace code. Do not re-allocate the ret buffer if the code does fallback. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: clean up open file handles in parent tracing processMike Frysinger2012-06-231-1/+2
| | | | | | | | | | | | | | Currently, if a non-static app sets up a pipe (with cloexec enabled) and executes a static app, the handle to that pipe is left open in the parent process. This causes trouble when the parent is waiting for that to be closed immediately. Since none of the fds in the forked parent process matter to us, we can just go ahead and clean up all fds before we start tracing the child. URL: http://bugs.gentoo.org/364877 Reported-by: Victor Stinner <victor.stinner@haypocalc.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: handle ENOSYS w/process_vm_readvMike Frysinger2013-02-241-1/+6
| | | | | | | If we have a newer glibc built against/running on an older kernel, the func return ENOSYS at runtime. Handle that. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: use process_vm_readv if availableMike Frysinger2012-08-121-0/+26
| | | | | | | Should speed up loading of strings from remote processes as we only have to do (usually) one syscall to extract the whole string in one shot. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: add x32 ABI supportv2.6Mike Frysinger2012-07-031-4/+17
| | | | | | | | | | | We can trace x32 when the host is x86_64 or x32, but x32 cannot trace x86_64 due to limitations in the kernel interface -- all pointers get truncated to 32bits. We'll have to add external ptrace helpers in the future to make this work, but for now, we'll just let x86_64 code run unchecked :(. URL: https://bugs.gentoo.org/394179 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: migrate to get/set regs interface for everyoneMike Frysinger2012-07-031-35/+8
| | | | | | | | | | Newer ports (like x32) limit what is available via the peek/poke user interface, and instead are pushing people to use the single get/set regs interface. Since this also simplifies the code a bit (by forcing all ports to use this), and cuts down on the number of syscalls that we have to make, switch everyone over to it. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* significantly overhaul output helpersMike Frysinger2012-06-231-35/+27
| | | | | | | | | | | | | | | | | | | | There are a few major points we want to hit here: - have all output from libsandbox go through portage helpers when we are in the portage environment so that output is properly logged - convert SB_E{info,warn,error} to sb_e{info,warn,error} to match style of other functions and cut down on confusion - move all abort/output helpers to libsbutil so it can be used in all source trees and not just by libsandbox - migrate all abort points to the centralized sb_ebort helper Unfortunately, it's not terribly easy to untangle these into separate patches, but hopefully this shouldn't be too messy as much of it is mechanical: move funcs between files, and change the name of funcs that get called. URL: http://bugs.gentoo.org/278761 Reported-by: Mounir Lamouri <volkmar@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: set syscall error rather than killing on violationsMike Frysinger2012-03-061-6/+22
| | | | | | | | | | | | | | | If we kill the app, then the syscall that we flagged as a violation will complete, and our entire purpose has failed -- to prevent modifications to the protected paths. Instead, set the syscall number to an invalid one, continue the syscall, then set the syscall return value (which will become the errno) after the syscall finishes. This way the bad syscall isn't actually executed, and we let the app continue to run like normal. URL: http://bugs.gentoo.org/406543 Reported-by: Marijn Schouten <hkbst@gentoo.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: delay trace_regs #error until useMike Frysinger2011-07-081-0/+4
| | | | | | | Don't error out if we're missing trace_regs, but we don't ever actually use it. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: don't swallow SIGCHLD notificationsMike Frysinger2010-08-151-1/+0
| | | | | | | | | | | | When tracing static processes, the original implementation included code that would always swallow SIGCHLD. Much has changed since then, and it doesn't seem to be needed anymore, and it is certainly breaking a few packages. So drop it, add some tests, and if it causes a regression in the future, we can look at it then (with an actual test case). URL: http://bugs.gentoo.org/289963 Reported-by: Joeri Capens <joeri@capens.net> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: fix ptrace decode of utimensatMike Frysinger2009-10-251-1/+1
| | | | | | | | | The ptrace code skipped one too many arguments when decoding the utimensat syscall which caused random utils to fail with garbage paths. URL: http://bugs.gentoo.org/288227 Reported-by: RB <aoz.syn@gmail.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: add support for tracing SPARC systemsMike Frysinger2009-10-251-15/+23
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: use PTRACE_SETOPTIONS only when definedMike Frysinger2009-06-041-1/+1
| | | | | | | | This should fix building on really on Linux systems. URL: http://bugs.gentoo.org/255019 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reported-by: Jeremy Olexa <darkside@gentoo.org>
* libsandbox: convert trace to waitpid()Mike Frysinger2009-06-041-6/+6
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: handle utimensat with NULL pathsMike Frysinger2009-06-041-2/+3
| | | | | | | The utimensat() function can operate on file fd's directly when the path is NULL, not just relative directory fd's. So tackle that use case. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: ignore core dumpsMike Frysinger2009-06-041-2/+7
| | | | | | | If the user has core dumping enabled, then we may get a dump notice from the traced child. Since this is fine by us, let it go through. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: add pre checks to static tracingMike Frysinger2009-06-041-50/+95
| | | | | | | | | | The normal wrapped functions go through some "pre checks" where certain normal conditions are not flagged as problematic. The static tracing lacked those pre checks though. URL: http://bugs.gentoo.org/265885 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reported-by: Daniel Robbins <drobbins@funtoo.org>
* libsandbox: don't filter signals the traced pid receivesMike Frysinger2009-04-091-9/+21
| | | | | | | | | | | | If we receive a notice that the child got a signal we don't care about, make sure we tell it to continue on with the signal info so we don't go filtering all signals the child may receive. Otherwise we break test code like that in glibc which exercises the ability of a child to catch and process signals properly. URL: http://bugs.gentoo.org/265072 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reported-by: Nick Fortino <nfortino@gmail.com>
* libsandbox: add support for tracing Blackfin/PARISC systemsMike Frysinger2009-04-081-3/+10
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: decode signal details when falling over in traceMike Frysinger2009-04-061-3/+8
| | | | Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: handle trace code when vforkingMike Frysinger2009-04-051-3/+14
| | | | | | | | | | The make program likes to vfork() when running programs, so if it vforks and runs a static binary, we need to make sure we clean up state in the child so as to not make the parent angry. URL: http://bugs.gentoo.org/264478 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reported-by: Paul Mulders <info@mld.demon.nl>
* libsandbox: fix slightly broken logic with ptrace() returnMike Frysinger2009-04-051-3/+10
| | | | | | | | The code attempted to account for the PEEK requests returning -1 in the normal case via errno, but the logic was incorrect. This ended up flagging some successful ptrace() calls when the data returned was -1. Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: enable tracing for multiple personalitiesMike Frysinger2009-04-051-75/+126
| | | | | | | | | Initial support for tracing non-default personalities. For example, tracing a 32bit binary from a 64bit environment. URL: http://bugs.gentoo.org/264399 Signed-off-by: Mike Frysinger <vapier@gentoo.org> Reported-by: Patrick Lauer <patrick@gentoo.org>
* libsandbox: be nicer with unknown traced signalsMike Frysinger2009-03-311-1/+1
| | | | | | | | Ignore SIGCHLD (in case the static app made some children), and in the case of unknown signals, simply warn rather than aborting so more stuff "just works" (well, ignoring the additional warnings). Signed-off-by: Mike Frysinger <vapier@gentoo.org>
* libsandbox: initial support for tracing of static binaries via ptrace()Mike Frysinger2009-03-181-0/+386
Signed-off-by: Mike Frysinger <vapier@gentoo.org>