All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tycho Andersen <tycho@docker.com>
To: Laura Abbott <labbott@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kernel-hardening@lists.openwall.com,
	Marco Benatto <marco.antonio.780@gmail.com>,
	Juerg Haefliger <juerg.haefliger@canonical.com>
Subject: Re: [kernel-hardening] [PATCH v5 06/10] arm64/mm: Disable section mappings if XPFO is enabled
Date: Fri, 11 Aug 2017 15:13:02 -0600	[thread overview]
Message-ID: <20170811211302.limmjv4rmq23b25b@smitten> (raw)
In-Reply-To: <f6a42032-d4e5-f488-3d55-1da4c8a4dbaf@redhat.com>

Hi Laura,

On Fri, Aug 11, 2017 at 10:25:14AM -0700, Laura Abbott wrote:
> On 08/09/2017 01:07 PM, Tycho Andersen wrote:
> > From: Juerg Haefliger <juerg.haefliger@hpe.com>
> > 
> > XPFO (eXclusive Page Frame Ownership) doesn't support section mappings
> > yet, so disable it if XPFO is turned on.
> > 
> > Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
> > Tested-by: Tycho Andersen <tycho@docker.com>
> > ---
> >  arch/arm64/mm/mmu.c | 14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> > index f1eb15e0e864..38026b3ccb46 100644
> > --- a/arch/arm64/mm/mmu.c
> > +++ b/arch/arm64/mm/mmu.c
> > @@ -176,6 +176,18 @@ static void alloc_init_cont_pte(pmd_t *pmd, unsigned long addr,
> >  	} while (addr = next, addr != end);
> >  }
> >  
> > +static inline bool use_section_mapping(unsigned long addr, unsigned long next,
> > +				unsigned long phys)
> > +{
> > +	if (IS_ENABLED(CONFIG_XPFO))
> > +		return false;
> > +
> > +	if (((addr | next | phys) & ~SECTION_MASK) != 0)
> > +		return false;
> > +
> > +	return true;
> > +}
> > +
> >  static void init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
> >  		     phys_addr_t phys, pgprot_t prot,
> >  		     phys_addr_t (*pgtable_alloc)(void), int flags)
> > @@ -190,7 +202,7 @@ static void init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
> >  		next = pmd_addr_end(addr, end);
> >  
> >  		/* try section mapping first */
> > -		if (((addr | next | phys) & ~SECTION_MASK) == 0 &&
> > +		if (use_section_mapping(addr, next, phys) &&
> >  		    (flags & NO_BLOCK_MAPPINGS) == 0) {
> >  			pmd_set_huge(pmd, phys, prot);
> >  
> > 
> 
> There is already similar logic to disable section mappings for
> debug_pagealloc at the start of map_mem, can you take advantage
> of that?

You're suggesting something like this instead? Seems to work fine.

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 38026b3ccb46..3b2c17bbbf12 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -434,6 +434,8 @@ static void __init map_mem(pgd_t *pgd)
 
 	if (debug_pagealloc_enabled())
 		flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
+	if (IS_ENABLED(CONFIG_XPFO))
+		flags |= NO_BLOCK_MAPPINGS;
 
 	/*
 	 * Take care not to create a writable alias for the

Cheers,

Tycho

WARNING: multiple messages have this Message-ID (diff)
From: Tycho Andersen <tycho@docker.com>
To: Laura Abbott <labbott@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	kernel-hardening@lists.openwall.com,
	Marco Benatto <marco.antonio.780@gmail.com>,
	Juerg Haefliger <juerg.haefliger@canonical.com>
Subject: Re: [kernel-hardening] [PATCH v5 06/10] arm64/mm: Disable section mappings if XPFO is enabled
Date: Fri, 11 Aug 2017 15:13:02 -0600	[thread overview]
Message-ID: <20170811211302.limmjv4rmq23b25b@smitten> (raw)
In-Reply-To: <f6a42032-d4e5-f488-3d55-1da4c8a4dbaf@redhat.com>

Hi Laura,

On Fri, Aug 11, 2017 at 10:25:14AM -0700, Laura Abbott wrote:
> On 08/09/2017 01:07 PM, Tycho Andersen wrote:
> > From: Juerg Haefliger <juerg.haefliger@hpe.com>
> > 
> > XPFO (eXclusive Page Frame Ownership) doesn't support section mappings
> > yet, so disable it if XPFO is turned on.
> > 
> > Signed-off-by: Juerg Haefliger <juerg.haefliger@canonical.com>
> > Tested-by: Tycho Andersen <tycho@docker.com>
> > ---
> >  arch/arm64/mm/mmu.c | 14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
> > index f1eb15e0e864..38026b3ccb46 100644
> > --- a/arch/arm64/mm/mmu.c
> > +++ b/arch/arm64/mm/mmu.c
> > @@ -176,6 +176,18 @@ static void alloc_init_cont_pte(pmd_t *pmd, unsigned long addr,
> >  	} while (addr = next, addr != end);
> >  }
> >  
> > +static inline bool use_section_mapping(unsigned long addr, unsigned long next,
> > +				unsigned long phys)
> > +{
> > +	if (IS_ENABLED(CONFIG_XPFO))
> > +		return false;
> > +
> > +	if (((addr | next | phys) & ~SECTION_MASK) != 0)
> > +		return false;
> > +
> > +	return true;
> > +}
> > +
> >  static void init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
> >  		     phys_addr_t phys, pgprot_t prot,
> >  		     phys_addr_t (*pgtable_alloc)(void), int flags)
> > @@ -190,7 +202,7 @@ static void init_pmd(pud_t *pud, unsigned long addr, unsigned long end,
> >  		next = pmd_addr_end(addr, end);
> >  
> >  		/* try section mapping first */
> > -		if (((addr | next | phys) & ~SECTION_MASK) == 0 &&
> > +		if (use_section_mapping(addr, next, phys) &&
> >  		    (flags & NO_BLOCK_MAPPINGS) == 0) {
> >  			pmd_set_huge(pmd, phys, prot);
> >  
> > 
> 
> There is already similar logic to disable section mappings for
> debug_pagealloc at the start of map_mem, can you take advantage
> of that?

You're suggesting something like this instead? Seems to work fine.

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 38026b3ccb46..3b2c17bbbf12 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -434,6 +434,8 @@ static void __init map_mem(pgd_t *pgd)
 
 	if (debug_pagealloc_enabled())
 		flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
+	if (IS_ENABLED(CONFIG_XPFO))
+		flags |= NO_BLOCK_MAPPINGS;
 
 	/*
 	 * Take care not to create a writable alias for the

Cheers,

Tycho

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2017-08-11 21:13 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-09 20:07 [PATCH v5 00/10] Add support for eXclusive Page Frame Ownership Tycho Andersen
2017-08-09 20:07 ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07 ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 01/10] mm: add MAP_HUGETLB support to vm_mmap Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 02/10] mm, x86: Add support for eXclusive Page Frame Ownership (XPFO) Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-14 18:51   ` Laura Abbott
2017-08-14 18:51     ` [kernel-hardening] " Laura Abbott
2017-08-14 18:51     ` Laura Abbott
2017-08-14 22:30   ` Laura Abbott
2017-08-14 22:30     ` [kernel-hardening] " Laura Abbott
2017-08-14 22:30     ` Laura Abbott
2017-08-15  3:47     ` Tycho Andersen
2017-08-15  3:47       ` [kernel-hardening] " Tycho Andersen
2017-08-15  3:47       ` Tycho Andersen
2017-08-15  3:51       ` Tycho Andersen
2017-08-15  3:51         ` [kernel-hardening] " Tycho Andersen
2017-08-15  3:51         ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 03/10] swiotlb: Map the buffer if it was unmapped by XPFO Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-10 13:01   ` Konrad Rzeszutek Wilk
2017-08-10 13:01     ` [kernel-hardening] " Konrad Rzeszutek Wilk
2017-08-10 13:01     ` Konrad Rzeszutek Wilk
2017-08-10 16:22     ` Tycho Andersen
2017-08-10 16:22       ` [kernel-hardening] " Tycho Andersen
2017-08-10 16:22       ` Tycho Andersen
2017-09-20 16:19   ` Dave Hansen
2017-09-20 16:19     ` [kernel-hardening] " Dave Hansen
2017-09-20 16:19     ` Dave Hansen
2017-09-20 22:47     ` Tycho Andersen
2017-09-20 22:47       ` [kernel-hardening] " Tycho Andersen
2017-09-20 22:47       ` Tycho Andersen
2017-09-20 23:25       ` Dave Hansen
2017-09-20 23:25         ` [kernel-hardening] " Dave Hansen
2017-09-20 23:25         ` Dave Hansen
2017-08-09 20:07 ` [PATCH v5 04/10] arm64: Add __flush_tlb_one() Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-12 11:26   ` [kernel-hardening] " Mark Rutland
2017-08-12 11:26     ` Mark Rutland
2017-08-14 16:35     ` Tycho Andersen
2017-08-14 16:35       ` Tycho Andersen
2017-08-14 16:50       ` Mark Rutland
2017-08-14 16:50         ` Mark Rutland
2017-08-14 17:01         ` Tycho Andersen
2017-08-14 17:01           ` Tycho Andersen
2017-08-23 16:58         ` Tycho Andersen
2017-08-23 16:58           ` Tycho Andersen
2017-08-23 17:04           ` Mark Rutland
2017-08-23 17:04             ` Mark Rutland
2017-08-23 17:13             ` Tycho Andersen
2017-08-23 17:13               ` Tycho Andersen
2017-08-24 15:45               ` Mark Rutland
2017-08-24 15:45                 ` Mark Rutland
2017-08-29 17:24                 ` Tycho Andersen
2017-08-29 17:24                   ` Tycho Andersen
2017-08-30  5:31             ` Juerg Haefliger
2017-08-30 16:47               ` Tycho Andersen
2017-08-30 16:47                 ` Tycho Andersen
2017-08-31  9:43                 ` Juerg Haefliger
2017-08-31  9:47                   ` Mark Rutland
2017-08-31  9:47                     ` Mark Rutland
2017-08-31 21:21                     ` Tycho Andersen
2017-08-31 21:21                       ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 05/10] arm64/mm: Add support for XPFO Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-11 18:01   ` [kernel-hardening] " Laura Abbott
2017-08-11 18:01     ` Laura Abbott
2017-08-11 20:19     ` Tycho Andersen
2017-08-11 20:19       ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 06/10] arm64/mm: Disable section mappings if XPFO is enabled Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-11 17:25   ` [kernel-hardening] " Laura Abbott
2017-08-11 17:25     ` Laura Abbott
2017-08-11 21:13     ` Tycho Andersen [this message]
2017-08-11 21:13       ` Tycho Andersen
2017-08-11 21:52       ` Tycho Andersen
2017-08-11 21:52         ` Tycho Andersen
2017-08-12 11:17       ` Mark Rutland
2017-08-12 11:17         ` Mark Rutland
2017-08-14 16:22         ` Tycho Andersen
2017-08-14 16:22           ` Tycho Andersen
2017-08-14 18:42           ` Laura Abbott
2017-08-14 18:42             ` Laura Abbott
2017-08-14 20:28             ` Tycho Andersen
2017-08-14 20:28               ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 07/10] arm64/mm: Don't flush the data cache if the page is unmapped by XPFO Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-12 11:57   ` [kernel-hardening] " Mark Rutland
2017-08-12 11:57     ` Mark Rutland
2017-08-14 16:54     ` Mark Rutland
2017-08-14 16:54       ` Mark Rutland
2017-08-14 20:27     ` Tycho Andersen
2017-08-14 20:27       ` Tycho Andersen
2017-08-15  9:39       ` Mark Rutland
2017-08-15  9:39         ` Mark Rutland
2017-08-09 20:07 ` [PATCH v5 08/10] arm64/mm: Add support for XPFO to swiotlb Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-10 13:11   ` Konrad Rzeszutek Wilk
2017-08-10 13:11     ` [kernel-hardening] " Konrad Rzeszutek Wilk
2017-08-10 13:11     ` Konrad Rzeszutek Wilk
2017-08-10 16:35     ` Tycho Andersen
2017-08-10 16:35       ` [kernel-hardening] " Tycho Andersen
2017-08-10 16:35       ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 09/10] mm: add a user_virt_to_phys symbol Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-09 20:07 ` [PATCH v5 10/10] lkdtm: Add test for XPFO Tycho Andersen
2017-08-09 20:07   ` [kernel-hardening] " Tycho Andersen
2017-08-09 20:07   ` Tycho Andersen
2017-08-12 20:24   ` kbuild test robot
2017-08-12 20:24     ` [kernel-hardening] " kbuild test robot
2017-08-12 20:24     ` kbuild test robot
2017-08-14 16:21     ` Tycho Andersen
2017-08-14 16:21       ` [kernel-hardening] " Tycho Andersen
2017-08-14 16:21       ` Tycho Andersen
2017-08-12 21:05   ` kbuild test robot
2017-08-12 21:05     ` [kernel-hardening] " kbuild test robot
2017-08-12 21:05     ` kbuild test robot
2017-08-14 19:10   ` Kees Cook
2017-08-14 19:10     ` [kernel-hardening] " Kees Cook
2017-08-14 19:10     ` Kees Cook
2017-08-14 20:29     ` Tycho Andersen
2017-08-14 20:29       ` [kernel-hardening] " Tycho Andersen
2017-08-14 20:29       ` Tycho Andersen
2017-08-11 23:35 ` [kernel-hardening] [PATCH v5 00/10] Add support for eXclusive Page Frame Ownership Laura Abbott
2017-08-11 23:35   ` Laura Abbott

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=20170811211302.limmjv4rmq23b25b@smitten \
    --to=tycho@docker.com \
    --cc=juerg.haefliger@canonical.com \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=labbott@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=marco.antonio.780@gmail.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 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.