public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] set*uid() must not fail-and-return on OOM/rlimits
@ 2006-08-20  0:38 Solar Designer
  2006-08-20  7:52 ` Kari Hurtta
                   ` (4 more replies)
  0 siblings, 5 replies; 31+ messages in thread
From: Solar Designer @ 2006-08-20  0:38 UTC (permalink / raw)
  To: Willy Tarreau; +Cc: linux-kernel

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

Willy and all,

Attached is a trivial patch (extracted from 2.4.33-ow1) that makes
set*uid() kill the current process rather than proceed with -EAGAIN when
the kernel is running out of memory.  Apparently, alloc_uid() can't fail
and return anyway due to properties of the allocator, in which case the
patch does not change a thing.  But better safe than sorry.

As you're probably aware, 2.6 kernels are affected to a greater extent,
where set*uid() may also fail on trying to exceed RLIMIT_NPROC.  That
needs to be fixed, too.

Opinions are welcome.

Thanks,

Alexander

[-- Attachment #2: linux-2.4.33-ow1-set_user.diff --]
[-- Type: text/plain, Size: 431 bytes --]

diff -urpPX nopatch linux-2.4.33/kernel/sys.c linux/kernel/sys.c
--- linux-2.4.33/kernel/sys.c	Fri Nov 28 21:26:21 2003
+++ linux/kernel/sys.c	Wed Aug 16 05:19:21 2006
@@ -514,8 +514,10 @@ static int set_user(uid_t new_ruid, int 
 	struct user_struct *new_user;
 
 	new_user = alloc_uid(new_ruid);
-	if (!new_user)
+	if (!new_user) {
+		force_sig(SIGSEGV, current);
 		return -EAGAIN;
+	}
 	switch_uid(new_user);
 
 	if(dumpclear)

^ permalink raw reply	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2006-08-21  5:06 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-08-20  0:38 [PATCH] set*uid() must not fail-and-return on OOM/rlimits Solar Designer
2006-08-20  7:52 ` Kari Hurtta
2006-08-20 18:10   ` Alan Cox
2006-08-21  5:05     ` Kari Hurtta
2006-08-20  8:26 ` Willy Tarreau
2006-08-20 15:25   ` Solar Designer
2006-08-20 10:07 ` Alex Riesen
2006-08-20 15:30   ` Solar Designer
2006-08-20 15:53     ` Arjan van de Ven
2006-08-20 16:17       ` Willy Tarreau
2006-08-20 16:28       ` Ulrich Drepper
2006-08-20 16:45         ` Arjan van de Ven
2006-08-20 16:47         ` Michael Buesch
2006-08-20 16:48         ` Solar Designer
2006-08-20 18:03     ` Alan Cox
2006-08-20 18:10       ` Willy Tarreau
2006-08-20 18:36         ` Alan Cox
2006-08-20 18:21           ` Willy Tarreau
2006-08-20 18:52             ` Alan Cox
2006-08-20 19:01               ` Willy Tarreau
2006-08-20 19:33                 ` Alan Cox
2006-08-20 19:17                   ` Willy Tarreau
2006-08-20 16:04 ` Florian Weimer
2006-08-20 16:25   ` Solar Designer
2006-08-20 18:14 ` Alan Cox
2006-08-20 22:12   ` Solar Designer
2006-08-20 22:51     ` Alan Cox
2006-08-20 22:58       ` Solar Designer
2006-08-20 23:00       ` Alan Cox
2006-08-21  0:23       ` Peter Williams
2006-08-21  0:45         ` Solar Designer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox