Skip to content

Commit 9883c7f

Browse files
jgunthorpeakpm00
authored andcommitted
mm/gup: do not return 0 from pin_user_pages_fast() for bad args
These routines are not intended to return zero, the callers cannot do anything sane with a 0 return. They should return an error which means future calls to GUP will not succeed, or they should return some non-zero number of pinned pages which means GUP should be called again. If start + nr_pages overflows it should return -EOVERFLOW to signal the arguments are invalid. Syzkaller keeps tripping on this when fuzzing GUP arguments. Link: https://lkml.kernel.org/r/0-v1-3d5ed1f20d50+104-gup_overflow_jgg@nvidia.com Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Reported-by: syzbot+353c7be4964c6253f24a@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/000000000000094fdd05faa4d3a4@google.com Reviewed-by: John Hubbard <jhubbard@nvidia.com> Reviewed-by: Lorenzo Stoakes <lstoakes@gmail.com> Reviewed-by: David Hildenbrand <david@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 0b52c42 commit 9883c7f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/gup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3080,7 +3080,7 @@ static int internal_get_user_pages_fast(unsigned long start,
30803080
start = untagged_addr(start) & PAGE_MASK;
30813081
len = nr_pages << PAGE_SHIFT;
30823082
if (check_add_overflow(start, len, &end))
3083-
return 0;
3083+
return -EOVERFLOW;
30843084
if (end > TASK_SIZE_MAX)
30853085
return -EFAULT;
30863086
if (unlikely(!access_ok((void __user *)start, len)))

0 commit comments

Comments
 (0)