From: Dan Carpenter <dan.carpenter@oracle.com>
To: Andrew Morton <akpm@linux-foundation.org>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>,
Keith Busch <keith.busch@intel.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Kees Cook <keescook@chromium.org>,
YueHaibing <yuehaibing@huawei.com>,
linux-mm@kvack.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] mm/gup_benchmark: prevent integer overflow in ioctl
Date: Thu, 25 Oct 2018 09:15:46 +0300 [thread overview]
Message-ID: <20181025061546.hnhkv33diogf2uis@kili.mountain> (raw)
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.
Fixes: 64c349f4ae78 ("mm: add infrastructure for get_user_pages_fast() benchmarking")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
mm/gup_benchmark.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c
index debf11388a60..5b42d3d4b60a 100644
--- 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)
--
2.11.0
next reply other threads:[~2018-10-25 6:16 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 6:15 Dan Carpenter [this message]
2018-10-25 7:32 ` Kirill A. Shutemov
2018-11-01 6:38 ` William Kucharski
2018-11-01 7:16 ` Dan Carpenter
2018-11-01 8:28 ` William Kucharski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181025061546.hnhkv33diogf2uis@kili.mountain \
--to=dan.carpenter@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=keescook@chromium.org \
--cc=keith.busch@intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-mm@kvack.org \
--cc=mst@redhat.com \
--cc=sfr@canb.auug.org.au \
--cc=yuehaibing@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox