Skip to contentSkip to conversation

2.6.33-rc8 breaks UML with Restrict initial stack space expansion to rlimit

PATCH In review Jouni Malinen 5 participants 15 messages Feb 14, 2010 – Feb 15, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA
#1 lore raw
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Crud, the "killed" is definitely something this patch could cause.

I'm not familiar with UML. Is this the guest and the host booting rc8, or just the host? Does UML use stack protection at all?

Can you try booting the guest to init=/bin/sh and try running some tests to see what you can set 'ulimit -s' to and still be able to run a simple command like '/bin/ls'?

Mikey

Quoted 4 lines
Signature · 2 lines
-- 
Jouni Malinen                                            PGP id EFC895FA
#2 lore raw
Quoted 15 lines
Quoted 12 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

Quoted 16 lines
Quoted 8 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal

Quoted 8 lines

mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

Wow. It seems very strange. Usually stack overflow makes SIGSEGV, not SIGKILL. plus, In my environment (x86_64 non-uml), mount command doesn't use the stack so much.

% /usr/bin/time --format="mem %M" ls
/usr/bin/time --format="mem %M" ls
GPATH INSTALL README configure fdisk lib misc-utils schedutils
mem 3232

% sudo /usr/bin/time --format="mem %M" mount -a
sudo /usr/bin/time --format="mem %M" mount -a
mem 2992

Hmmm...
I have no idea.

Quoted 35 lines
Quoted 4 lines

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Crud, the "killed" is definitely something this patch could cause.

I'm not familiar with UML. Is this the guest and the host booting rc8, or just the host? Does UML use stack protection at all?

Can you try booting the guest to init=/bin/sh and try running some tests to see what you can set 'ulimit -s' to and still be able to run a simple command like '/bin/ls'?

Mikey

Quoted 4 lines
Signature · 2 lines
-- 
Jouni Malinen                                            PGP id EFC895FA

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#3 lore raw
Quoted 3 lines · KOSAKI Motohiro

Wow. It seems very strange. Usually stack overflow makes SIGSEGV, not SIGKILL. plus, In my environment (x86_64 non-uml), mount command doesn't use the stack so much.

The SIGKILL part is the odd one, I would assume.. It looks like about half of the commands are failing with SIGKILL even with ulimit -s 8192 and the ulimit -s value did not really change the failure rate that much if at all. SIGSEGV starts showing up only after having limited ulimit -s to quite samll number (see my previous email).

Quoted 4 lines

% /usr/bin/time --format="mem %M" ls
/usr/bin/time --format="mem %M" ls
GPATH INSTALL README configure fdisk lib misc-utils schedutils
mem 3232

mem 3296
on my UML setup

Quoted 3 lines

% sudo /usr/bin/time --format="mem %M" mount -a
sudo /usr/bin/time --format="mem %M" mount -a
mem 2992

mem 2928

Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA
#4 lore raw
In reply to Michael Neuling
Quoted 4 lines · Michael Neuling

Crud, the "killed" is definitely something this patch could cause.

I'm not familiar with UML. Is this the guest and the host booting rc8, or just the host? Does UML use stack protection at all?

Only the guest was booting rc8 (host is Ubuntu 2.6.31-19-generic), i.e., the issue shows up in the guest kernel after rc8 (and is removed by reverting 803bf5). I do not know whether stack protection is used.

Quoted 3 lines

Can you try booting the guest to init=/bin/sh and try running some tests to see what you can set 'ulimit -s' to and still be able to run a simple command like '/bin/ls'?

With 803bf5 included, init=/bin/sh seems to fail the boot quite frequently, but not always. Once I get to shell on the UML guest, /bin/ls fails about half of the time (e.g., running /bin/ls in /root failed six times out of ten). This was before touching ulimit -s at all ("ulimit -s" shows 8192).

The behavior of 'ls' run with various ulimit -s values:

24-10000: OK or Killed
16-23: OK or Segmentation fault or Killed
1-15: Killed or Segmentation fault

I have no idea what is causing the random behavior in the results, but anyway, it looks like 'ulimit -s 23' is the first point where segmentation faults start showing up and 'ulimit -s 15' is the point where ls fails every time.

