diff --git a/docs/development/proroot-analysis.md b/docs/development/proroot-analysis.md index f3bdb0e393..7d4139c35a 100644 --- a/docs/development/proroot-analysis.md +++ b/docs/development/proroot-analysis.md @@ -70,7 +70,7 @@ handles the same constraint with `libproot-loader.so`. | path calls from glibc internals (ld.so, fts, realpath, nss, `__open_nocancel`) and raw `svc` | **still go to proot (15–60 µs)** | **patched svc sites** | | Android-blocked syscalls (`set_robust_list`, `faccessat2`, `clone3`, ...) | SIGSYS stop answered by proot (0016 etc.), one ptrace round trip and one signal round trip each | in-process | | `brk` | proot emulation, a trap per call (mitigated by `top_pad`) | in-process emulation | -| correctness fallback | proot is always there | none: anything missed runs unconfined or is emulated wrongly | +| correctness fallback | proot is always there | limited in-process seccomp/SIGSYS handling; no general tracer fallback, so calls outside the filter can run unconfined or be emulated incorrectly | | long Unix socket paths | fast path `/proc/self/fd/N/name` aliases | short socket aliases (`proroot_create_short_unix_socket_alias`) | | rseq | `GLIBC_TUNABLES=glibc.pthread.rseq=0` | trampoline | @@ -533,3 +533,15 @@ PID. Per-run Steam/CEF medians ranged 1,217.9–1,240.9 MiB off and variation, but it is not evidence of zero memory cost. PSS avoids counting shared pages in full for each process. Startup and memory comparisons used one unchanged APK; no downloads or games were initiated during them. + +CodeRabbit follow-up: the workload now compares canonical paths, so relative and +absolute fixture arguments agree. All SVC bench tools keep their checks active +under NDEBUG; their clock, syscall and thread operations cannot silently disappear. +Both cases were rebuilt with -DNDEBUG and checked on Thor. The memory-file-denial +test now blocks only O_RDWR opens and asserts the single-thread check still works, +so it reaches the intended /proc/self/mem failure. The initial proroot comparison +also distinguishes its limited in-process fallback from a general tracer. +The request to return to default-off was addressed through the interruption/unwind +fixes and tests while retaining the requested default. The proposed readlink count +change was not applied because exact boundary tests reproduce the current PRoot +behavior; changing that inherited policy belongs in a separate correctness change. diff --git a/tools/proot/bench/checks.h b/tools/proot/bench/checks.h new file mode 100644 index 0000000000..2b0f9064ad --- /dev/null +++ b/tools/proot/bench/checks.h @@ -0,0 +1,10 @@ +#ifndef DROIDDECK_BENCH_CHECKS_H +#define DROIDDECK_BENCH_CHECKS_H + +/* Benchmark assertions execute the operations being measured. */ +#ifdef NDEBUG +#undef NDEBUG +#endif +#include + +#endif diff --git a/tools/proot/bench/svc-check.c b/tools/proot/bench/svc-check.c index 664181d606..bb40bdece0 100644 --- a/tools/proot/bench/svc-check.c +++ b/tools/proot/bench/svc-check.c @@ -3,7 +3,7 @@ static void interruption_hook(const long *); #define FP_SVC_TEST_HOOK interruption_hook #endif #include "../fastpath/fastpath.c" -#include +#include "checks.h" #include #include #include diff --git a/tools/proot/bench/svc-fail.c b/tools/proot/bench/svc-fail.c index 3dcb8badf3..c53bf8e183 100644 --- a/tools/proot/bench/svc-fail.c +++ b/tools/proot/bench/svc-fail.c @@ -1,5 +1,5 @@ #include "../fastpath/fastpath.c" -#include +#include "checks.h" #include #include #include diff --git a/tools/proot/bench/svc-race.c b/tools/proot/bench/svc-race.c index 4198f4e36c..efd6a22fb3 100644 --- a/tools/proot/bench/svc-race.c +++ b/tools/proot/bench/svc-race.c @@ -1,5 +1,5 @@ #define _GNU_SOURCE -#include +#include "checks.h" #include #include #include diff --git a/tools/proot/bench/svc-storage.c b/tools/proot/bench/svc-storage.c index 2b9dd40ca6..ff829ecb95 100644 --- a/tools/proot/bench/svc-storage.c +++ b/tools/proot/bench/svc-storage.c @@ -1,5 +1,5 @@ #define _GNU_SOURCE -#include +#include "checks.h" #include #include #include diff --git a/tools/proot/bench/svc-threads.c b/tools/proot/bench/svc-threads.c index 88988bd2e6..6eae555a80 100644 --- a/tools/proot/bench/svc-threads.c +++ b/tools/proot/bench/svc-threads.c @@ -1,5 +1,5 @@ #define _GNU_SOURCE -#include +#include "checks.h" #include #include #include diff --git a/tools/proot/bench/svc-workload.c b/tools/proot/bench/svc-workload.c index 350a7081ca..89f0dc5904 100644 --- a/tools/proot/bench/svc-workload.c +++ b/tools/proot/bench/svc-workload.c @@ -1,5 +1,5 @@ #define _GNU_SOURCE -#include +#include "checks.h" #include #include #include @@ -59,8 +59,9 @@ int main(int argc, char **argv) { } assert(fts_close(fts) == 0); printf("fts: %u files %u dirs %u links\n", files, dirs, links); - char resolved[4096]; - assert(realpath(link, resolved) && !strcmp(resolved, path)); + char resolved[4096], canonical[4096]; + assert(realpath(path, canonical)); + assert(realpath(link, resolved) && !strcmp(resolved, canonical)); struct passwd pw, *found; char buf[16384]; r = getpwnam_r("root", &pw, buf, sizeof buf, &found); diff --git a/tools/tests/test_fastpath_svc.py b/tools/tests/test_fastpath_svc.py index 41c1be275d..7a74aac9af 100644 --- a/tools/tests/test_fastpath_svc.py +++ b/tools/tests/test_fastpath_svc.py @@ -14,11 +14,22 @@ class FastPathSvcEncodingTest(unittest.TestCase): self.skipTest("cc is not available") with tempfile.TemporaryDirectory() as directory: program = Path(directory) / "check.c" - program.write_text(source.replace('"HEADER"', '"' + HEADER.with_name(header).as_posix() + '"')) + program.write_text(source.replace('"HEADER"', '"' + (HEADER.parent / header).as_posix() + '"')) output = Path(directory) / "check" subprocess.run(["cc", "-O2", "-Wall", "-Wextra", "-Werror", str(program), "-o", str(output)], check=True) subprocess.run([str(output)], check=True, timeout=10) + def test_benchmark_checks_execute_with_ndebug(self): + self.compile_check(r''' +#define NDEBUG +#include "HEADER" +int main(void) { + int calls = 0; + assert(++calls == 1); + return calls != 1; +} +''', "../bench/checks.h") + def test_stack_bounds_and_alternate_stack_fallback(self): self.compile_check(r''' #define _GNU_SOURCE