Commit f4000fdf authored by John Hubbard's avatar John Hubbard Committed by Linus Torvalds
Browse files

mm/gup: allow FOLL_FORCE for get_user_pages_fast()

Commit 817be129 ("mm: validate get_user_pages_fast flags") allowed
only FOLL_WRITE and FOLL_LONGTERM to be passed to get_user_pages_fast().
This, combined with the fact that get_user_pages_fast() falls back to
"slow gup", which *does* accept FOLL_FORCE, leads to an odd situation:
if you need FOLL_FORCE, you cannot call get_user_pages_fast().

There does not appear to be any reason for filtering out FOLL_FORCE.
There is nothing in the _fast() implementation that requires that we
avoid writing to the pages.  So it appears to have been an oversight.

Fix by allowing FOLL_FORCE to be set for get_user_pages_fast().

Fixes: 817be129

 ("mm: validate get_user_pages_fast flags")
Signed-off-by: default avatarJohn Hubbard <>
Reviewed-by: default avatarLeon Romanovsky <>
Reviewed-by: default avatarJan Kara <>
Cc: Christoph Hellwig <>
Cc: Alex Williamson <>
Cc: Aneesh Kumar K.V <>
Cc: Björn Töpel <>
Cc: Daniel Vetter <>
Cc: Dan Williams <>
Cc: Hans Verkuil <>
Cc: Ira Weiny <>
Cc: Jason Gunthorpe <>
Cc: Jason Gunthorpe <>
Cc: Jens Axboe <>
Cc: Jerome Glisse <>
Cc: Jonathan Corbet <>
Cc: Kirill A. Shutemov <>
Cc: Mauro Carvalho Chehab <>
Cc: Mike Rapoport <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 3567813e
......@@ -2411,7 +2411,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages,
unsigned long addr, len, end;
int nr = 0, ret = 0;
return -EINVAL;
start = untagged_addr(start) & PAGE_MASK;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment