linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Matthew Wilcox <willy@infradead.org>, linux-mm@kvack.org
Cc: Kees Cook <keescook@chromium.org>, Jann Horn <jannh@google.com>
Subject: Re: [DESIGN] Hardening page allocator against type confusion
Date: Thu, 3 Oct 2024 16:27:12 +0200	[thread overview]
Message-ID: <c36bf308-1966-48fd-82a2-a2ce6dbcf6db@suse.cz> (raw)
In-Reply-To: <ZvRogWyCrfm6WD7U@casper.infradead.org>

On 9/25/24 21:46, Matthew Wilcox wrote:
> Kees and I had a fun discussion at Plumbers.
> 
> We're trying to harden against type confusion, where we think we have
> a pointer to one thing, but it turns out to be a pointer to a different
> thing.  There's various ways this can be harmful, which Kees has laid out
> before when adding slab buckets.  eg see https://lwn.net/Articles/978976/
> 
> Not all allocations come from slab though.  If we free a slab object
> and the slab it was in gets freed back to the page allocator, it can
> turn into almost anything else _quickly_ as the page allocator fronts
> the buddy allocator with a stack of recently-freed pages (called PCP,
> not to be confused with percpu memory), so if the attacker can arrange
> for a page table allocation to come in soon after a slab free, it is
> very likely to be the memory they have access to.
> 
> My proposal is that we resolve this "type confusion" by having separate
> PCP lists for different types of pages.  We'll need to have this for
> memdescs anyway, so this is just shifting some of the work left.
> 
> We'd reduce the exploitability of type confusion by using a per-CPU,
> per-type stack of recently used pages.  To turn a slab page into a page
> table page, the attacker would have to cause a dozen slabs to be freed on
> this CPU, pushing this one into the buddy allocator.  Then they'd have
> to cause the allocating task to empty its stack of page table pages,
> causing the attackable slab to be pulled from the buddy.  It's still
> possible, but it's harder.
> 
> Harder enough?  I don't know, hence this email.  We can get into the
> API design (and then the implementation design) if we have agreement
> that this is the right approach to be taking.

Not a security expert but I doubt it's harder enough?

I thought the robust mitigation here was SLAB_VIRTUAL


  reply	other threads:[~2024-10-03 14:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-25 19:46 Matthew Wilcox
2024-10-03 14:27 ` Vlastimil Babka [this message]
2024-10-03 16:50   ` Matthew Wilcox
2024-10-04 14:04     ` Vlastimil Babka
2024-10-04 18:01     ` Kees Cook

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=c36bf308-1966-48fd-82a2-a2ce6dbcf6db@suse.cz \
    --to=vbabka@suse.cz \
    --cc=jannh@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox