Newer versions of glibc apparently enforce argv to contain at least one
argument, regardless of what what passed to execlp(). This behavioral
change resulted in test-0cf405b0 performing an endless loop.
This commit addresses this problem by setting an environment variable to
indicate, whether the execlp() call has already been performed.
Disable the check to see if the executable being executed
is the same ELF machine as the host system. This is to
support the case where ELF objects are run under a custom
QEMU emulator or LD_LIBRARY_PATH.
Bug: https://github.com/proot-me/proot/issues/343
This eliminates unexpected SIGTRAPs in newly forked processes,
allowing removal of ugly (and broken) workarounds in
the handle_tracee_event_kernel_4_8 event handler.
"Useless" seccomp traps still may happen if a tracee has
explicity disabled seccomp (like during ptrace emulation),
but handling these is much easier.
This fixes following tests: test-d92b57ca, test-2db65cd2.
Additionaly test-230f47ch is not skipped now, but it fails
under seccomp due to missing seccomp handling in handle_ptracee_event.
proot currently does not even try to handle seccomp traps when running
ptrace emulation. Returning an error is better than misleading the ptracer
into expecting seccomp events.
This (sort of) fixes test-230f47ch.
If we decided that we need to do sysexit, the tracee needs to be be restarted
using PTRACE_SYSCALL rather than PTRACE_CONT.
In particular, if we got the sysenter through PTRACE rather than SECCOMP,
we need to make sure that the restart from the useless SECCOMP honers this.
Also add a minor optimization to make sure we set the optimum restart method
(and sysexit_pending) when we got the syscall through PTRACE before SECCOMP.
This is the Y2038 function for utimensat and AFAICT the only one we care about.
There are a few other ones that are referred to by the kompac extension
but a kernel with the Y2038 syscalls are not going to be old enough to need those...
The use of a real syscall number causes problem with seccomp enabled
since we might not get a second chance in sysexit to set the return value from the syscall.
This, along with the use of PROOT_SET_SYSCALL,
was introduced in e675d09b2c.
The comment and the commit message claims that the syscall number must be a valid one.
However, based on local testing (on both an aarch64 kernel and an arm kernel)
it seems that while the 32bit kernel is unhappy about a invalid syscall number
it treats a `-1` from the ptracer as ignoring the syscall just as what we need.
OTOH, the 64bit kernel doesn't seem to care at all and will happily treate the `-2`
as ignoring syscall as well. I have not found any document
about the special treatment of `syscall(-1)` but this is what strace uses.
The original choice of `-2` seems to be because `-1` is used to indicate uninitialized value.
It doesn't seem that this is needed anymore after 63c7f7f668
and we should be able to use the better supported `-1` for this purpose.
If we aren't interested in the exit event, in addition to continuing using `PTRACE_CONT`.
We also need to set the status to 0 so that we won't be waiting for a sysexit next.
This was causing us to skip many syscall enters...
If we are simply restarting a syscall, there's no need to do anything afterwards
to restore any register values so we don't really need to keep a record of it ourselves
in the chain syscall list.
By simply resetting the PC and the arguments, we avoid issue #292 for this function
when we get a signal before we run the restarted syscall and confused syscall
from the signal handler as the one we restarted (chained).
When the ptracer waits on a non-immediate child,
the information is only available in the zombies list and we need to handle those ourselves.
Expands the tracee lookup of the wait enter to include zombies of the tracee to handle this.
The new test mimicing the testing operation from gdb's `linux_check_ptrace_features`.
* Fix extraction of wrapped file
Make sure libarchive stops reading when we reach the end of the file.
The LZOP filter otherwize complains about data past the end.
Co-authored-by: Lucas Ramage <lucas.ramage@infinite-omicron.com>
* Enable github action for testing
Add a `QUIET_LOG` option for the test makefile to allow printing the full log
while still having a nice summary of the test results.
Co-authored-by: Lucas Ramage <lucas.ramage@infinite-omicron.com>
* Make sure we actually check if `img` is available
The current logic checks if docker is available a second time if it is available
and set the builder to img without checking if docker isn't available.
* Check if docker can run hello-world to catch permission error for the running user.
The event handler for the old kernel may still be called on new kernels.
This causes issues since the two event handlers maintains their own global states
unaware of each other.
In particular, execve+ptrace handling from the loader of the tracee
will issue an `execve(0x1, ...)` to signal proot of the start addresses.
This triggers a `SIGTRAP` to the tracee for the tracer to handle.
However, the event handler expect one initial `SIGTRAP` to have special meaning
and if the wrong event handler is called, it will incorrectly assume this `SIGTRAP`
is the special one and acts incorrectly. (In this case, causing the signaling `execve`
to run again and set the addresses incorrectly.)
* Fix python option handler...
... was this option ever used?
* Use the end symbol instead of the size symbol
It's difficult to use a *ABS* symbol from C code.
Specifying `-fPIC` could work around it but I'd like to not force it.
Instead, simply use the symbol pointing to the end of the file and
compute the size from the difference.
* Fix python3.8 linking
Starting python 3.8, the --ldflags by default omits the python library.
A new --embed option was added to restore the previous behavior.
Bug: https://github.com/proot-me/proot/issues/250
Force binding substitution and invocation of HOST_PATH extensions
on the first component of a user path (i.e. '/').
Otherwise for instance the following does not work when the rootfs
is readonly with fake_id0 extension:
$ proot -O -r rootfs touch /empty
This change will scan both '/' and 'empty' path components when
the '/empty' path is canonicalized, formerly, only the 'empty'
component was scanned.
This makes sure we actually access the argument rather than the results on arm and aarch64.
This is a partial workaround. A better solution might still be needed...
Bug: https://github.com/proot-me/proot/issues/283