mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Markus Wichmann <nullplan@gmx.net>
To: musl@lists.openwall.com
Cc: musl@lists.openwall.com
Subject: Re: [musl] synccall patches
Date: Thu, 2 Nov 2023 17:42:14 +0100	[thread overview]
Message-ID: <ZUPRZjmCTJ4X3FuL@voyager> (raw)
In-Reply-To: <20231101170506.GS4163@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 87 bytes --]

Hi all,

as discussed, I'm attaching a new patch for the __setxid issue.

Ciao,
Markus

[-- Attachment #2: 0004-Ensure-valid-setxid-return-value.patch --]
[-- Type: text/x-diff, Size: 1264 bytes --]

From 1f3b01f625dd7d33a7107efbd8417857461bb4fe Mon Sep 17 00:00:00 2001
From: Markus Wichmann <nullplan@gmx.net>
Date: Thu, 2 Nov 2023 17:39:33 +0100
Subject: [PATCH 4/4] Ensure valid setxid return 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..1dfb2c01 100644
--- a/src/unistd/setxid.c
+++ b/src/unistd/setxid.c
@@ -30,5 +30,5 @@ int __setxid(int nr, int id, int eid, int sid)
 	 * trigger the safety kill above. */
 	struct ctx c = { .nr = nr, .id = id, .eid = eid, .sid = sid, .ret = 1 };
 	__synccall(do_setxid, &c);
-	return __syscall_ret(c.ret);
+	return __syscall_ret(c.ret > 0? -EAGAIN : c.ret);
 }
--
2.39.2


  reply	other threads:[~2023-11-02 16:42 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31 16:21 Markus Wichmann
2023-11-01 13:00 ` Rich Felker
2023-11-01 13:53   ` Markus Wichmann
2023-11-01 17:05     ` Rich Felker
2023-11-02 16:42       ` Markus Wichmann [this message]
2023-11-01 17:28   ` Alexey Izbyshev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZUPRZjmCTJ4X3FuL@voyager \
    --to=nullplan@gmx.net \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).