From: tip-bot for Baoquan He <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: bhe@redhat.com, mingo@kernel.org,
kirill.shutemov@linux.intel.com, linux-kernel@vger.kernel.org,
tglx@linutronix.de, hpa@zytor.com
Subject: [tip:x86/mm] x86/mm/KASLR: Reduce randomization granularity for 5-level paging to 1GB
Date: Fri, 5 Apr 2019 13:19:56 -0700 [thread overview]
Message-ID: <tip-b569c18434987163a05f05a12cdf6a9975c55ff3@git.kernel.org> (raw)
In-Reply-To: <20190308025616.21440-3-bhe@redhat.com>
Commit-ID: b569c18434987163a05f05a12cdf6a9975c55ff3
Gitweb: https://git.kernel.org/tip/b569c18434987163a05f05a12cdf6a9975c55ff3
Author: Baoquan He <bhe@redhat.com>
AuthorDate: Fri, 8 Mar 2019 10:56:16 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 5 Apr 2019 22:13:52 +0200
x86/mm/KASLR: Reduce randomization granularity for 5-level paging to 1GB
The current randomization granularity of 5-level is 512 GB. The mapping of
the real mode trampoline has been reduced to one PUD entry, so there is no
restriction anymore.
Reduce the granularity to 1GB for 5-level paging mode which allows better
randomization.
[ tglx: Massaged changelog ]
Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: dave.hansen@linux.intel.com
Cc: luto@kernel.org
Cc: peterz@infradead.org
Cc: bp@alien8.de
Cc: hpa@zytor.com
Cc: keescook@chromium.org
Cc: thgarnie@google.com
Link: https://lkml.kernel.org/r/20190308025616.21440-3-bhe@redhat.com
---
arch/x86/mm/kaslr.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)
diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
index 97813751340d..f6ba2791eeb5 100644
--- a/arch/x86/mm/kaslr.c
+++ b/arch/x86/mm/kaslr.c
@@ -125,10 +125,7 @@ void __init kernel_randomize_memory(void)
*/
entropy = remain_entropy / (ARRAY_SIZE(kaslr_regions) - i);
prandom_bytes_state(&rand_state, &rand, sizeof(rand));
- if (pgtable_l5_enabled())
- entropy = (rand % (entropy + 1)) & P4D_MASK;
- else
- entropy = (rand % (entropy + 1)) & PUD_MASK;
+ entropy = (rand % (entropy + 1)) & PUD_MASK;
vaddr += entropy;
*kaslr_regions[i].base = vaddr;
@@ -137,10 +134,7 @@ void __init kernel_randomize_memory(void)
* randomization alignment.
*/
vaddr += get_padding(&kaslr_regions[i]);
- if (pgtable_l5_enabled())
- vaddr = round_up(vaddr + 1, P4D_SIZE);
- else
- vaddr = round_up(vaddr + 1, PUD_SIZE);
+ vaddr = round_up(vaddr + 1, PUD_SIZE);
remain_entropy -= entropy;
}
}
next prev parent reply other threads:[~2019-04-05 20:20 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-08 2:56 [PATCH v3 0/2] x86/mm/KASLR: Change the granularity of randomization to PUD size in 5-level Baoquan He
2019-03-08 2:56 ` [PATCH v3 1/2] x86/mm/KASLR: Only build one PUD entry of area for real mode trampoline Baoquan He
2019-03-12 7:38 ` Kirill A. Shutemov
2019-04-05 20:19 ` [tip:x86/mm] x86/mm/KASLR: Use only one PUD entry " tip-bot for Baoquan He
2019-03-08 2:56 ` [PATCH v3 2/2] x86/mm/KASLR: Change the granularity of randomization to PUD size in 5-level Baoquan He
2019-03-12 7:39 ` Kirill A. Shutemov
2019-04-05 20:19 ` tip-bot for Baoquan He [this message]
2019-04-04 2:18 ` [PATCH v3 0/2] " Baoquan He
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=tip-b569c18434987163a05f05a12cdf6a9975c55ff3@git.kernel.org \
--to=tipbot@zytor.com \
--cc=bhe@redhat.com \
--cc=hpa@zytor.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome