Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4853474pxj; Wed, 9 Jun 2021 03:35:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmrknEhN4jUpmykf/cXugfybbnVgQEWK2LFLezT7hwWMhfxSxmyghm3KBmsOBaWVissDxY X-Received: by 2002:a17:906:2459:: with SMTP id a25mr27230216ejb.306.1623234958413; Wed, 09 Jun 2021 03:35:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623234958; cv=none; d=google.com; s=arc-20160816; b=XOMlAnzU8AqD7x1jOv0ZC+sYVtea3STjbECV3rPLeV6FW+iu0H2jLM9WE50lHDEert T0WA9H5YfovQtyFvzkEzk0U51vrJLGdlBgq62+AdZAyYGMCT+vM18uH043PjrOgQOFVG Ad79f5pbsVYTh1wKRBrV6gJhGHn7RQ+jovxI1VUV/3SDb/ezsm2robfbBlzadFYm4xln EmhhdylLL7xs/GdqmYqYwp8LePpNUSm2N4XcCL3D75QG1h2UIP3a5P6SmcKouus8IwtY bbtz/rvwvhPA7p/mKoMueJMq/3lRTds16Nyx38HjBSnWCACgITjdnrr8DbfiGf+683nw zePA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oWI+Rf3Ie2qPgVNMuKicY9tO/qGblLnDIVlSJ747Nbs=; b=OyjOjut15Wf61ZdOdZ0ZPLGDeCe3ACW9/3vqOWes/+MaYULpbtlxaQYbxzhnkgu70Y vGY8MrpKqhwmxjD4IM5OLQp7lQVGEEDjhMvInLa+5z1nFWcOjnQRfSezja3uxYkrbmcg 8ELQqdW+3AhdfWYnD0aDwKVcIursDLBX75gE92hOwY79owlpeIpzHtyDIYqwbJnUGqx3 nF2jDvsEZJC368Jd0j4lBwrDO8RNVH361weOrZmv9SOHSbbKDNsg6cDvND+0Qk4WjBrG 6mfaiFrH3uuLZh8y7N28uE5Y+gLlI6mzcUQVARNJHhVxWPtbQVNatZFzs17GKPT2+EOy q7QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=koCluqm8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jz5si2316048ejb.22.2021.06.09.03.35.34; Wed, 09 Jun 2021 03:35:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=koCluqm8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237087AbhFHTJN (ORCPT + 99 others); Tue, 8 Jun 2021 15:09:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:33690 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237340AbhFHTAS (ORCPT ); Tue, 8 Jun 2021 15:00:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 77AE661443; Tue, 8 Jun 2021 18:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623177819; bh=Fb9d/2feoqFWeaeXMZHa35j9HPjekHgnoNpjzgJTVos=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=koCluqm8vhuyuBQxxW2ivChPaBOkBFzdZjz3tW0LMbrMEvz7zs31r5YiwXRZpGMG6 OlAbW3qSbDJym0m7llnRA87pl2vdlfhA01EvVWWJGeuiU099nmy/ddyx2w28nw04kN NpgI15FGn/02zmKXzNg1ZvLSqQxakuPFh92gpi00= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gerald Schaefer , Anshuman Khandual , Vineet Gupta , Palmer Dabbelt , Paul Walmsley , Andrew Morton , Linus Torvalds Subject: [PATCH 5.10 110/137] mm/debug_vm_pgtable: fix alignment for pmd/pud_advanced_tests() Date: Tue, 8 Jun 2021 20:27:30 +0200 Message-Id: <20210608175946.103539340@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210608175942.377073879@linuxfoundation.org> References: <20210608175942.377073879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Gerald Schaefer commit 04f7ce3f07ce39b1a3ca03a56b238a53acc52cfd upstream. 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. Link: https://lkml.kernel.org/r/20210525130043.186290-2-gerald.schaefer@linux.ibm.com Fixes: a5c3b9ffb0f40 ("mm/debug_vm_pgtable: add tests validating advanced arch page table helpers") Signed-off-by: Gerald Schaefer Reviewed-by: Anshuman Khandual Cc: Vineet Gupta Cc: Palmer Dabbelt Cc: Paul Walmsley Cc: [5.9+] Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/debug_vm_pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/mm/debug_vm_pgtable.c +++ b/mm/debug_vm_pgtable.c @@ -163,7 +163,7 @@ static void __init pmd_advanced_tests(st 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); @@ -285,7 +285,7 @@ static void __init pud_advanced_tests(st 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; set_pud_at(mm, vaddr, pudp, pud); pudp_set_wrprotect(mm, vaddr, pudp);