All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	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: Re: [PATCH] mm/gup_benchmark: prevent integer overflow in ioctl
Date: Thu, 25 Oct 2018 07:32:29 +0000	[thread overview]
Message-ID: <20181025073229.dbsloufbem4p4arz@kshutemo-mobl1> (raw)
In-Reply-To: <20181025061546.hnhkv33diogf2uis@kili.mountain>

On Thu, Oct 25, 2018 at 09:15:46AM +0300, Dan Carpenter wrote:
> 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;
> +

Strictly speaking gup->size / PAGE_SIZE has to be <= ULONG_MAX, but it
should be fine this way too.

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

WARNING: multiple messages have this Message-ID (diff)
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	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: Re: [PATCH] mm/gup_benchmark: prevent integer overflow in ioctl
Date: Thu, 25 Oct 2018 10:32:29 +0300	[thread overview]
Message-ID: <20181025073229.dbsloufbem4p4arz@kshutemo-mobl1> (raw)
In-Reply-To: <20181025061546.hnhkv33diogf2uis@kili.mountain>

On Thu, Oct 25, 2018 at 09:15:46AM +0300, Dan Carpenter wrote:
> 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;
> +

Strictly speaking gup->size / PAGE_SIZE has to be <= ULONG_MAX, but it
should be fine this way too.

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

-- 
 Kirill A. Shutemov

  reply	other threads:[~2018-10-25  7:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25  6:15 [PATCH] mm/gup_benchmark: prevent integer overflow in ioctl Dan Carpenter
2018-10-25  6:15 ` Dan Carpenter
2018-10-25  7:32 ` Kirill A. Shutemov [this message]
2018-10-25  7:32   ` Kirill A. Shutemov
2018-11-01  6:38 ` William Kucharski
2018-11-01  6:38   ` William Kucharski
2018-11-01  7:16   ` Dan Carpenter
2018-11-01  7:16     ` Dan Carpenter
2018-11-01  8:28     ` William Kucharski
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=20181025073229.dbsloufbem4p4arz@kshutemo-mobl1 \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=dan.carpenter@oracle.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.