linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Catalin Marinas <catalin.marinas@arm.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Pingfan Liu <kernelfans@gmail.com>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	Will Deacon <will@kernel.org>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	James Morse <james.morse@arm.com>,
	Matthias Brugger <mbrugger@suse.com>
Subject: Re: [PATCH] arm64: mm: assign PXN permission in trans_pgd
Date: Thu, 11 Nov 2021 18:18:17 +0000	[thread overview]
Message-ID: <YY1eacUqllp9S+6A@arm.com> (raw)
In-Reply-To: <CAMj1kXEnzTYvEugk33KCPfPty4JW4SMaY_8sSwvJN=-SvX9sTQ@mail.gmail.com>

On Thu, Nov 11, 2021 at 05:13:02PM +0100, Ard Biesheuvel wrote:
> On Thu, 11 Nov 2021 at 17:09, Catalin Marinas <catalin.marinas@arm.com> wrote:
> > On Thu, Nov 11, 2021 at 02:03:16PM +0800, Pingfan Liu wrote:
> > > diff --git a/arch/arm64/mm/trans_pgd.c b/arch/arm64/mm/trans_pgd.c
> > > index d7da8ca40d2e..7b43d179e94d 100644
> > > --- a/arch/arm64/mm/trans_pgd.c
> > > +++ b/arch/arm64/mm/trans_pgd.c
> > > @@ -67,7 +67,7 @@ static int copy_pte(struct trans_pgd_info *info, pmd_t *dst_pmdp,
> > >       dst_ptep = trans_alloc(info);
> > >       if (!dst_ptep)
> > >               return -ENOMEM;
> > > -     pmd_populate_kernel(NULL, dst_pmdp, dst_ptep);
> > > +     pmd_populate_kernel(&init_mm, dst_pmdp, dst_ptep);
> > >       dst_ptep = pte_offset_kernel(dst_pmdp, start);
> >
> > Commit 5de59884ac0e ("arm64: trans_pgd: pass NULL instead of init_mm to
> > *_populate functions") actually replaced &init_mm with NULL. Commit
> > 59511cfd08f3 ("arm64: mm: use XN table mapping attributes for
> > user/kernel mappings") introduced the VM_BUG_ON.
> >
> > So we either revert Pasha's trans_pgd commit (as per your patch) or we
> > fix Ard's commit to make it aware of a NULL mm and either skip the table
> > UXN altogether or treat it as init_mm.
> >
> 
> That code in pmd_populate_kernel() does not actually *use* the mm
> argument at all, it just BUGs if its value != init_mm. So we can just
> relax the BUG() to disregard mm ==  NULL.

We also have pud_populate() that ends up setting PUD_TABLE_PXN when mm
is NULL. Fortunately we don't execute anything from those mappings, they
are just a copy of the linear map.

BTW, in line with PAGE_KERNEL, pud_populate() could set both UXN and PXN
for init_mm mappings.

-- 
Catalin

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-11-11 18:19 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11  6:03 [PATCH] arm64: mm: assign PXN permission in trans_pgd Pingfan Liu
2021-11-11 16:09 ` Catalin Marinas
2021-11-11 16:13   ` Ard Biesheuvel
2021-11-11 18:18     ` Catalin Marinas [this message]
2021-11-11 18:24       ` Catalin Marinas
2021-11-12  5:18       ` Pingfan Liu
2021-11-12  5:22 ` [PATCHv2] arm64: mm: Fix VM_BUG_ON(mm != &init_mm) for trans_pgd Pingfan Liu
2021-11-12 14:26   ` Catalin Marinas
2021-11-12 14:37   ` Pasha Tatashin
2021-11-16 10:39   ` Will Deacon

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=YY1eacUqllp9S+6A@arm.com \
    --to=catalin.marinas@arm.com \
    --cc=ardb@kernel.org \
    --cc=james.morse@arm.com \
    --cc=kernelfans@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mbrugger@suse.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).