All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rik van Riel <riel@redhat.com>
To: lkp@lists.01.org
Subject: Re: [x86/uaccess] 5b710f34e1: kernel BUG at mm/usercopy.c:75!
Date: Wed, 17 Aug 2016 17:37:00 -0400	[thread overview]
Message-ID: <1471469820.32433.74.camel@redhat.com> (raw)
In-Reply-To: <CA+55aFw2Hxyavo5unZuu8YkNbsSwC1G5dSsrWYpNSq3kFnRWHg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1561 bytes --]

On Wed, 2016-08-17 at 09:14 -0700, Linus Torvalds wrote:

> but compound pages are about the mapping of hugepages, not about
> simple multi-order allocations like the task structure (or slab
> entries).
> 
> In other words, it looks like the memory hardening is simply broken
> for any case that doesn't use kmalloc(), but instead just allocates
> non-order-0 pages directly. Which is certainly _rare_, but not
> unheard
> of.
> 
> I'm not sure how to fix it.The low-level page allocator does *not*
> mark orders anywhere.
> 
> I suspect we should just get rid of the page-crosser checking,
> because
> it's unsolvable.

I glossed over the fact that prep_new_page only marks
the page as a compound page if __GFP_COMP is set, which
it is not for some higher order allocations, including
GFP masks passed straight through by the SLOB allocator.

This particular allocation is through kmalloc, but the
kernel in question has CONFIG_SLOB=y, and usercopy has
no code in mm/slob.c

I can think of two possibilities:
- mark every higher order allocation so it can be
  recognized later on (this might break allocators
  that free part of a higher order allocation, I
  do not know whether they exist)
- drop this part of the usercopy code, and no longer
  check that a range is part of an object that was
  allocated all at once, or spans multiple memory
  allocations - this may be ok, given that most
  heap overflows are likely to be kmalloc/slab objects,
  anyway

kind regards,

Rik
-- 

All Rights Reversed.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Rik van Riel <riel@redhat.com>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	kernel test robot <xiaolong.ye@intel.com>
Cc: Kees Cook <keescook@chromium.org>, LKP <lkp@01.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Valdis Kletnieks <valdis.kletnieks@vt.edu>
Subject: Re: [x86/uaccess] 5b710f34e1: kernel BUG at mm/usercopy.c:75!
Date: Wed, 17 Aug 2016 17:37:00 -0400	[thread overview]
Message-ID: <1471469820.32433.74.camel@redhat.com> (raw)
In-Reply-To: <CA+55aFw2Hxyavo5unZuu8YkNbsSwC1G5dSsrWYpNSq3kFnRWHg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1559 bytes --]

On Wed, 2016-08-17 at 09:14 -0700, Linus Torvalds wrote:

> but compound pages are about the mapping of hugepages, not about
> simple multi-order allocations like the task structure (or slab
> entries).
> 
> In other words, it looks like the memory hardening is simply broken
> for any case that doesn't use kmalloc(), but instead just allocates
> non-order-0 pages directly. Which is certainly _rare_, but not
> unheard
> of.
> 
> I'm not sure how to fix it.The low-level page allocator does *not*
> mark orders anywhere.
> 
> I suspect we should just get rid of the page-crosser checking,
> because
> it's unsolvable.

I glossed over the fact that prep_new_page only marks
the page as a compound page if __GFP_COMP is set, which
it is not for some higher order allocations, including
GFP masks passed straight through by the SLOB allocator.

This particular allocation is through kmalloc, but the
kernel in question has CONFIG_SLOB=y, and usercopy has
no code in mm/slob.c

I can think of two possibilities:
- mark every higher order allocation so it can be
  recognized later on (this might break allocators
  that free part of a higher order allocation, I
  do not know whether they exist)
- drop this part of the usercopy code, and no longer
  check that a range is part of an object that was
  allocated all at once, or spans multiple memory
  allocations - this may be ok, given that most
  heap overflows are likely to be kmalloc/slab objects,
  anyway

kind regards,

Rik
-- 

All Rights Reversed.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

  parent reply	other threads:[~2016-08-17 21:37 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-17 12:17 [x86/uaccess] 5b710f34e1: kernel BUG at mm/usercopy.c:75! kernel test robot
2016-08-17 12:17 ` kernel test robot
2016-08-17 16:14 ` Linus Torvalds
2016-08-17 16:14   ` Linus Torvalds
2016-08-17 21:25   ` Kees Cook
2016-08-17 21:25     ` Kees Cook
2016-08-17 21:30     ` Linus Torvalds
2016-08-17 21:30       ` Linus Torvalds
2016-08-17 21:34       ` Kees Cook
2016-08-17 21:34         ` Kees Cook
2016-08-17 21:37   ` Rik van Riel [this message]
2016-08-17 21:37     ` Rik van Riel
2016-08-17 21:45     ` Linus Torvalds
2016-08-17 21:45       ` Linus Torvalds
2016-08-17 21:50       ` Kees Cook
2016-08-17 21:50         ` Kees Cook
2016-08-17 21:55         ` Linus Torvalds
2016-08-17 21:55           ` Linus Torvalds
2016-08-17 21:57           ` Kees Cook
2016-08-17 21:57             ` Kees Cook
2016-08-17 21:45     ` Kees Cook
2016-08-17 21:45       ` Kees Cook
2016-08-17 21:52       ` Linus Torvalds
2016-08-17 21:52         ` Linus Torvalds
2016-08-17 21:53         ` Kees Cook
2016-08-17 21:53           ` Kees Cook
  -- strict thread matches above, loose matches on Subject: below --
2016-08-18  5:44 kernel test robot
2016-08-18  5:44 ` kernel test robot
2016-08-18  6:27 ` Ye Xiaolong

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=1471469820.32433.74.camel@redhat.com \
    --to=riel@redhat.com \
    --cc=lkp@lists.01.org \
    /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.