Received: by 10.213.65.68 with SMTP id h4csp467305imn; Tue, 13 Mar 2018 09:59:27 -0700 (PDT) X-Google-Smtp-Source: AG47ELscateFP2L4V/XPI1fxKiexJIZQZFQ/s+jxNO71ud8M9llrT6pPxW4MH1qdkIZ81lVo5e6D X-Received: by 10.98.63.75 with SMTP id m72mr1293487pfa.122.1520960367408; Tue, 13 Mar 2018 09:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520960367; cv=none; d=google.com; s=arc-20160816; b=H/zL+vtj/0ItT8rXdyHKeNJ6Z5xfk440TvNySOALKo5g6+q1dlwbjV6b13onp0E1Uy J3XuDAlyC4ei315HUFHfaijCXVeK12WMGbBjjlUQ7uZL9pzfm91giNijcW9DLQGZG7hp vot0Q+TpyvVnMmsa670CiqX1Tm4Nw7z2HBcquKUfy2BeEuQL8YO+uY8VeN4juKWUx1La 1CjRvQhCwjEGYv5Ga+hVq0B61ab6SvobRViRfNeHocTK8VyYq6Hjiqct0MdsibnZCmvd OKyGi+ROcvu6K1N0rMCpoNOZBQu+XaxCoiJew+gB46EDoW+GoCkXtxVTdpmbeva4b+Xy 7yXQ== 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=smqNmhYz5BI9gMp0kLRF5VPOyObBmTv3iH8/4F4AYNs=; b=pUL+8hlHF9bZrxTFeODCLsAfe/Qp0vZqJhh4leoBe8KQTX9766tc74JJ7Da6xmPheK wrCYXLnYWqogfKFsqx3TLrb1dFWEWrUGibKhT66SaPJIxOcB2rXqOANwG5QTwP+6DOCY 3Rcz00iBMMrEkc6XO/JyGa0lRDk//Jg8ieRmmmfhiIrUmCB/2OfwG1IUhB9ABrOsaq2+ 2Kqwm8grQbLQkpyrEsZDKO7leSTnyuPYwPrBQlUWa6/mMYJmqCpxgTifO7PCPB15KW+I oelX+bwKfBav6DvBX2hJ3MtyvfXH0w2m1ucqmbJZ4HNy7dHhzqNaz+y7G1qVfFuPWgxS Xsyw== 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 c193si346192pfc.356.2018.03.13.09.59.13; Tue, 13 Mar 2018 09:59:27 -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 S933167AbeCMPaE (ORCPT + 99 others); Tue, 13 Mar 2018 11:30:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58592 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933138AbeCMP34 (ORCPT ); Tue, 13 Mar 2018 11:29:56 -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 93A3DFC6; Tue, 13 Mar 2018 15:29:55 +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.15 054/146] arm64: mm: fix thinko in non-global page table attribute check Date: Tue, 13 Mar 2018 16:23:41 +0100 Message-Id: <20180313152324.816712250@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180313152320.439085687@linuxfoundation.org> References: <20180313152320.439085687@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.15-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; }