mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: david.keisarschm@mail.huji.ac.il
To: linux-kernel@vger.kernel.org
Cc: Jason@zx2c4.com, linux-mm@kvack.org, akpm@linux-foundation.org,
	vbabka@suse.cz, 42.hyeyoo@gmail.com, mingo@redhat.com,
	hpa@zytor.com, keescook@chromium.org,
	David Keisar Schmidt <david.keisarschm@mail.huji.ac.il>,
	aksecurity@gmail.com, ilay.bahat1@gmail.com
Subject: [PATCH v4 0/3] Secure prandom_u32 invocations
Date: Fri, 13 Jan 2023 23:33:10 +0200	[thread overview]
Message-ID: <cover.1673470326.git.david.keisarschm@mail.huji.ac.il> (raw)

From: David Keisar Schmidt <david.keisarschm@mail.huji.ac.il>

Hi,

The security improvements for prandom_u32 done in commits c51f8f88d705
from October 2020 and d4150779e60f from May 2022 didn't handle the cases
when prandom_bytes_state() and prandom_u32_state() are used.

Specifically, this weak randomization takes place in three cases:
    1.	mm/slab.c
    2.	mm/slab_common.c
    3.	arch/x86/mm/kaslr.c

The first two invocations (mm/slab.c, mm/slab_common.c) are used to create
randomization in the slab allocator freelists.
This is done to make sure attackers can’t obtain information on the heap state.

The last invocation, inside arch/x86/mm/kaslr.c,
randomizes the virtual address space of kernel memory regions.
The use of prandom_bytes_state() is justified since it has a dedicated
state and draws only 3 pseudo random values, but the seeding state takes advantage
of only 32 bits out of 64 bits of the seed.
Hence, we have added the necessary changes to make those randomizations stronger,
switching the invocation of prandom_seed_state to a more secure version, which
we implemented inside kaslr.c.
---
Changes since v3:
* arch/x86/mm/kaslr.c: secure the way the region offsets are generated in the
  seeding state - Adding a revised version of prandom_seed_state
* edited commit messages

Changes since v2:
* edited commit message.
* replaced instances of get_random_u32 with get_random_u32_below
      in mm/slab.c, mm/slab_common.c

Regards,

David Keisar Schmidt (3):
  Replace invocation of weak PRNG in mm/slab.c
  Replace invocation of weak PRNG inside mm/slab_common.c
  Add 64bits prandom_seed_state to arch/x86/mm/kaslr.c

 arch/x86/mm/kaslr.c | 26 +++++++++++++++++++++++++-
 mm/slab.c           | 25 ++++++++++---------------
 mm/slab_common.c    | 11 +++--------
 3 files changed, 38 insertions(+), 24 deletions(-)

-- 
2.38.0


             reply	other threads:[~2023-01-13 21:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 21:33 david.keisarschm [this message]
2023-01-13 21:35 ` [PATCH v4 1/3] slab_allocator: mm/slab.c: Replace invocation of weak PRNG david.keisarschm
2023-01-13 21:37 ` [PATCH v4 2/3] slab_allocator: mm/slab_common.c: " david.keisarschm
2023-01-13 21:39 ` [PATCH v4 3/3] x86 mm, x86 architecture (32-bit and 64-bit): arch/x86/mm/kaslr.c: Adds 64bits version of prandom_seed_state david.keisarschm
2023-01-14  2:10   ` H. Peter Anvin
     [not found]     ` <CAD0z2U1Y1CR_erAj+akPbVF2jxicdQKQfqWPc69fwL-rvSu_fQ@mail.gmail.com>
2023-01-17 23:50       ` H. Peter Anvin

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=cover.1673470326.git.david.keisarschm@mail.huji.ac.il \
    --to=david.keisarschm@mail.huji.ac.il \
    --cc=42.hyeyoo@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=akpm@linux-foundation.org \
    --cc=aksecurity@gmail.com \
    --cc=hpa@zytor.com \
    --cc=ilay.bahat1@gmail.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mingo@redhat.com \
    --cc=vbabka@suse.cz \
    /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

all inboxes | Powered by JetHome®