Commit Graph

1266 Commits

Author SHA1 Message Date
Josselin Poiret a5ee0b7900 Fix test-25069c12 and test-25069c13 for new kernels.
Fix both tests in the same vein as [1].  Note that this behavior had been
changed by Linux's [2], not by glibc as suggested by [1].

[1] 10dd605103
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=dcd46d897adb70d63e025f175a00a89797d31a43
2023-05-13 01:31:16 -05:00
Lucas Ramage c5a465e8d6 Rename test-0cf405b0.c 2023-04-23 19:36:28 +00:00
Kimon Hoffmann 10dd605103 Fix test-0cf405b0 for newer versions of glibc.
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.
2023-04-23 15:08:34 -04:00
David Leonard 8d94d2a1a7 Add option --mixed-mode to disable mixed execution
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
2023-04-22 17:42:22 -04:00
Lucas Ramage 6cd6da9fa4 Include lib directory in Makefile 2023-04-22 17:09:28 -04:00
Lucas Ramage d8b2dcf4ba Pin lib/uthash at v2.3.0 2023-04-22 17:09:28 -04:00
Lucas Ramage 41d78d48c0 Add uthash submodule 2023-04-22 17:09:28 -04:00
Lucas Ramage ae17d787c5 Update copyright year 2023-04-22 17:09:28 -04:00
Lucas Ramage 3d512fe64d Android compatibility in temp.c 2023-04-22 17:09:28 -04:00
Lucas Ramage 1ced0101ef
Enable SonarCloud (#347)
* Create sonarcloud.yml

* Create sonar-project.properties

* Combine github actions files

* Fix syntax error with GitHub Actions

* Update clang-tools for GitHub Actions

* Simplify test matrix naming
2023-04-15 20:25:00 -04:00
Lucas Ramage c8401b1f6d
Add link to usage survey
[skip ci]
2023-01-27 09:38:38 -05:00
Lucas Ramage a0dc181e93 Remove extra tab for PR_faccessat2 2022-10-29 14:06:18 -04:00
name f23459ee66 Add: faccess2(2) syscall 2022-10-29 14:06:18 -04:00
Lucas Ramage 99a8417521 Prepare for v5.3.1 release 2022-04-24 16:52:11 -04:00
Lucas Ramage dabcc6ffd2 Fix incorrect year for 5.3.0 release 2022-04-24 16:52:11 -04:00
orent 0a1d0b4aa4
Remove unnecessary dependency of proot on libarchive. (#309)
Also generate CARE dependency using pkgconfig.
2022-01-22 11:51:39 -05:00
Jakub Zakrzewski 9e9cd23baa
Set the restart_how field in a newly created child tracee. (#308)
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.
2022-01-22 11:49:01 -05:00
Jakub Zakrzewski d92431accd
Error out when trying to set PTRACE_O_TRACESECCOMP under ptrace emulation. (#311)
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.
2022-01-22 11:48:01 -05:00
Lucas Ramage dde79f8d00
Remove changelog from doc makefile (#317) 2022-01-05 20:17:50 -05:00
Lucas Ramage 96e5a8b1f2
Prepare for v5.3.0 release (#316)
* Update DOI badge

* Update CHANGELOG.rst

* Delete changelog.rst for proot and care

* Update manual.rst

* Update proot.h
2022-01-04 22:40:30 -05:00
Lucas Ramage f6f43005c0 Update wording in manual regarding rootfs
Closes: https://github.com/proot-me/proot/issues/271
2021-11-08 01:26:46 +00:00
Lucas Ramage 45fecd7cc2
Add link to repository on website (#273)
Closes: https://github.com/proot-me/proot/issues/245
2021-11-07 20:22:40 -05:00
Lucas Ramage db16f34966
Fix fchmod permissions for loader (#268)
Bug: https://github.com/proot-me/proot/issues/227
2021-11-05 19:16:09 -04:00
Yichao Yu 185f6fdc17
Some printing tweaks (#300)
* Add a message for stopping and starting of tracees
* Try not to print anything by default
2021-11-05 19:10:15 -04:00
Yichao Yu eb8b77a117
Do not unconditionally use PTRACE_CONT when recieving a useless SECCOMP event (#301)
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.
2021-11-05 18:28:29 -04:00
Yichao Yu f81a72d3dc
Fix test compilation on ARM (#302)
The user_regs_struct has different names on different architectures...
2021-11-05 18:26:42 -04:00
Yichao Yu 1a9609dc6c
Support utimensat_time64 on 32bit architectures (#303)
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...
2021-11-05 18:25:40 -04:00
Yichao Yu 53191c518e
Remove special handling of syscall avoider number on ARM (#304)
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.
2021-11-05 18:23:52 -04:00
Yichao Yu dd57b59200
Allow the value of AT_HWCAP to be empty (#305)
On ARM the glibc decodes the hwcap into strings similar to that from /proc/cpuinfo.
This means that an value of zero prints an empty string.
2021-11-05 18:21:19 -04:00
Yichao Yu ba3cb343fa
Fix include in tests (#299) 2021-10-06 06:34:25 -04:00
Yichao Yu d69b41ae5b
Fix handling of receiving seccomp after normal ptrace event (#298)
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...
2021-10-05 16:36:01 -04:00
Yichao Yu d8bf141fea
Change restart_original_syscall to not use chained syscall (#297)
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).
2021-10-05 16:34:41 -04:00
Yichao Yu 464d242f8c
Fix waitpid on zombies (#291)
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`.
2021-10-04 17:06:55 -04:00
Yichao Yu cc6bac2367
Fix extraction of wrapped file (#295)
* 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>
2021-10-04 17:01:30 -04:00
Yichao Yu 47fc3a3066
Fix archive suffix handling (#294)
* Parse ".raw" as raw instead of bin.
* Respect the explicit wrapper choice when no compression format is specified.
2021-10-04 16:53:03 -04:00
Yichao Yu 248bcda083
Install LZOP on CI for CARE archive extraction (#296) 2021-10-04 16:51:58 -04:00
Yichao Yu 3bd4a3c757
Do not treat libarchive warnings as errors (#293) 2021-10-04 16:49:03 -04:00
Yichao Yu e5a1af0818
Enable github action for testing (#287)
* 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>
2021-10-02 15:00:07 -04:00
Yichao Yu 9e40f58234
Fix and improve docker test skip detection (#289)
* 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.
2021-10-02 14:54:05 -04:00
Yichao Yu d0a8b690b6
Fix event handling on newer kernels (#288)
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.)
2021-10-02 14:51:06 -04:00
Lucas Ramage a70023ab3d
Delete roadmap.rst 2021-10-01 13:36:37 -04:00
Lucas Ramage 295768c4a4
Delete roadmap.rst 2021-10-01 13:36:07 -04:00
Yichao Yu 6baaa278e0
A few fixes for the python extension (#285)
* 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
2021-10-01 13:22:37 -04:00
Christophe Guillon af689de986
canon: call bindings substitution on '/' component of user path (#100)
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.
2021-10-01 10:57:24 -04:00
Yichao Yu a577a36545
Access sockfd in the chained getsocketname via the original version (#284)
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
2021-10-01 10:55:43 -04:00
Yichao Yu b0afb6bbc0
Make sure not to fake too old an kernel release (#281)
Or glibc will complain about kernel too old...
2021-10-01 10:54:43 -04:00
Yichao Yu 806bb62f27
Make sure the stack is aligned (#282)
This is required on AArch64.
X86 also requires this for SIMD code.

Bug: https://github.com/proot-me/proot/issues/263
2021-10-01 10:53:12 -04:00
Yichao Yu f5b81a9a56
Python 3 support in test (#280) 2021-10-01 10:52:10 -04:00
Yichao Yu d9198cdf77
Allow a higher initial heap size in test (#279)
A `/bin/sleep` has an initial heap size fo 33 pages on my local setup.
-1 pages is way too small to fail.
2021-10-01 10:51:22 -04:00
Yichao Yu 267efd6ac6
Fix regression in socket name shortening (#278)
Instead of creating a temporary socket directly,
create a temporary directory and have the socket be created in there.

Bug: https://github.com/proot-me/proot/issues/260
2021-10-01 10:49:36 -04:00