From 44e97fb238670e83eff31c3894cc8a024cef051c Mon Sep 17 00:00:00 2001 From: Markus Wichmann Date: Tue, 31 Oct 2023 16:59:47 +0100 Subject: [PATCH 1/2] Initialize setxid retval to valid value. If __synccall() fails to capture all threads because tkill fails for some reason other than EAGAIN, then the callback given will never be executed, so nothing will ever overwrite the initial value. So that is the value that will be returned from the function. The previous setting of 1 is not a valid value for setuid() et al. to return. I chose -EAGAIN since I don't know the reason the synccall failed ahead of time, but EAGAIN is a specified error code for a possibly temporary failure in setuid(). --- src/unistd/setxid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unistd/setxid.c b/src/unistd/setxid.c index 487c1a16..0a2d9d12 100644 --- a/src/unistd/setxid.c +++ b/src/unistd/setxid.c @@ -28,7 +28,7 @@ int __setxid(int nr, int id, int eid, int sid) { /* ret is initially nonzero so that failure of the first thread does not * trigger the safety kill above. */ - struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .ret = 1 }; + struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .ret = -EAGAIN }; __synccall(do_setxid, &c); return __syscall_ret(c.ret); } -- 2.39.2