Re: [PATCH] Fix overflow in vma length when copying mmap on clone

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

 



On 25 April 2012 01:10, Siddhesh Poyarekar <siddhesh.poyarekar@xxxxxxxxx> wrote:
> That was supposed to be errno, not the pointer. I had added my own
> syscall wrappers to eliminate glibc and then reverted it to the
> original smaller-to-read reproducer and this got left behind in the
> process. The demo program is supposed to show "successed" for
> iterations 16383 to 16390 since the overflow happens at 16TB. All
> iterations before it (and after) show a fork failure.
>
> /proc/sys/vm/overcommit_memory is 0.
>
> Perhaps a cleaner demo program would have been:

Ugh, I missed some details once again. The demo below will show
"Unexpected success" without this patch in place. The system I've
tested this patch on is an x86_64 F-16 box with 4GB RAM and 6GB swap.

> #include <stdio.h>
> #include <unistd.h>
> #include <sys/mman.h>
> #include <errno.h>
>
> #define GIG 1024 * 1024 * 1024L
> #define EXTENT 16393
>
> int main(void)
> {
>        int i, r;
>        void *m;
>        char buf[1024];
>        int prev_failed = 0;
>
>        for (i = 0; i < EXTENT; i++) {
>                m = mmap(NULL, (size_t) 1 * 1024 * 1024 * 1024L,
>                         PROT_READ | PROT_WRITE, MAP_PRIVATE |
> MAP_ANONYMOUS, 0, 0);
>
>                if (m == (void *)-1) {
>                        printf("MMAP Failed: %d\n", errno);
>                        return 1;
>                }
>
>                r = fork();
>
>                if (r == 0) {
>                        return 0;
>                } else if (r < 0) {
>                        prev_failed = 1;
>                        /* Fork failed as expected */
>                }
>                else if (r > 0 && prev_failed) {
>                        printf("Unexpected success at %d\n", i);
>                        wait(NULL);
>                        return 1;
>                }
>        }
>        return 0;
> }
>



-- 
Siddhesh Poyarekar
http://siddhesh.in

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]