From patchwork Mon Feb 1 19:06:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 374288 Delivered-To: patch@linaro.org Received: by 2002:a17:906:24d5:0:0:0:0 with SMTP id f21csp4176246ejb; Mon, 1 Feb 2021 11:08:27 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTterulWdMBM+1bTNDInWlve24OIaFwYk4gBycNd6MKVKTlHYNCgB4NCX7UJQK99AgpaYL X-Received: by 2002:aa7:ca0d:: with SMTP id y13mr3196576eds.115.1612206507914; Mon, 01 Feb 2021 11:08:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612206507; cv=none; d=google.com; s=arc-20160816; b=YPHtPvlbC8Rs7IL+X9Z7s2CJFwrXgysL1sbUIM2Nu8B25h5VnzWvqYpTHNJbR8g8KR Y9n/C+GgPcnPKLjVxt5fxYVsPu25LmfBPFLfTHn5isduV9xnKnQGYkQKIqqbrgCcBSo7 V9Dl5CDxT0b5/L2MMGDHEeVselgm1ThRUEUZ/FsvhcGNONLYiws6x2rntL3/zJLGS+TY TNANLA28ai8OJ23tBnMQfyM8xQ9viw9WvsxgyjpLW8G4ISZRHeWxrG1PCStPdVAoy2R1 z9uzAL5t+uUL2DbVh2+CbKv/x+iWjQb8YWx81WU0Lf/Y1FlJtRsQCe/MTsjSRWkhlNKo qACg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=zMkRDLQzsm+Rt4QHGipHxKK5Rz809TSRe8ltdt989Yk=; b=RJuQkmoUZSyE215nNrIUBDtPciB1NUv03/dUOlPcnTQre27fzbu3IU1Ot1gDqWfsFI PwdcmPKDOASAYDWLyhw4TPl2GMcJYA8RDLuK38CDwpz680tfazUgSE80RlG60PcI+O48 JdhRMqLcEYksZ2yAVxPLcotVO/6zTWUPaVgaJitP5/XrlgUrfV7w8EoK/vL+HdqWglU5 MIZICoebCjV4vYNHfhT9ahVw3XxKkEbnkJLKTiheoMxKIoowlVZ6KEfJM8vVhH/SbHuZ q1bvJXupMMVRhwHI8cpzOl1qJcFngghHqkyJtV5/Q2xbOP/S2FRH8070a2xHkGNxt1Ej YWRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o27si12419305edz.400.2021.02.01.11.08.27; Mon, 01 Feb 2021 11:08:27 -0800 (PST) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231226AbhBATHU (ORCPT + 13 others); Mon, 1 Feb 2021 14:07:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:38588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231184AbhBATHT (ORCPT ); Mon, 1 Feb 2021 14:07:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E26A464E8D; Mon, 1 Feb 2021 19:06:37 +0000 (UTC) From: Catalin Marinas To: Ard Biesheuvel , Linus Torvalds Cc: linux-arm-kernel@lists.infradead.org, Vincenzo Frascino , Will Deacon , Mark Rutland , stable@vger.kernel.org Subject: [PATCH 1/2] arm64: Do not pass tagged addresses to __is_lm_address() Date: Mon, 1 Feb 2021 19:06:33 +0000 Message-Id: <20210201190634.22942-2-catalin.marinas@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210201190634.22942-1-catalin.marinas@arm.com> References: <20210201190634.22942-1-catalin.marinas@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Commit 519ea6f1c82f ("arm64: Fix kernel address detection of __is_lm_address()") fixed the incorrect validation of addresses below PAGE_OFFSET. However, it no longer allowed tagged addresses to be passed to virt_addr_valid(). Fix this by explicitly resetting the pointer tag prior to invoking __is_lm_address(). This is consistent with the __lm_to_phys() macro. Fixes: 519ea6f1c82f ("arm64: Fix kernel address detection of __is_lm_address()") Signed-off-by: Catalin Marinas Cc: # 5.4.x Cc: Will Deacon Cc: Vincenzo Frascino Cc: Ard Biesheuvel Cc: Mark Rutland --- arch/arm64/include/asm/memory.h | 2 +- arch/arm64/mm/physaddr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 99d7e1494aaa..3c1aaa522cbd 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -332,7 +332,7 @@ static inline void *phys_to_virt(phys_addr_t x) #endif /* !CONFIG_SPARSEMEM_VMEMMAP || CONFIG_DEBUG_VIRTUAL */ #define virt_addr_valid(addr) ({ \ - __typeof__(addr) __addr = addr; \ + __typeof__(addr) __addr = __tag_reset(addr); \ __is_lm_address(__addr) && pfn_valid(virt_to_pfn(__addr)); \ }) diff --git a/arch/arm64/mm/physaddr.c b/arch/arm64/mm/physaddr.c index 67a9ba9eaa96..cde44c13dda1 100644 --- a/arch/arm64/mm/physaddr.c +++ b/arch/arm64/mm/physaddr.c @@ -9,7 +9,7 @@ phys_addr_t __virt_to_phys(unsigned long x) { - WARN(!__is_lm_address(x), + WARN(!__is_lm_address(__tag_reset(x)), "virt_to_phys used for non-linear address: %pK (%pS)\n", (void *)x, (void *)x);