lkml.org 
[lkml]   [2006]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] set*uid() must not fail-and-return on OOM/rlimits
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
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)
\
 
 \ /
  Last update: 2006-08-20 02:47    [from the cache]
©2003-2011 Jasper Spaans