lkml.org 
[lkml]   [2001]   [Nov]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] Re: What is the difference between 'login: root' and 'su -' ?
On Thu, Nov 08, 2001 at 11:14:21AM +0100, Peter Seiderer wrote:
> Hello,
> the SIGXFSZ signal is produced in the file mm/filemap.c (linx-2.4.14) in
> line 2771:
>
> 2769: if (limit != RLIM_INFINITY) {
> 2770: if (pos >= limit) {
> 2771: send_sig(SIGXFSZ, current, 0);
> 2772: goto out;
> 2773: }
>
> The valus at this point are
> limit: 0x7fffffff
> RLIM_INFINITY: 0xffffffff
> pos: 0x80004000
>
> where limit comes from:
> unsigned long limit = current->rlim[RLIMIT_FSIZE].rlim_cur;
>
> but I did not yet detected the point(s) where
> current->rlim[RLIMIT_FSIZE].rlim_cur
> is(are) set/changed.
> Peter
>

Investigated a litte bit in the kernel I detected there is a
sys_getrlimit function and a sys_old_getrlimit function which is
called in arch i386, m68k, sh, ppc, s390, cris, arm which mangles the
RLIM_INFINITY: 0xffffffff to 0x7fffffff.

The problem is that it is now impossible to set the limits to
RLIM_INFINITY while only 0x7fffffff is given as input.

Therefor I programed analog to sys_old_getrlimit the function sys_old_setrlimit
which mangles all values >= 0x7fffffff to 0xffffffff (see attached patch).

Peter


diff -ru linux-2.4.14_orig/arch/arm/kernel/calls.S linux-2.4.14/arch/arm/kernel/calls.S
--- linux-2.4.14_orig/arch/arm/kernel/calls.S Mon Oct 8 19:39:18 2001
+++ linux-2.4.14/arch/arm/kernel/calls.S Thu Nov 8 14:48:58 2001
@@ -89,7 +89,7 @@
.long SYMBOL_NAME(sys_sigsuspend_wrapper)
.long SYMBOL_NAME(sys_sigpending)
.long SYMBOL_NAME(sys_sethostname)
-/* 75 */ .long SYMBOL_NAME(sys_setrlimit)
+/* 75 */ .long SYMBOL_NAME(sys_old_setrlimit)
.long SYMBOL_NAME(sys_old_getrlimit)
.long SYMBOL_NAME(sys_getrusage)
.long SYMBOL_NAME(sys_gettimeofday)
diff -ru linux-2.4.14_orig/arch/cris/kernel/entry.S linux-2.4.14/arch/cris/kernel/entry.S
--- linux-2.4.14_orig/arch/cris/kernel/entry.S Mon Oct 8 20:43:54 2001
+++ linux-2.4.14/arch/cris/kernel/entry.S Thu Nov 8 14:48:40 2001
@@ -833,7 +833,7 @@
.long SYMBOL_NAME(sys_sigsuspend)
.long SYMBOL_NAME(sys_sigpending)
.long SYMBOL_NAME(sys_sethostname)
- .long SYMBOL_NAME(sys_setrlimit) /* 75 */
+ .long SYMBOL_NAME(sys_old_setrlimit) /* 75 */
.long SYMBOL_NAME(sys_old_getrlimit)
.long SYMBOL_NAME(sys_getrusage)
.long SYMBOL_NAME(sys_gettimeofday)
diff -ru linux-2.4.14_orig/arch/i386/kernel/entry.S linux-2.4.14/arch/i386/kernel/entry.S
--- linux-2.4.14_orig/arch/i386/kernel/entry.S Sat Nov 3 02:18:49 2001
+++ linux-2.4.14/arch/i386/kernel/entry.S Thu Nov 8 13:57:47 2001
@@ -471,7 +471,7 @@
.long SYMBOL_NAME(sys_sigsuspend)
.long SYMBOL_NAME(sys_sigpending)
.long SYMBOL_NAME(sys_sethostname)
- .long SYMBOL_NAME(sys_setrlimit) /* 75 */
+ .long SYMBOL_NAME(sys_old_setrlimit) /* 75 */
.long SYMBOL_NAME(sys_old_getrlimit)
.long SYMBOL_NAME(sys_getrusage)
.long SYMBOL_NAME(sys_gettimeofday)
diff -ru linux-2.4.14_orig/arch/m68k/kernel/entry.S linux-2.4.14/arch/m68k/kernel/entry.S
--- linux-2.4.14_orig/arch/m68k/kernel/entry.S Mon Oct 8 19:39:18 2001
+++ linux-2.4.14/arch/m68k/kernel/entry.S Thu Nov 8 14:46:53 2001
@@ -500,7 +500,7 @@
.long SYMBOL_NAME(sys_sigsuspend)
.long SYMBOL_NAME(sys_sigpending)
.long SYMBOL_NAME(sys_sethostname)
- .long SYMBOL_NAME(sys_setrlimit) /* 75 */
+ .long SYMBOL_NAME(sys_old_setrlimit) /* 75 */
.long SYMBOL_NAME(sys_old_getrlimit)
.long SYMBOL_NAME(sys_getrusage)
.long SYMBOL_NAME(sys_gettimeofday)
diff -ru linux-2.4.14_orig/arch/ppc/kernel/misc.S linux-2.4.14/arch/ppc/kernel/misc.S
--- linux-2.4.14_orig/arch/ppc/kernel/misc.S Sat Nov 3 02:43:54 2001
+++ linux-2.4.14/arch/ppc/kernel/misc.S Thu Nov 8 14:47:54 2001
@@ -988,7 +988,7 @@
.long sys_sigsuspend
.long sys_sigpending
.long sys_sethostname
- .long sys_setrlimit /* 75 */
+ .long sys_old_setrlimit /* 75 */
.long sys_old_getrlimit
.long sys_getrusage
.long sys_gettimeofday
diff -ru linux-2.4.14_orig/arch/s390/kernel/entry.S linux-2.4.14/arch/s390/kernel/entry.S
--- linux-2.4.14_orig/arch/s390/kernel/entry.S Thu Oct 11 18:04:57 2001
+++ linux-2.4.14/arch/s390/kernel/entry.S Thu Nov 8 14:48:24 2001
@@ -442,7 +442,7 @@
.long sys_sigsuspend_glue
.long sys_sigpending
.long sys_sethostname
- .long sys_setrlimit /* 75 */
+ .long sys_old_setrlimit /* 75 */
.long sys_old_getrlimit
.long sys_getrusage
.long sys_gettimeofday
diff -ru linux-2.4.14_orig/arch/sh/kernel/entry.S linux-2.4.14/arch/sh/kernel/entry.S
--- linux-2.4.14_orig/arch/sh/kernel/entry.S Mon Oct 8 19:39:18 2001
+++ linux-2.4.14/arch/sh/kernel/entry.S Thu Nov 8 14:47:13 2001
@@ -1151,7 +1151,7 @@
.long SYMBOL_NAME(sys_sigsuspend)
.long SYMBOL_NAME(sys_sigpending)
.long SYMBOL_NAME(sys_sethostname)
- .long SYMBOL_NAME(sys_setrlimit) /* 75 */
+ .long SYMBOL_NAME(sys_old_setrlimit) /* 75 */
.long SYMBOL_NAME(sys_old_getrlimit)
.long SYMBOL_NAME(sys_getrusage)
.long SYMBOL_NAME(sys_gettimeofday)
diff -ru linux-2.4.14_orig/kernel/sys.c linux-2.4.14/kernel/sys.c
--- linux-2.4.14_orig/kernel/sys.c Tue Sep 18 23:10:43 2001
+++ linux-2.4.14/kernel/sys.c Thu Nov 8 14:54:11 2001
@@ -1133,6 +1133,39 @@
return 0;
}

