Re: [PATCH] mm, gpu: fix error when FOLL_MLOCK an unpresent page

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

 



On Mon, Aug 30, 2021 at 6:08 PM Christoph Hellwig <hch@xxxxxxxxxxxxx> wrote:
>
> On Mon, Aug 30, 2021 at 05:12:32PM +0800, Yafang Shao wrote:
> > > Which is not a valid way to call get_user_pages.  What we need to do is
> > > to reject that case.
> >
> > Do you mean below change ?
>
> Sory of.  I think once touching this we should do a few more cleanups
> including making many of the flags private to gup.c.  I'll try to find
> some time to post a more complete series.

JFYI, below test case can also hit the bug I reported above.

#define _GNU_SOURCE
#include <stdio.h>
#include <sys/mman.h>

#define LEN 4096

int main()
{
        char *addr;
        int ret;

        addr = mmap(NULL, LEN, PROT_READ|PROT_WRITE, MAP_PRIVATE |
MAP_ANON , -1, 0);
        if (addr == MAP_FAILED) {
                perror("mmap");
                return ret;
        }

        /*
         * MLOCK_ONFAULT  will hit below if condition.
         *  if ((*flags & (FOLL_POPULATE | FOLL_MLOCK)) == FOLL_MLOCK)
         *       return -ENOENT;
         */
        ret = mlock2(addr, LEN, MLOCK_ONFAULT);
//      ret = mlock2(addr, LEN, 0);
        if (ret < 0) {
                perror("mlock2");
                return ret;
        }

        return 0;
}

-- 
Thanks
Yafang




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

  Powered by Linux