linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anshuman Khandual <anshuman.khandual@arm.com>
To: Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>,
	linux-arch <linux-arch@vger.kernel.org>,
	linux-sparc <sparclinux@vger.kernel.org>,
	linux-s390 <linux-s390@vger.kernel.org>,
	stable@vger.kernel.org, Vineet Gupta <vgupta@synopsys.com>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Paul Walmsley <paul.walmsley@sifive.com>
Subject: Re: [PATCH 1/1] mm/debug_vm_pgtable: fix alignment for pmd/pud_advanced_tests()
Date: Wed, 26 May 2021 10:10:06 +0530	[thread overview]
Message-ID: <53271f1e-51e3-7673-b58b-0bfe65ffde94@arm.com> (raw)
In-Reply-To: <20210525130043.186290-2-gerald.schaefer@linux.ibm.com>


On 5/25/21 6:30 PM, Gerald Schaefer wrote:
> In pmd/pud_advanced_tests(), the vaddr is aligned up to the next pmd/pud
> entry, and so it does not match the given pmdp/pudp and (aligned down) pfn
> any more.
> 
> For s390, this results in memory corruption, because the IDTE instruction
> used e.g. in xxx_get_and_clear() will take the vaddr for some calculations,
> in combination with the given pmdp. It will then end up with a wrong table
> origin, ending on ...ff8, and some of those wrongly set low-order bits will
> also select a wrong pagetable level for the index addition. IDTE could
> therefore invalidate (or 0x20) something outside of the page tables,
> depending on the wrongly picked index, which in turn depends on the random
> vaddr.
> 
> As result, we sometimes see "BUG task_struct (Not tainted): Padding
> overwritten" on s390, where one 0x5a padding value got overwritten with
> 0x7a.
> 
> Fix this by aligning down, similar to how the pmd/pud_aligned pfns are
> calculated.
> 
> Fixes: a5c3b9ffb0f40 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers")
> Cc: <stable@vger.kernel.org> # v5.9+
> Signed-off-by: Gerald Schaefer <gerald.schaefer@linux.ibm.com>

Did not see any problem on arm64 or x86, builds okay across all
supported platforms. It would be great, if folks could test this
on remaining platforms i.e arc, riscv etc.

+ Vineet Gupta <vgupta@synopsys.com>
+ Palmer Dabbelt <palmer@dabbelt.com>
+ Paul Walmsley <paul.walmsley@sifive.com>

Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com>

> ---
>  mm/debug_vm_pgtable.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c
> index 6ff92c8b0a00..f7b23565a04f 100644
> --- a/mm/debug_vm_pgtable.c
> +++ b/mm/debug_vm_pgtable.c
> @@ -193,7 +193,7 @@ static void __init pmd_advanced_tests(struct mm_struct *mm,
>  
>  	pr_debug("Validating PMD advanced\n");
>  	/* Align the address wrt HPAGE_PMD_SIZE */
> -	vaddr = (vaddr & HPAGE_PMD_MASK) + HPAGE_PMD_SIZE;
> +	vaddr &= HPAGE_PMD_MASK;
>  
>  	pgtable_trans_huge_deposit(mm, pmdp, pgtable);
>  
> @@ -318,7 +318,7 @@ static void __init pud_advanced_tests(struct mm_struct *mm,
>  
>  	pr_debug("Validating PUD advanced\n");
>  	/* Align the address wrt HPAGE_PUD_SIZE */
> -	vaddr = (vaddr & HPAGE_PUD_MASK) + HPAGE_PUD_SIZE;
> +	vaddr &= HPAGE_PUD_MASK;
>  
>  	pud = pfn_pud(pfn, prot);
>  	set_pud_at(mm, vaddr, pudp, pud);
> 

  reply	other threads:[~2021-05-26  4:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-25 13:00 [PATCH 0/1] mm/debug_vm_pgtable: fix alignment for pmd/pud_advanced_tests() Gerald Schaefer
2021-05-25 13:00 ` [PATCH 1/1] " Gerald Schaefer
2021-05-26  4:40   ` Anshuman Khandual [this message]
2021-05-26 11:27   ` Anatoly Pugachev
2021-05-26 12:36     ` Anshuman Khandual
2021-05-26 13:36       ` Anatoly Pugachev
2021-05-26  4:24 ` [PATCH 0/1] " Anshuman Khandual

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=53271f1e-51e3-7673-b58b-0bfe65ffde94@arm.com \
    --to=anshuman.khandual@arm.com \
    --cc=akpm@linux-foundation.org \
    --cc=gerald.schaefer@linux.ibm.com \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=sparclinux@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vgupta@synopsys.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;
as well as URLs for NNTP newsgroup(s).