[lkml]   [2006]   [Aug]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
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.


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;
+ }

 \ /
  Last update: 2006-08-20 02:47    [W:0.149 / U:0.044 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site