Received: by 10.213.65.68 with SMTP id h4csp433099imn; Tue, 13 Mar 2018 08:55:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELt/5rYcrFqUJDnmY78GzB52nxp7dSTnKDwKUFYBWTRY54d2nf6cHD3QuRr+cYXP8geVn1cU X-Received: by 10.98.76.215 with SMTP id e84mr1084794pfj.45.1520956500651; Tue, 13 Mar 2018 08:55:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520956500; cv=none; d=google.com; s=arc-20160816; b=RNrCW6iJl4RX8JL2lquiIxs+Br0lLs1+qwbINIBl+VcCfZeY6wrlEbx33Z8k3d1mJ7 WEhDyi2tvVn1hWL0UkB1l1jsFYyc206wAWLnckAZMOmI1GxOl+mHQaMmkmHMVl8p0IhP QSCzRxK9KZMwFcDk0Y67NlPza0yTSMbwzDuP54/GLxDMjCzbTmew3crcuS1mgMUc7nNk tVYfUBegsUoMe7vn766I9fzGCz5WY67gs8hTtJiWN+absoB8ucgKdoRMYhI5KSIafWPP 5g/OBZ7zc1/lVhUfUpjepMPFpdYuBAI8gFHy2fSV8fFCTE8WMxwCqrtwGV4VX7jzitp+ ghtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=pfNHV4DohaURF2uPOj/FYB2YF5DT5NClVHLICPcd5oQ=; b=ELhVPXEohLD0AhTpk7hq9wk2de5khP9UVnlnXcwWZuYqY4wtPSCqNWMgD9aAFqbTUq nch0da2YNtIsGkt3sURhhAtHxg14LhVQveiDrgzgwHZyeBH1TglhGUobqzXvEbPF3YmJ qBGh3FBwRNWfOsfIUT2zHi2Jy8Tay/0s7P8EYTXFs7gPRKF8TCjTmlTrMjvh6FZ2lvJ7 CU0McWII75m+75dkif2OCVFbFvlgVrwK+0gK+UFoP1ekE206dNesyZw8mOpXnL7g+kLD nn4Z4Y8HpPLAqJPIMJuB6lTZrbwa0H3P0GUbxrBgFv9lF7YW1H/+2o+fBMEgVDNqC0tJ VmzQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5-v6si306659plp.327.2018.03.13.08.54.46; Tue, 13 Mar 2018 08:55:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934712AbeCMPjT (ORCPT + 99 others); Tue, 13 Mar 2018 11:39:19 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35262 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934680AbeCMPjP (ORCPT ); Tue, 13 Mar 2018 11:39:15 -0400 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 2C4B1F8F; Tue, 13 Mar 2018 15:39:15 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas Subject: [PATCH 4.14 090/140] arm64: mm: fix thinko in non-global page table attribute check Date: Tue, 13 Mar 2018 16:24:53 +0100 Message-Id: <20180313152504.179086368@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152458.201155692@linuxfoundation.org> References: <20180313152458.201155692@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel commit 753e8abc36b2c966caea075db0c845563c8a19bf upstream. The routine pgattr_change_is_safe() was extended in commit 4e6020565596 ("arm64: mm: Permit transitioning from Global to Non-Global without BBM") to permit changing the nG attribute from not set to set, but did so in a way that inadvertently disallows such changes if other permitted attribute changes take place at the same time. So update the code to take this into account. Fixes: 4e6020565596 ("arm64: mm: Permit transitioning from Global to ...") Cc: # 4.14.x- Acked-by: Mark Rutland Reviewed-by: Marc Zyngier Acked-by: Will Deacon Signed-off-by: Ard Biesheuvel Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/mmu.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -107,7 +107,7 @@ static bool pgattr_change_is_safe(u64 ol * The following mapping attributes may be updated in live * kernel mappings without the need for break-before-make. */ - static const pteval_t mask = PTE_PXN | PTE_RDONLY | PTE_WRITE; + static const pteval_t mask = PTE_PXN | PTE_RDONLY | PTE_WRITE | PTE_NG; /* creating or taking down mappings is always safe */ if (old == 0 || new == 0) @@ -117,9 +117,9 @@ static bool pgattr_change_is_safe(u64 ol if ((old | new) & PTE_CONT) return false; - /* Transitioning from Global to Non-Global is safe */ - if (((old ^ new) == PTE_NG) && (new & PTE_NG)) - return true; + /* Transitioning from Non-Global to Global is unsafe */ + if (old & ~new & PTE_NG) + return false; return ((old ^ new) & ~mask) == 0; }