If I start the guest (normal boot with multiple virtual consoles) with 803bf5 reverted, 'ulimit -s 84' has /bin/ls working every time and 'ulimit -s 83' makes it fail every time.

Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA
#5 lore raw
In reply to Jouni Malinen
Quoted 32 lines · Jouni Malinen

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

I have created the Bugzilla entry at http://bugzilla.kernel.org/show_bug.cgi?id=15308
for your report.

Thanks,
Rafael

#6 lore raw
In reply to Jouni Malinen
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Jouni,

I can reproduce this now.

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

Let me know if it fixes it for you also.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in also attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This caused a regression in UML resulting in most guest processes to be killed.

fs/exec.c +4 -3
index e95c692..e0e7b3c 100644
@@ -637,15 +637,16 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_start + rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_start + max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_end + stack_expand;
 #else
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_end - rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_end - max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_start - stack_expand;
 #endif
#7 lore raw
Quoted 94 lines
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Jouni,

I can reproduce this now.

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

Let me know if it fixes it for you also.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in also attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This caused a regression in UML resulting in most guest processes to be killed.

fs/exec.c +2 -2
index e95c692..e0e7b3c 100644
@@ -637,15 +637,16 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_start + rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_start + max(rlim_stack,stack_size);

fs/exec.c int setup_arg_pages(struct linux_binprm *bprm, · line 652

Quoted 10 lines
fs/exec.c +2 -1
 	else
 		stack_base = vma->vm_end + stack_expand;
 #else
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_end - rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_end - max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_start - stack_expand;
 #endif

- rlim_stack = min(rlim_stack, stack_size);
+ /* Expand only to rlimit, making sure not to shrink it */
+ rlim_stack = max(rlim_stack, stack_size);

is better fix?

#8 lore raw
Quoted 5 lines · KOSAKI Motohiro
fs/exec.c +2 -1
-	rlim_stack = min(rlim_stack, stack_size);
+	/*  Expand only to rlimit, making sure not to shrink it */
+	rlim_stack = max(rlim_stack, stack_size);

is better fix?

Assuming I understood correctly that that was to replace the patch from Michael completely and not just a part of it (i.e., just this one-liner on top of linux-2.6.git), I can confirm that this, too, resolves the issue I was seeing with UML.

Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA
#9 lore raw

PATCH 1/1 exec/fs: fix initial stack reservation

In reply to KOSAKI Motohiro
Quoted 109 lines · In message <[email protected]> you wrote:
Quoted 104 lines
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Jouni,

I can reproduce this now.

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

Let me know if it fixes it for you also.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in also attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This caused a regression in UML resulting in most guest processes to be killed.

fs/exec.c +4 -3
index e95c692..e0e7b3c 100644
@@ -637,15 +637,16 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_start + rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_start + max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_end + stack_expand;
 #else
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_end - rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_end - max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_start - stack_expand;
 #endif
(quoted diff) +2 -1
-	rlim_stack = min(rlim_stack, stack_size);
+	/*  Expand only to rlimit, making sure not to shrink it */
+	rlim_stack = max(rlim_stack, stack_size);
Quoted 1 line

is better fix?

Actually, I think we can just get rid of min() line altogether. expand_stack checks to make sure the stack is getting bigger, otherwise it does nothing. We don't need to bother with this check.

The below works for me on UML x86_64 and ppc64 64k and 4k pages.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This size reduction check is not necessary as the expand_stack call does this already.

This caused a regression in UML resulting in most guest processes being killed.

---
 fs/exec.c |    1 -
 1 file changed, 1 deletion(-)
fs/exec.c +0 -1
Index: linux-2.6-ozlabs/fs/exec.c
===================================================================
@@ -637,7 +637,6 @@ int setup_arg_pages(struct linux_binprm 
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
 		stack_base = vma->vm_start + rlim_stack;
Reviewed-by on v1 1/1
#10 lore raw

Re: [PATCH] exec/fs: fix initial stack reservation

Quoted 110 lines
Quoted 109 lines · In message <[email protected]> you wrote:
Quoted 104 lines
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Jouni,

I can reproduce this now.

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

Let me know if it fixes it for you also.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in also attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This caused a regression in UML resulting in most guest processes to be killed.

fs/exec.c +4 -3
index e95c692..e0e7b3c 100644
@@ -637,15 +637,16 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_start + rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_start + max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_end + stack_expand;
 #else
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_end - rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_end - max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_start - stack_expand;
 #endif
(quoted diff) +2 -1
-	rlim_stack = min(rlim_stack, stack_size);
+	/*  Expand only to rlimit, making sure not to shrink it */
+	rlim_stack = max(rlim_stack, stack_size);
Quoted 7 lines
Quoted 1 line

is better fix?

Actually, I think we can just get rid of min() line altogether. expand_stack checks to make sure the stack is getting bigger, otherwise it does nothing. We don't need to bother with this check.

The below works for me on UML x86_64 and ppc64 64k and 4k pages.

OK, Right you are.

Quoted 34 lines

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This size reduction check is not necessary as the expand_stack call does this already.

This caused a regression in UML resulting in most guest processes being killed.

---
 fs/exec.c |    1 -
 1 file changed, 1 deletion(-)

Index: linux-2.6-ozlabs/fs/exec.c
===================================================================

fs/exec.c +0 -1
@@ -637,7 +637,6 @@ int setup_arg_pages(struct linux_binprm 
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
 		stack_base = vma->vm_start + rlim_stack;
Acked-by on v1 1/1
#11 lore raw

Re: [PATCH] exec/fs: fix initial stack reservation

In reply to Michael Neuling
Quoted 110 lines · Michael Neuling
Quoted 109 lines · In message <[email protected]> you wrote:
Quoted 104 lines
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Jouni,

I can reproduce this now.

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

Let me know if it fixes it for you also.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in also attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This caused a regression in UML resulting in most guest processes to be killed.

fs/exec.c +4 -3
index e95c692..e0e7b3c 100644
@@ -637,15 +637,16 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_start + rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_start + max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_end + stack_expand;
 #else
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_end - rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_end - max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_start - stack_expand;
 #endif
(quoted diff) +2 -1
-	rlim_stack = min(rlim_stack, stack_size);
+	/*  Expand only to rlimit, making sure not to shrink it */
+	rlim_stack = max(rlim_stack, stack_size);
Quoted 6 lines
Quoted 1 line

is better fix?

Actually, I think we can just get rid of min() line altogether. expand_stack checks to make sure the stack is getting bigger, otherwise it does nothing. We don't need to bother with this check.

Right...

Above change makes me confused. :-( But now, everything is clear.

Quoted 11 lines

The below works for me on UML x86_64 and ppc64 64k and 4k pages.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

Quoted 8 lines

This size reduction check is not necessary as the expand_stack call does this already.

This caused a regression in UML resulting in most guest processes being killed.

This one definitely better.

Quoted 21 lines

---
fs/exec.c | 1 -

1 file changed, 1 deletion(-)

Index: linux-2.6-ozlabs/fs/exec.c
===================================================================

fs/exec.c +0 -2
@@ -637,7 +637,6 @@ int setup_arg_pages(struct linux_binprm 
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
 		stack_base = vma->vm_start + rlim_stack;
--

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Signature · 1 line
Live like a child, think like the god.
#12 lore raw
In reply to KOSAKI Motohiro
Quoted 109 lines · KOSAKI Motohiro
Quoted 104 lines
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Jouni,

I can reproduce this now.

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

Let me know if it fixes it for you also.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in also attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This caused a regression in UML resulting in most guest processes to be killed.

fs/exec.c +4 -3
index e95c692..e0e7b3c 100644
@@ -637,15 +637,16 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_start + rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_start + max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_end + stack_expand;
 #else
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_end - rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_end - max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_start - stack_expand;
 #endif
fs/exec.c +2 -1
-	rlim_stack = min(rlim_stack, stack_size);
+	/*  Expand only to rlimit, making sure not to shrink it */
+	rlim_stack = max(rlim_stack, stack_size);
Quoted 2 lines

is better fix?

Odd. If this is the right fix, 'stack_size" will be able to exceed stack rlimit, then Michael's previous rlimit patch will be useless. Am I missing something?

#13 lore raw
Quoted 110 lines · KOSAKI Motohiro
Quoted 109 lines
Quoted 104 lines
Quoted 32 lines · In message <[email protected]> you wrote:

It looks like the commit 803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) broke my user mode Linux setup by somehow preventing system setup from running properly (or killing some processes that try to mount things, etc.). This commit turned up as the reason based on git bisect and reverting it fixes my UML test setup (Ubuntu 9.10 on both host and in UML and AMD64 arch for both). I have no idea what exactly would be the main cause for this issue, but this looks like a somewhat unfortunately timed regression in 2.6.33-rc8.

The failed run shows like this (with current linux-2.6.git):

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
mountall: mount /sys/kernel/debug [218] killed by KILL signal
mountall: Filesystem could not be mounted: /sys/kernel/debug
mountall: mount /dev [219] killed by KILL signal
mountall: Filesystem could not be mounted: /dev
mountall: mount /tmp [220] killed by KILL signal
mountall: Filesystem could not be mounted: /tmp
mountall: mount /var/lock [222] killed by KILL signal
mountall: Filesystem could not be mounted: /var/lock
...

With 803bf5ec reverted, UML comes up and the output looks like this:

Quoted 10 lines

...
EXT3-fs (ubda): mounted filesystem with writeback data mode
VFS: Mounted root (ext3 filesystem) readonly on device 98:0. IRQ 3/console-write: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 2/console: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs IRQ 10/winch: IRQF_DISABLED is not guaranteed on shared IRQs
init: procps main process (226) terminated with status 255 fsck from util-linux-ng 2.16
...

Jouni,

I can reproduce this now.

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

Let me know if it fixes it for you also.

Mikey

exec/fs: fix initial stack reservation

803bf5ec259941936262d10ecc84511b76a20921 (fs/exec.c: restrict initial stack space expansion to rlimit) attempts to limit the initial stack to 20*PAGE_SIZE. Unfortunately, in also attempting ensure the stack is not reduced in size, we ended up not changing the stack at all.

This caused a regression in UML resulting in most guest processes to be killed.

fs/exec.c +4 -3
index e95c692..e0e7b3c 100644
@@ -637,15 +637,16 @@ int setup_arg_pages(struct linux_binprm *bprm,
 	 * will align it up.
 	 */
 	rlim_stack = rlimit(RLIMIT_STACK) & PAGE_MASK;
-	rlim_stack = min(rlim_stack, stack_size);
 #ifdef CONFIG_STACK_GROWSUP
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_start + rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_start + max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_end + stack_expand;
 #else
 	if (stack_size + stack_expand > rlim_stack)
-		stack_base = vma->vm_end - rlim_stack;
+		/*  Expand only to rlimit, making sure not to shrink it */
+		stack_base = vma->vm_end - max(rlim_stack,stack_size);
 	else
 		stack_base = vma->vm_start - stack_expand;
 #endif
fs/exec.c +2 -1
-	rlim_stack = min(rlim_stack, stack_size);
+	/*  Expand only to rlimit, making sure not to shrink it */
+	rlim_stack = max(rlim_stack, stack_size);
Quoted 7 lines
Quoted 2 lines

is better fix?

Odd. If this is the right fix, 'stack_size" will be able to exceed stack rlimit, then Michael's previous rlimit patch will be useless. Am I missing something?

This function is in exec processing, IOW user process doesn't start yet, and stack_size is always PAGE_SIZE.

No problem.

This expression only mean we parse "ulimit -s 1" as "ulimit -s 4". (round up to one-page)

#14 lore raw
In reply to Michael Neuling
Quoted 11 lines · Michael Neuling

We got the logic wrong in one of the cleanups and hence we aren't actually changing the stack reservation ever, when we intended on allocating up to 20 new pages.

The:

	rlim_stack = min(rlim_stack, stack_size);

always chooses stack_size hence we end up not changing the stack at all. This seems to cause fatal problems on UML, but is obviously not what was intended for archs as well.

The following works for me on PPC64 64k and 4k pages and UML on x86_64.

That fixes my UML setup, too.

Signature · 1 line
Jouni Malinen                                            PGP id EFC895FA