linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: Mike Kravetz <mike.kravetz@oracle.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	bugzilla-daemon@bugzilla.kernel.org,
	"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
	Nic Losby <blurbdust@gmail.com>,
	Yisheng Xie <xieyisheng1@huawei.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH v3] hugetlbfs: check for pgoff value overflow
Date: Fri, 16 Mar 2018 17:53:06 +0100	[thread overview]
Message-ID: <20180316165306.GM23100@dhcp22.suse.cz> (raw)
In-Reply-To: <12826dc6-c81e-c22a-2ec1-8e1cf0f07dfc@oracle.com>

On Fri 16-03-18 09:19:07, Mike Kravetz wrote:
> On 03/16/2018 03:17 AM, Michal Hocko wrote:
> > On Thu 08-03-18 16:27:26, Mike Kravetz wrote:
> > 
> > OK, looks good to me. Hairy but seems to be the easiest way around this.
> > Acked-by: Michal Hocko <mhocko@suse.com>
> > 
> <snip>
> >> +/*
> >> + * Mask used when checking the page offset value passed in via system
> >> + * calls.  This value will be converted to a loff_t which is signed.
> >> + * Therefore, we want to check the upper PAGE_SHIFT + 1 bits of the
> >> + * value.  The extra bit (- 1 in the shift value) is to take the sign
> >> + * bit into account.
> >> + */
> >> +#define PGOFF_LOFFT_MAX (PAGE_MASK << (BITS_PER_LONG - (2 * PAGE_SHIFT) - 1))
> 
> Thanks Michal,
> 
> However, kbuild found a problem with this definition on certain configs.
> Consider a config where,
> BITS_PER_LONG = 32 (32bit config)
> PAGE_SHIFT = 16 (64K pages)
> This results in the negative shift value.
> Not something I would not immediately think of, but a valid config.

Well, 64K pages on 32b doesn't sound even remotely sane to me but what
ever.

> The definition has been changed to,
> #define PGOFF_LOFFT_MAX \
> 	(((1UL << (PAGE_SHIFT + 1)) - 1) <<  (BITS_PER_LONG - (PAGE_SHIFT + 1)))
> 
> as discussed here,
> http://lkml.kernel.org/r/432fb2a3-b729-9c3a-7d60-890b8f9b10dd@oracle.com

This looks more wild but seems correct as well. You can keep my acked-by

Thanks!
-- 
Michal Hocko
SUSE Labs

      reply	other threads:[~2018-03-16 16:53 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-199037-27@https.bugzilla.kernel.org/>
2018-03-06 21:31 ` [Bug 199037] New: Kernel bug at mm/hugetlb.c:741 Andrew Morton
2018-03-06 21:46   ` Mike Kravetz
2018-03-07  0:31     ` Mike Kravetz
2018-03-07  2:49       ` Nic Losby
2018-03-07  4:19       ` Mike Kravetz
2018-03-07 16:39         ` Mike Kravetz
2018-03-07 23:59   ` [PATCH] hugetlbfs: check for pgoff value overflow Mike Kravetz
2018-03-08  0:57     ` Nic Losby
2018-03-08  1:35     ` Yisheng Xie
2018-03-08  4:25       ` Mike Kravetz
2018-03-08 21:03         ` Mike Kravetz
2018-03-08 21:05   ` [PATCH v2] " Mike Kravetz
2018-03-08 22:15     ` Andrew Morton
2018-03-08 23:37       ` Mike Kravetz
2018-03-08 23:53         ` Andrew Morton
2018-03-09  0:27   ` [PATCH v3] " Mike Kravetz
2018-03-09  1:05     ` Andrew Morton
2018-03-16 10:17     ` Michal Hocko
2018-03-16 16:19       ` Mike Kravetz
2018-03-16 16:53         ` Michal Hocko [this message]

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=20180316165306.GM23100@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=blurbdust@gmail.com \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=stable@vger.kernel.org \
    --cc=xieyisheng1@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