Re: [PATCH 5/5] mm/gup: Take mmap_sem in get_dump_page()

From: Linus Torvalds
Date: Mon Apr 27 2020 - 23:59:19 EST


On Mon, Apr 27, 2020 at 8:28 PM Jann Horn <jannh@xxxxxxxxxx> wrote:
>
> Properly take the mmap_sem before calling into the GUP code from
> get_dump_page(); and play nice, allowing __get_user_pages_locked() to drop
> the mmap_sem if it has to sleep.

This makes my skin crawl.

The only reason for this all is that page cache flushing.

My gut feeling is that it should be done by get_user_pages() anyway,
since all the other users presumably want it to be coherent in the
cache.

And in fact, looking at __get_user_pages(), it already does that

if (pages) {
pages[i] = page;
flush_anon_page(vma, page, start);
flush_dcache_page(page);
ctx.page_mask = 0;
}

and I think that the get_dump_page() logic is unnecessary to begin with.

Linus