Re: how to flush out cache.?

From: Matthew Dillon (dillon_at_apollo.backplane.com)
Date: 04/23/04

  • Next message: Matthew Dillon: "Re: how to flush out cache.?"
    Date: Thu, 22 Apr 2004 19:42:24 -0700 (PDT)
    To: Stephan Uphoff <ups@tree.com>
    
    

        Ok... I've done some more testing.

        Ahh! I finally was able to reproduce the problem with PROT_READ, and
        I now see the code bit you were talking about. That's definitely a bug.

        Here's the test program that reproduces the problem. This is definitely
        a serious bug.

                                                    -Matt

    /*
     * y.c
     */
    #include <sys/types.h>
    #include <sys/mman.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>

    int
    main(int ac, char **av)
    {
        int fd;
        char *ptr1;
        char *ptr2;

        fd = open("test.dat", O_RDWR|O_CREAT|O_TRUNC, 0666);
        ftruncate(fd, 4096);
        ptr1 = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
        *ptr1 = 'A';
        ptr2 = mmap(NULL, 4096, PROT_READ, MAP_SHARED, fd, 0);
        if (msync(ptr2, 4096, MS_INVALIDATE | MS_SYNC) < 0)
            perror("msync");
        printf("contents of *ptr1 is %d\n", *ptr1);
        printf("contents of *ptr2 is %d\n", *ptr2);
        return(0);
    }

    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"


  • Next message: Matthew Dillon: "Re: how to flush out cache.?"

    Relevant Pages

    • Re: malloc()/realloc() - have I got this right?
      ... In one of the questions, you have to write a function to read lines of arbitrary length from the command line, using mallocand reallocto allocate the necessary memory to hold the lines. ... char *getline ... int line_len = 0; ... I'm hoping someone can tell me if I've got this function basically right - have I introduced some bug which is causing the crash, or is it a Windows thing that I don't need to concern myself with? ...
      (comp.lang.c)
    • Re: [PATCH] Avoid buffer overflows in get_user_pages()
      ... In particular, "len" is a signed int, and it is only checked at the ... So, if it is passed in as zero, the loop ... I think that, if get_user_pageshas been asked to grab zero pages, ... Which is a bug, and you want to catch it. ...
      (Linux-Kernel)
    • Re: Any isencrypted function available?
      ... static int incompressible(const char *inbuf, ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
      (Debian-User)
    • Re: pointers?
      ... int a; ... Well, not a bug IMO, but yes, that's what I'm talking about. ... Foo is called with delta as parameter, ... compiler "optimizes" b away, therefore the compiler has a bug. ...
      (comp.lang.forth)
    • Re: Version 1.3.1 Versus 1.4.2_04
      ... nail:Ncl/Java_bash-2.05b$ java -version ... public class Bug ... public Bug (int bg) ... [kvnsmnsn@star Rid3]$ java -version ...
      (comp.lang.java.programmer)