Re: PIE breaks detection of available stack depth with getrlimit?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> If you can write a short program that demonstrates the failure,
> say by comparing getrlimit(RLIMIT_STACK) to the results of
> an internal "cat /proc/self/maps", then that's a kernel bug.

----- where.c
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/resource.h>

char buf[8192];

main()
{
	struct rlimit rlim;
	int const rv1= getrlimit(RLIMIT_STACK, &rlim);
	printf("stack rlim_cur=%p  rlim_max=%p  stack=%p\n",
		rlim.rlim_cur, rlim.rlim_max, &rlim);
	fflush(stdout);
	int const fd=open("/proc/self/maps", O_RDONLY);
	for (;;) {
		size_t len=read(fd, buf, sizeof(buf));
		if (-1==len) {
			perror("read"); exit(1);
		}
		if (0==len)
			break;
		if (len!=write(1, buf, len))
			perror("write"); exit(1);
	}
	return 0;
}
-----

$ gcc -m32 -pie -fPIE -o where where.c
$ ./where
stack rlim_cur=0x800000  rlim_max=0xffffffff  stack=0xffcc472c
f7558000-f7559000 rw-p 00000000 00:00 0
f7559000-f7704000 r-xp 00000000 08:0c 402364                             /usr/lib/libc-2.15.so
f7704000-f7705000 ---p 001ab000 08:0c 402364                             /usr/lib/libc-2.15.so
f7705000-f7707000 r--p 001ab000 08:0c 402364                             /usr/lib/libc-2.15.so
f7707000-f7708000 rw-p 001ad000 08:0c 402364                             /usr/lib/libc-2.15.so
f7708000-f770b000 rw-p 00000000 00:00 0
f7725000-f7727000 rw-p 00000000 00:00 0
f7727000-f7728000 r-xp 00000000 00:00 0                                  [vdso]
f7728000-f7747000 r-xp 00000000 08:0c 416838                             /usr/lib/ld-2.15.so
f7747000-f7748000 r--p 0001e000 08:0c 416838                             /usr/lib/ld-2.15.so
f7748000-f7749000 rw-p 0001f000 08:0c 416838                             /usr/lib/ld-2.15.so
f7749000-f774a000 r-xp 00000000 08:15 7024004                            /bigdata/home/jreiser/where
f774a000-f774b000 rw-p 00000000 08:15 7024004                            /bigdata/home/jreiser/where
f774b000-f774d000 rw-p 00000000 00:00 0
ffca5000-ffcc6000 rw-p 00000000 00:00 0                                  [stack]
$

Looks OK to me.  0xffcc6000 - 0x800000 = 0xff4c6000 which is above 0xf774d000
by 0x7d79000 which is a lot.  rlim_max=0xffffffff is "infinity" which
cannot be a real limit.

-- 

-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel





[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux