Fix sigaltstack error path leaking sighand lock - #2727
Conversation
|
Independently reproduced and confirmed. We hit this in the iSH-AOK fork as well and arrived at the identical fix, so this is a second pair of eyes rather than a competing patch. Reproduced on master (7864dd6) using your reproducer plus one extra step — any later signal operation needs long r = syscall(SYS_sigaltstack, &ss, NULL); /* ss.ss_size = 1 */
printf("[1] ret=%ld errno=%d\n", r, errno);
signal(SIGUSR1, h); /* needs sighand->lock */
raise(SIGUSR1);
printf("SURVIVED\n");
Worth noting how hard it wedges: on the unpatched build the program produces no output whatsoever, not even the first For whatever it's worth as an independent data point: our fork has carried the same one-line |
sys_sigaltstack()returns_ENOMEMwhile still holdingsighand->lockwhen the new alt stack is smaller thanMINSIGSTKSZ_, causing a permanent lock leak/deadlock on later signal operations.A simple reproducer:
When this reproducer is compiled and run inside the iSH app, the whole app becomes stuck after the first failing
sigaltstack()call.