From: tip-bot for Joerg Roedel <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jroedel@suse.de, luto@kernel.org, jkosina@suse.cz, pavel@ucw.cz,
peterz@infradead.org, llong@redhat.com, brgerst@gmail.com,
hpa@zytor.com, gregkh@linuxfoundation.org, mingo@kernel.org,
boris.ostrovsky@oracle.com, dhgutteridge@sympatico.ca,
jgross@suse.com, linux-kernel@vger.kernel.org,
dave.hansen@intel.com, aarcange@redhat.com, bp@alien8.de,
David.Laight@aculab.com, will.deacon@arm.com, tglx@linutronix.de,
eduval@amazon.com, torvalds@linux-foundation.org,
dvlasenk@redhat.com, jpoimboe@redhat.com
Subject: [tip:x86/pti] x86/mm/pti: Don't clear permissions in pti_clone_pmd()
Date: Tue, 7 Aug 2018 14:45:51 -0700 [thread overview]
Message-ID: <tip-30514effc9206d4e084ec32239ae221db157d43a@git.kernel.org> (raw)
In-Reply-To: <1533637471-30953-3-git-send-email-joro@8bytes.org>
Commit-ID: 30514effc9206d4e084ec32239ae221db157d43a
Gitweb: https://git.kernel.org/tip/30514effc9206d4e084ec32239ae221db157d43a
Author: Joerg Roedel <jroedel@suse.de>
AuthorDate: Tue, 7 Aug 2018 12:24:30 +0200
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 7 Aug 2018 23:36:02 +0200
x86/mm/pti: Don't clear permissions in pti_clone_pmd()
The function sets the global-bit on cloned PMD entries, which only makes
sense when the permissions are identical between the user and the kernel
page-table. Further, only write-permissions are cleared for entry-text and
kernel-text sections, which are not writeable at the end of the boot
process.
The reason why this RW clearing exists is that in the early PTI
implementations the cloned kernel areas were set up during early boot
before the kernel text is set to read only and not touched afterwards.
This is not longer true. The cloned areas are still set up early to get the
entry code working for interrupts and other things, but after the kernel
text has been set RO the clone is repeated which copies the RO PMD/PTEs
over to the user visible clone. That means the initial clearing of the
writable bit can be avoided.
[ tglx: Amended changelog ]
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Dave Hansen <dave.hansen@intel.com>
Cc: "H . Peter Anvin" <hpa@zytor.com>
Cc: linux-mm@kvack.org
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Jiri Kosina <jkosina@suse.cz>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: David Laight <David.Laight@aculab.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Eduardo Valentin <eduval@amazon.com>
Cc: Greg KH <gregkh@linuxfoundation.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: aliguori@amazon.com
Cc: daniel.gruss@iaik.tugraz.at
Cc: hughd@google.com
Cc: keescook@google.com
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Waiman Long <llong@redhat.com>
Cc: Pavel Machek <pavel@ucw.cz>
Cc: "David H . Gutteridge" <dhgutteridge@sympatico.ca>
Cc: joro@8bytes.org
Link: https://lkml.kernel.org/r/1533637471-30953-3-git-send-email-joro@8bytes.org
---
arch/x86/mm/pti.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index 113ba14a03d8..5164c987b1f1 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -291,7 +291,7 @@ static void __init pti_setup_vsyscall(void) { }
#endif
static void
-pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
+pti_clone_pmds(unsigned long start, unsigned long end)
{
unsigned long addr;
@@ -352,7 +352,7 @@ pti_clone_pmds(unsigned long start, unsigned long end, pmdval_t clear)
* tables will share the last-level page tables of this
* address range
*/
- *target_pmd = pmd_clear_flags(*pmd, clear);
+ *target_pmd = *pmd;
}
}
@@ -398,7 +398,7 @@ static void __init pti_clone_user_shared(void)
start = CPU_ENTRY_AREA_BASE;
end = start + (PAGE_SIZE * CPU_ENTRY_AREA_PAGES);
- pti_clone_pmds(start, end, 0);
+ pti_clone_pmds(start, end);
}
#endif /* CONFIG_X86_64 */
@@ -418,8 +418,7 @@ static void __init pti_setup_espfix64(void)
static void pti_clone_entry_text(void)
{
pti_clone_pmds((unsigned long) __entry_text_start,
- (unsigned long) __irqentry_text_end,
- _PAGE_RW);
+ (unsigned long) __irqentry_text_end);
}
/*
@@ -501,7 +500,7 @@ static void pti_clone_kernel_text(void)
* pti_set_kernel_image_nonglobal() did to clear the
* global bit.
*/
- pti_clone_pmds(start, end_clone, _PAGE_RW);
+ pti_clone_pmds(start, end_clone);
/*
* pti_clone_pmds() will set the global bit in any PMDs
next prev parent reply other threads:[~2018-08-07 21:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-07 10:24 [PATCH 0/3] PTI for x86-32 Fixes Joerg Roedel
2018-08-07 10:24 ` [PATCH 1/3] x86/mm/pti: Fix 32 bit PCID check Joerg Roedel
2018-08-07 16:55 ` [tip:x86/pti] " tip-bot for Joerg Roedel
2018-08-07 10:24 ` [PATCH 2/3] x86/mm/pti: Don't clear permissions in pti_clone_pmd() Joerg Roedel
2018-08-07 18:34 ` Dave Hansen
2018-08-07 19:38 ` Andy Lutomirski
2018-08-07 20:21 ` Thomas Gleixner
2018-08-07 20:28 ` Andy Lutomirski
2018-08-07 21:45 ` tip-bot for Joerg Roedel [this message]
2018-08-07 10:24 ` [PATCH 3/3] x86/mm/pti: Clone kernel-image on PTE level for 32 bit Joerg Roedel
2018-08-07 21:46 ` [tip:x86/pti] " tip-bot for Joerg Roedel
2018-08-17 2:44 ` [PATCH 0/3] PTI for x86-32 Fixes David H. Gutteridge
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-30514effc9206d4e084ec32239ae221db157d43a@git.kernel.org \
--to=tipbot@zytor.com \
--cc=David.Laight@aculab.com \
--cc=aarcange@redhat.com \
--cc=boris.ostrovsky@oracle.com \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=dave.hansen@intel.com \
--cc=dhgutteridge@sympatico.ca \
--cc=dvlasenk@redhat.com \
--cc=eduval@amazon.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=jkosina@suse.cz \
--cc=jpoimboe@redhat.com \
--cc=jroedel@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=llong@redhat.com \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=will.deacon@arm.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