Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 23 Aug 2013 13:40:31 +0200
From: (Jérémie Courrèges-Anglas)
To: Tavis Ormandy <>
Cc: Jilles Tjoelker <>, Harald van Dijk <>,,
Subject: Re: [PATCH] implement privmode support in dash


Tavis Ormandy <> writes:


>> Apart from that, it is better to check the return value from setuid()
>> and similar functions. In particular, some versions of Linux may fail
>> setuid() for [EAGAIN], leaving the process running with the same
>> privileges.
> I don't think this is true anymore, but I have no strong objection to
> adding it, so long as it's noted that bash and pdksh do not do this.

Just for reference, from mksh:


/* we don't need to check for other codes, EPERM won't happen */
#define DO_SETUID(func, argvec) do {					\
	if ((func argvec) && errno == EAGAIN)				\
		errorf("%s failed with EAGAIN, probably due to a"	\
		    " too low process limit; aborting", #func);		\
} while (/* CONSTCOND */ 0)
#define DO_SETUID(func, argvec) func argvec


	  if (f == FPRIVILEGED && oldval && !newval) {
		/* Turning off -p? */

		/*XXX this can probably be optimised */
		kshegid = kshgid = getgid();
		DO_SETUID(setresgid, (kshegid, kshegid, kshegid));
		/* setgroups doesn't EAGAIN on Linux */
		setgroups(1, &kshegid);
		DO_SETUID(setresuid, (ksheuid, ksheuid, ksheuid));
		/* seteuid, setegid, setgid don't EAGAIN on Linux */
		ksheuid = kshuid = getuid();
		DO_SETUID(setuid, (ksheuid));
	} [...]

> Tavis.

jca | PGP: 0x06A11494 / 61DB D9A0 00A4 67CF 2A90  8961 6191 8FBF 06A1 1494

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.