+#if !defined(__ia64__)
+
+/*
+ * Analog to sys_old_getrlimit the back compatibility for setrlimit.
+ */
+
+asmlinkage long sys_old_setrlimit(unsigned int resource, struct rlimit *rlim)
+{
+ struct rlimit new_rlim, *old_rlim;
+
+ if (resource >= RLIM_NLIMITS)
+ return -EINVAL;
+ if(copy_from_user(&new_rlim, rlim, sizeof(*rlim)))
+ return -EFAULT;
+ old_rlim = current->rlim + resource;
+ if (((new_rlim.rlim_cur > old_rlim->rlim_max) ||
+ (new_rlim.rlim_max > old_rlim->rlim_max)) &&
+ !capable(CAP_SYS_RESOURCE))
+ return -EPERM;
+ if (resource == RLIMIT_NOFILE) {
+ if (new_rlim.rlim_cur > NR_OPEN || new_rlim.rlim_max > NR_OPEN)
+ return -EPERM;
+ }
+ if (new_rlim.rlim_cur >= 0x7FFFFFFF)
+ new_rlim.rlim_cur = RLIM_INFINITY;
+ if (new_rlim.rlim_max >= 0x7FFFFFFF)
+ new_rlim.rlim_max = RLIM_INFINITY;
+ *old_rlim = new_rlim;
+ return 0;
+}
+
+#endif
+
/*
* It would make sense to put struct rusage in the task_struct,
* except that would make the task_struct be *really big*. After
\
 
 \ /
  Last update: 2005-03-22 13:13    [W:0.087 / U:8.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site