projects
/
openwrt
/
staging
/
blogic.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ec131b2
)
mm/gup_benchmark.c: prevent integer overflow in ioctl
author
Dan Carpenter
<
[email protected]
>
Tue, 30 Oct 2018 22:04:32 +0000
(15:04 -0700)
committer
Linus Torvalds
<
[email protected]
>
Wed, 31 Oct 2018 15:54:12 +0000
(08:54 -0700)
The concern here is that "gup->size" is a u64 and "nr_pages" is unsigned
long. On 32 bit systems we could trick the kernel into allocating fewer
pages than expected.
Link:
http://lkml.kernel.org/r/
[email protected]
Fixes: 64c349f4ae78 ("mm: add infrastructure for get_user_pages_fast() benchmarking")
Signed-off-by: Dan Carpenter <
[email protected]
>
Acked-by: Kirill A. Shutemov <
[email protected]
>
Reviewed-by: Andrew Morton <
[email protected]
>
Cc: Stephen Rothwell <
[email protected]
>
Cc: Keith Busch <
[email protected]
>
Cc: "Michael S. Tsirkin" <
[email protected]
>
Cc: Kees Cook <
[email protected]
>
Cc: YueHaibing <
[email protected]
>
Signed-off-by: Andrew Morton <
[email protected]
>
Signed-off-by: Linus Torvalds <
[email protected]
>
mm/gup_benchmark.c
patch
|
blob
|
history
diff --git
a/mm/gup_benchmark.c
b/mm/gup_benchmark.c
index debf11388a600d0f445ed1ac055e14bf0d55790d..5b42d3d4b60aa3a921002abf8f2872bc6e0764f8 100644
(file)
--- a/
mm/gup_benchmark.c
+++ b/
mm/gup_benchmark.c
@@
-27,6
+27,9
@@
static int __gup_benchmark_ioctl(unsigned int cmd,
int nr;
struct page **pages;
+ if (gup->size > ULONG_MAX)
+ return -EINVAL;
+
nr_pages = gup->size / PAGE_SIZE;
pages = kvcalloc(nr_pages, sizeof(void *), GFP_KERNEL);
if (!pages)