From mboxrd@z Thu Jan 1 00:00:00 1970 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 05F54C433F5 for ; Thu, 11 Nov 2021 16:14:33 +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 B878861247 for ; Thu, 11 Nov 2021 16:14:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B878861247 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Um+6Mr3MGoSU8Aol1jFmJ5xexNfMEpvuUfiFMGaeVCY=; b=o9C2oDA+RBgN9D d76xTLY0dBsX5H2EXNUIX/3gUmCiy+y3Fx90xEC14o1+NhLzIj4bz/07zyKq5GR9QGAvNKn73Nk91 H11jeqJSN3t+5g+KeiPRUqYilspY193k+u41wgqWCYh0r7iI3n+zuwn3ojsJLJpgrFOaGUM3na6Ew HjgqpD/soK+m+DO/4hGS/+6Y22n0SjDIRo06G1VNCLLyyzMajWHYWw3wbWnISiWS9qp4+ChonUvFD H6SApvqMSqtoEaC24pbgrc1wPDueHe6XISVhlMWCoR6s5PzpMMBwei0vIqKm59g4npaCCaMd2+J+k cgSxm4P4+0uKhB7Tw+kg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlChS-008L2z-P6; Thu, 11 Nov 2021 16:13:18 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mlChO-008L2K-ML for linux-arm-kernel@lists.infradead.org; Thu, 11 Nov 2021 16:13:16 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 47A1561247 for ; Thu, 11 Nov 2021 16:13:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1636647194; bh=PSb6fX7PWFyxacHOu2wv+6V8n4X/U3vOYSq5u7rD9cg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ig5wWAEWOY7MKUlRTiMnuq+FVn7MJTfZWpkL070UkJmB/CJcmatJ6Bow18aGvmo1y sKWmFwquOxziIKKanXqXSNICGM28sXot/cKIce2XmCunEnBv5DsZvwsp2SntYfsWeC RSSywdgKfV9rG0r4QFlPGDT4/6NND+4qTEswBkxd7oq/p/WObEnGASS88YRkIHJNhf Ydu1RPLtt99OTlp/QsqyxLi/5zNmoZM7xvQfH9sx7+z8VTqPjVLdPfsBhJSH5Ho7bV 4dibC6xZ86xtUMwvEGrKH5Ub8RvORAu76KJUihFG6iMqc+VZI9kJTbW7nKLM8c66oj kFKRYlyj3u/Xw== Received: by mail-oi1-f181.google.com with SMTP id t19so12493100oij.1 for ; Thu, 11 Nov 2021 08:13:14 -0800 (PST) X-Gm-Message-State: AOAM531em1TkqiRbsxOsFgzlVM2KmSVMrrd9MMU5RK/nu70LH8jIkkBy qe3gRr8CX8DoNNWzXQ8+KB2lD2pEZh2G4VBrFbg= X-Google-Smtp-Source: ABdhPJzOcaUghN+PvFgaXwaOUHtSpL5lqaMIn0uC04VuWP/TAlutAt7N33LHZ15YRFbz0s/nUJm7GtcUNfXlrknb4fo= X-Received: by 2002:aca:ad95:: with SMTP id w143mr19207597oie.47.1636647193558; Thu, 11 Nov 2021 08:13:13 -0800 (PST) MIME-Version: 1.0 References: <20211111060316.12438-1-kernelfans@gmail.com> In-Reply-To: From: Ard Biesheuvel Date: Thu, 11 Nov 2021 17:13:02 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64: mm: assign PXN permission in trans_pgd To: Catalin Marinas Cc: Pingfan Liu , Linux ARM , Will Deacon , Pasha Tatashin , James Morse , Matthias Brugger X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211111_081314_786559_8442F64D X-CRM114-Status: GOOD ( 25.42 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 11 Nov 2021 at 17:09, Catalin Marinas wrote: > > On Thu, Nov 11, 2021 at 02:03:16PM +0800, Pingfan Liu wrote: > > trans_pgd_create_copy() can hit "VM_BUG_ON(mm != &init_mm)" in the > > function pmd_populate_kernel(). > > I think that's more important to fix than the PXN. You may want to > change the subject to something like "Fix VM_BUG_ON ..." > > > 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. > > That's the table PXN, so it's not a big deal if we miss it. > > > 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 > > A Fixes: tag would be nice, we just need to decide which. > > > --- > > 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); > > 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. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel