setup_linux: Use LDT fallback directly#113
setup_linux: Use LDT fallback directly#113AlgebraManiacABC wants to merge 3 commits intodecompals:mainfrom
Conversation
|
This is quite a hack, it disables the entire |
|
I turned out to be the "interested reader." I added SIGSYS handling for a preliminary 64-bit syscall, and on fail it uses LDT. If the 64-bit syscall works, it continues on to using the 32-bit version. I have tried this with success in Claude Cowork in version 1.1.5749 (ecf3d9). |
|
The "preliminary 64-bit syscall" is not actually probing syscall(243, desc)does not hit the compat There is also a seccomp ABI mismatch here. The existing asm path uses I think the better approach is to guard the real compat syscall directly instead of trying to probe it indirectly first. The note in the patch saying the SIGSYS handler "must NOT" be used for the asm path is misleading here. wibo is still a normal x86-64 process, even if it temporarily far-jumps into compat code and executes What I would suggest instead is:
Something along these lines: static void sigsysHandler(int, siginfo_t *info, void *ctx) {
auto *uc = static_cast<ucontext_t *>(ctx);
if (info->si_code != SYS_SECCOMP ||
info->si_arch != AUDIT_ARCH_I386 ||
info->si_syscall != 243) {
return;
}
uc->uc_mcontext.gregs[REG_RAX] = -ENOSYS;
}and then: struct sigaction sa = {}, oldSa = {};
sa.sa_sigaction = sigsysHandler;
sa.sa_flags = SA_SIGINFO;
sigemptyset(&sa.sa_mask);
sigaction(SIGSYS, &sa, &oldSa);
int ret = setThreadArea64(g_threadAreaEntry, teb);
sigaction(SIGSYS, &oldSa, nullptr);One caveat: this only helps if the seccomp policy uses a recoverable action that delivers |
Problem
On Linux environments where the seccomp filter blocks
set_thread_area(i386 syscall 243), wibo is killed by
SIGSYSduring thread setup. The signalarrives before the existing LDT fallback can execute, so the process never
recovers.
Fix
Initialize
g_threadAreaEntryto-2instead of-1insrc/setup_linux.cpp. The value-2is already the sentinel meaning "skipset_thread_areaand usemodify_ldt"; this change simply makes that thedefault rather than a fallback reached only after a failed attempt.
Agentic Coding
This fixes wibo to work under Claude's Cowork feature, since
modify_ldtispermitted by the seccomp policies there. As an alternative, I wonder if
there is a way to determine the seccomp policies beforehand?
The answer is left as an exercise for the interested reader.