linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lai Jiangshan <jiangshanlai@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Lai Jiangshan <laijs@linux.alibaba.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	X86 ML <x86@kernel.org>, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH 1/2] x86/mm/pti: Check unaligned address for pmd clone in pti_clone_pagetable()
Date: Wed, 2 Dec 2020 16:55:29 +0800	[thread overview]
Message-ID: <CAJhGHyAPE4JSUr6za5HJe9ePhRmAgAXX-yLhAqEHWvRWs+1Upg@mail.gmail.com> (raw)
In-Reply-To: <0766416e-bab5-c8e7-9466-a72e965fdb8a@intel.com>

On Wed, Dec 2, 2020 at 1:43 AM Dave Hansen <dave.hansen@intel.com> wrote:
>
> On 11/30/20 7:25 AM, Lai Jiangshan wrote:
> > The commit 825d0b73cd752("x86/mm/pti: Handle unaligned address gracefully
> > in pti_clone_pagetable()") handles unaligned address well for unmapped
> > PUD/PMD etc. But unaligned address for pmd_large() or PTI_CLONE_PMD is also
> > needed to be aware.
>
> That 825d0b73cd752 changelog says:
>
> >     pti_clone_pmds() assumes that the supplied address is either:
> >
> >      - properly PUD/PMD aligned
> >     or
> >      - the address is actually mapped which means that independently
> >        of the mapping level (PUD/PMD/PTE) the next higher mapping
> >        exists.
>
> ... and that was the root of the bug.  If there was a large, unmapped
> area, it would skip a PUD_SIZE or PMD_SIZE *area* instead of skipping to
> the *next* pud/pmd.
>
> The case being patched here is from a *present* PTE/PMD, so it's a
> mapped area, not a hole.
>
> That said, I think the previous changelog was wrong.  An unaligned
> address to a mapped, large (2M) region followed by a smaller (4k) region
> would skip too far into the 4k region.
>
> That said, I'm not sure I like this fix.  If someone is explicitly
> asking to clone a PMD (which pti_clone_pgtable() forces you to do), they
> better align the address.

Hello, Dave

I think I got what you mean more or less, but I don't think I can
update the patch to address all your concerns and requirements.

I know very little about the area.

Could you make new patches to replace mine.

Thanks
Lai.

  reply	other threads:[~2020-12-02  8:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-30 15:25 [PATCH 1/2] x86/mm/pti: Check unaligned address for pmd clone in pti_clone_pagetable() Lai Jiangshan
2020-11-30 15:25 ` [PATCH 2/2] x86/mm/pti: warn and stop when pti_clone_pagetable() is on 1G page Lai Jiangshan
2020-11-30 16:37   ` Dave Hansen
2020-12-01 17:43 ` [PATCH 1/2] x86/mm/pti: Check unaligned address for pmd clone in pti_clone_pagetable() Dave Hansen
2020-12-02  8:55   ` Lai Jiangshan [this message]
2020-12-10 14:35   ` [PATCH V2 1/3] x86/mm/pti: handle " Lai Jiangshan
2020-12-10 14:35     ` [PATCH V2 2/3] x86/mm/pti: issue warning when mapping large pmd beyond specifid range Lai Jiangshan
2020-12-10 14:35     ` [PATCH V2 3/3] x86/mm/pti: warn and stop when pti_clone_pagetable() is on 1G page Lai Jiangshan
2020-12-18 13:00     ` [PATCH V2 1/3] x86/mm/pti: handle unaligned address for pmd clone in pti_clone_pagetable() Lai Jiangshan

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=CAJhGHyAPE4JSUr6za5HJe9ePhRmAgAXX-yLhAqEHWvRWs+1Upg@mail.gmail.com \
    --to=jiangshanlai@gmail.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=laijs@linux.alibaba.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=x86@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).