From: Peter Seiderer <Peter.Seiderer@ciselant.de>
To: linux-kernel@vger.kernel.org
Cc: Ville Herva <vherva@niksula.hut.fi>
Subject: [patch] Re: What is the difference between 'login: root' and 'su -' ?
Date: Thu, 8 Nov 2001 15:20:38 +0100 [thread overview]
Message-ID: <20011108152038.A728@zodiak.ecademix.com> (raw)
In-Reply-To: <20011107184710.A1410@zodiak.ecademix.com> <20011107224824.G26218@niksula.cs.hut.fi> <20011107234025.A602@zodiak.ecademix.com> <20011108081006.S1504@niksula.cs.hut.fi> <20011108094637.B615@zodiak.ecademix.com> <20011108104634.T1504@niksula.cs.hut.fi> <20011108100014.A704@zodiak.ecademix.com> <20011108111330.U1504@niksula.cs.hut.fi> <20011108111421.A612@zodiak.ecademix.com>
In-Reply-To: <20011108111421.A612@zodiak.ecademix.com>; from Peter.Seiderer@ciselant.de on Thu, Nov 08, 2001 at 11:14:21AM +0100
[-- Attachment #1: Type: text/plain, Size: 1156 bytes --]
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
[-- Attachment #2: patch_RLIM_INFINITY --]
[-- Type: text/plain, Size: 5195 bytes --]
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
next prev parent reply other threads:[~2001-11-08 14:50 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-11-07 17:47 What is the difference between 'login: root' and 'su -' ? Peter Seiderer
[not found] ` <20011107224824.G26218@niksula.cs.hut.fi>
2001-11-07 22:40 ` Peter Seiderer
[not found] ` <20011108081006.S1504@niksula.cs.hut.fi>
2001-11-08 8:46 ` Peter Seiderer
[not found] ` <20011108104634.T1504@niksula.cs.hut.fi>
2001-11-08 9:00 ` Peter Seiderer
[not found] ` <20011108111330.U1504@niksula.cs.hut.fi>
2001-11-08 10:14 ` Peter Seiderer
2001-11-08 14:20 ` Peter Seiderer [this message]
2001-11-08 7:31 ` Vitezslav Samel
2001-11-08 15:38 ` Tobias Diedrich
2001-11-08 18:35 ` Peter Seiderer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20011108152038.A728@zodiak.ecademix.com \
--to=peter.seiderer@ciselant.de \
--cc=linux-kernel@vger.kernel.org \
--cc=vherva@niksula.hut.fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).