From patchwork Thu Nov 11 06:03:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingfan Liu X-Patchwork-Id: 12692274 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C32FC433F5 for ; Thu, 11 Nov 2021 06:05:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C844D61159 for ; Thu, 11 Nov 2021 06:05:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C844D61159 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=R5c02CkGrviiCrPDUrLgMRpz59QU0xzKfsRs/1YmSYU=; b=4OljLbmhxZ4s2d 7cKJuypVn0JlozhI44eDOXlPjzIsv+eD+//pjw3pnUduwc9Hr8D8JwLSQrt7iG3c9SizzLHlTxhYf srwxOS9pekhCmcjLpupVAuANMshbzc0FKDvEypBGLwmk5xz2k/3jg/OzXWk5IJrAWCOaY+oE0jrYU vS+xYQY7ITXE+lmZiXbUKu45uxHDrNY15wLau0bAUlGAbm1e59frzRcfQkZfXBFA/k9MhPmIRBuK1 xyWHUB7TQkMnEy12RO7ph1vq7X/pDV/I7C4Zkk4GqP1Jx3J0EfEmeHnuXs0OSwFHQcrOiXcmO7Qca ZgV0ZSalOZzLkYh84FaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ml3BS-007HfV-Gu; Thu, 11 Nov 2021 06:03:38 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ml3BO-007HfB-MX for linux-arm-kernel@lists.infradead.org; Thu, 11 Nov 2021 06:03:35 +0000 Received: by mail-pg1-x52b.google.com with SMTP id f5so4251540pgc.12 for ; Wed, 10 Nov 2021 22:03:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XzX30iWMWCBcMzK8FZVaBq+tV5B7ptnZqGxSQc7tO3c=; b=QRUQdiZDeZV3ESPyinqxzISlcm7hJ8zxlRE5ko6f4pZwQnjmQhnYikl+3OJLxxX6T/ kCl9vSER7tKhvywVovjGF8s0cdRLJZP+1Li4EUo+EW3z/N9yh29Ez2Pn+94oYB0AxXQ9 uXnA2foE10Do0Q0Z86jjyGkv3Hyva/ZR4ovU/88n0DF9a1+misW16un/23NkvRRZdaU1 LpGnTYcNqWzSoOcpZh8tlp8H6/DWien2zRsqhk8lsB3+WVUKsOrVjAOAB24CQZtt7cq5 /ecptBxvMJvRAKSxaBBF5el7OV+tBFJ8LGRpfqsA/rS0DCtjbysVOHZghebc6INIJ/SU AGZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XzX30iWMWCBcMzK8FZVaBq+tV5B7ptnZqGxSQc7tO3c=; b=XwRCCDkamWPr/dyTmZmVRaruolGMISa4h0i9h30qfsRMc2wLniBcWrFBjz7KTo56Fc AChnORbmdYi2qrrJ6dytlpcpdBRuzPqL280Ngjlq0uccKiNsS1SU7PAR/fOf+84tc9hp Wv7UMOcOJyLOq4RIt/bjhzs5H0e7N4LUFD7scZD+ZusEGw3DVp5X5h+sZZbDdjbTBeCS zyvi7e3XHo11oAgnkavYMWxJOBqEmwYP8XRxFiY5/rRmfnuimhqSE/6ERQ45Qqd3FgYZ sW0OM8hAE8wFgbqo4vytNvrot0/Ps7XX9twBQdtovgCoXEvPvmnUpRA+YhJ38Gk9NEQd ZjTw== X-Gm-Message-State: AOAM531ycHzur5kK1C4xcEc+vZiM8PRhNgqjvIKBe5CTCUKHtNWRWGZ1 jNodlAcANdngZjevF2yn3mUAR8wO+A== X-Google-Smtp-Source: ABdhPJzQB51VjyMdjLOL7SZE6krEuAtRL43+MRwvdU914lPbtafl+SCnpJrZAvX8BWh/kN8i8QOBCg== X-Received: by 2002:a63:145d:: with SMTP id 29mr3107203pgu.264.1636610611686; Wed, 10 Nov 2021 22:03:31 -0800 (PST) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id lx15sm1303084pjb.44.2021.11.10.22.03.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 22:03:31 -0800 (PST) From: Pingfan Liu To: linux-arm-kernel@lists.infradead.org Cc: Pingfan Liu , Catalin Marinas , Will Deacon , Pasha Tatashin , James Morse , Matthias Brugger Subject: [PATCH] arm64: mm: assign PXN permission in trans_pgd Date: Thu, 11 Nov 2021 14:03:16 +0800 Message-Id: <20211111060316.12438-1-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211110_220334_785682_F92BB100 X-CRM114-Status: GOOD ( 11.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org trans_pgd_create_copy() can hit "VM_BUG_ON(mm != &init_mm)" in the function pmd_populate_kernel(). p?d_populate() helpers resort to the input parameter mm_struct to decide the attribute: UXN or PXN. And plus the fact, either hibernation or kexec runs in privilege mode. So the bug can be fixed by assigning &init_mm to the callsites of these helpers. Signed-off-by: Pingfan Liu Cc: Catalin Marinas Cc: Will Deacon Cc: Pasha Tatashin Cc: James Morse Cc: Matthias Brugger To: linux-arm-kernel@lists.infradead.org --- arch/arm64/mm/trans_pgd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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); src_ptep = pte_offset_kernel(src_pmdp, start); @@ -90,7 +90,7 @@ static int copy_pmd(struct trans_pgd_info *info, pud_t *dst_pudp, dst_pmdp = trans_alloc(info); if (!dst_pmdp) return -ENOMEM; - pud_populate(NULL, dst_pudp, dst_pmdp); + pud_populate(&init_mm, dst_pudp, dst_pmdp); } dst_pmdp = pmd_offset(dst_pudp, start); @@ -126,7 +126,7 @@ static int copy_pud(struct trans_pgd_info *info, p4d_t *dst_p4dp, dst_pudp = trans_alloc(info); if (!dst_pudp) return -ENOMEM; - p4d_populate(NULL, dst_p4dp, dst_pudp); + p4d_populate(&init_mm, dst_p4dp, dst_pudp); } dst_pudp = pud_offset(dst_p4dp, start);