[parisc-linux-cvs] setrlimit fix for "sshd drops argv[0] char 0" bug

Richard Hirst rhirst@linuxcare.com
Mon, 2 Apr 2001 21:59:38 +0100


On some machines, at least, sshd calls setrlimit to set the stack limit
to 0x3fffffff.  setup_arg_pages() assumes that limit will be page
aligned, and ends up with a stack segment at 0xbff00001.

You can tell whether setrlimit was called on your system with
cat /proc/NNN/maps for a child of sshd.  I saw:

bff00001-bff05000 rwxp 00000000 00:00 0

sshd is ok on rbrad's system, and showed

faf00000-faf04000 rwxp 00000000 00:00 0

Richard


===================================================================
RCS file: /home/cvs/parisc/linux/kernel/sys.c,v
retrieving revision 1.6
diff -u -r1.6 sys.c
--- sys.c       2000/11/10 21:45:05     1.6
+++ sys.c       2001/04/02 20:43:11
@@ -1076,6 +1076,11 @@
                if (new_rlim.rlim_cur > NR_OPEN || new_rlim.rlim_max > NR_OPEN)
                        return -EPERM;
        }
+       /* Code makes assumptions about RLIMIT_STACK being page aligned
+        * in various places (e.g. setup_arg_pages()).
+        */
+       if (resource == RLIMIT_STACK)
+               new_rlim.rlim_max = PAGE_ALIGN(new_rlim.rlim_max);
        *old_rlim = new_rlim;
        return 0;
 }