Commit 763f2e0
埃博拉酱
Address Copilot review on PR termux#348 and cache sysnum-regset availability
Two follow-ups to the unmodifiable-sysnum workaround:
1) Rewrite the workaround comment in src/syscall/syscall.c to reflect
the real failure point. The previous wording blamed the NT_PRSTATUS
push carrying x8=-1, but push_specific_regs() bails out earlier: on
arm64 it returns as soon as PTRACE_SETREGSET(NT_ARM_SYSTEM_CALL)
returns EINVAL, so the general-register push is never even
attempted. The comment now describes the syscall-number regset /
register in architecture-agnostic terms (x8/x0 references kept only
as concrete arm64 examples inside the explanation) and records why
a "known-unsafe syscall" guard proposed by the reviewer is not
added: (a) the legacy "keep sysnum=PR_void" path is strictly worse
on affected kernels because it causes SIGSEGV and kills the tracee;
(b) poisoning all six arg registers to -1 already traps the vast
majority of side-effectful syscalls at the kernel's
parameter-validation stage; (c) we have no empirically grounded
list of syscalls that both reach this suppression path and cause
harmful side effects when invoked with poisoned args, so a
speculative allow/deny list would be dead code. sysexit still
overrides the return-value register with the real error code.
2) Cache NT_ARM_SYSTEM_CALL availability in src/tracee/reg.c. The
regset is a kernel-global capability: once PTRACE_SETREGSET rejects
it with EINVAL, it will never succeed under the same running
kernel. A process-local static bool short-circuits subsequent
requests so the caller hits its workaround path immediately,
without paying the cost of a guaranteed-failing ptrace call on
every intercepted syscall. Only EINVAL is cached; ESRCH/EPERM/
EFAULT are per-tracee state errors and are not treated as kernel-
capability signals. The cache is memory-only and not persisted, so
a new proot run always re-probes — this keeps behaviour correct
across reboots, kernel upgrades, or chroots into different
kernels, at the cost of a single failing ptrace per proot start
on affected kernels.1 parent 970d51c commit 763f2e0
2 files changed
Lines changed: 55 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | | - | |
| 246 | + | |
247 | 247 | | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
253 | 256 | | |
254 | 257 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
261 | 266 | | |
262 | | - | |
| 267 | + | |
263 | 268 | | |
264 | 269 | | |
265 | | - | |
266 | | - | |
267 | | - | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
268 | 288 | | |
269 | 289 | | |
270 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
335 | | - | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
336 | 348 | | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
337 | 353 | | |
338 | 354 | | |
339 | 355 | | |
340 | 356 | | |
| 357 | + | |
| 358 | + | |
341 | 359 | | |
342 | 360 | | |
343 | 361 | | |
| |||
0 commit comments