summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Gunthorpe <jgg@nvidia.com>2023-06-19 15:27:25 -0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-11 12:14:25 +0200
commitd160941e1537c1b53f8c1de247bc8420b8619094 (patch)
treef07ace14af2d2ea3ef9d52363ceb5265185c284c
parent4abda85197ba5d695e6040d580b4b409ce0d3733 (diff)
downloadlinux-d160941e1537c1b53f8c1de247bc8420b8619094.tar.gz
linux-d160941e1537c1b53f8c1de247bc8420b8619094.tar.bz2
linux-d160941e1537c1b53f8c1de247bc8420b8619094.zip
mm/gup: do not return 0 from pin_user_pages_fast() for bad args
commit 9883c7f84053cec2826ca3c56254601b5ce9cdbe upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--mm/gup.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/gup.c b/mm/gup.c
index 94102390b273..e3e6c473bbc1 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2977,7 +2977,7 @@ static int internal_get_user_pages_fast(unsigned long start,
start = untagged_addr(start) & PAGE_MASK;
len = nr_pages << PAGE_SHIFT;
if (check_add_overflow(start, len, &end))
- return 0;
+ return -EOVERFLOW;
if (end > TASK_SIZE_MAX)
return -EFAULT;
if (unlikely(!access_ok((void __user *)start, len)))