Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3526378pxf; Mon, 15 Mar 2021 11:31:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3WzdjRscCTm9HJq6R8le0Um08cEjStVNu1KaISZwtI3kHuK37v2/+ld2ZCLDB4INYSX/k X-Received: by 2002:aa7:cb82:: with SMTP id r2mr31672830edt.209.1615833074451; Mon, 15 Mar 2021 11:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615833074; cv=none; d=google.com; s=arc-20160816; b=gwV5ZZD/ue/BWqu1XvV2ik8V3DoXaHyTAIz8vOaFPYFFZU2yp7FMHTCw78pzPVnww6 OAlPJ+aMtSFCoay3qgk4TNbMo0SFnTfAnvw7t6mqjhcTQL37UUwe/jJYBVQztHxvLIpV btxssp/E5CAs/+tso4y6B5bYx+AAJHtQGawWyAjB998mfXJ3RsFvWPrDEwpXDgcBA7da ffl36q2DeTTACejMRPFF1Wt0mx8H/7kkx8lPsfUmM6XDaxWByxlzyBjbHvhEAml3Os8H gm4XyizInCylkcugZZfVSrCq97l/kZ2lM/4uqVv7q/9KFYN828N4BUfiVo9gNlrosHuB SWPA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BThHN7N+OGFXrY3WiJMSpJN/dCaR6lknH/g0XT79X2o=; b=KICBVy4JITbKeDF/4KcbmYedsj+pIX+phFnBAm/6dsUYW7AqrNp7uruu0gwHjUkGTg 9KKDj0/9E2JMd8WBPuAE/1geo9u/ycS+e1MyvYHlcfFYy1WggtY/0WLB4Tn7Ln7Esuos Fn32SIp8bqWnUxQtGbtMxE+bOy0VVcQYotK7kUF8dNYdqpomT820z7mKAKySaHajqWau cHxAKXYNUEwtyPTMqWjBraym+uItRrVk10H4znkMd8qKKPUtAkFwBZRGZp298VE2K/P+ c4ujEdgdRXRSOlcb2W7snZ3AIMjFZRTkj1MB40TzD1m4J/iH8wXTjdm8JskCdIGILltJ ypdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kZXxv0mj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si11961847ejr.192.2021.03.15.11.30.52; Mon, 15 Mar 2021 11:31:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kZXxv0mj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236095AbhCOOea (ORCPT + 99 others); Mon, 15 Mar 2021 10:34:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:37836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233425AbhCOOBk (ORCPT ); Mon, 15 Mar 2021 10:01:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B49064F66; Mon, 15 Mar 2021 14:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816879; bh=DWkUTZJPYEwdrYvkqTCumpJfYkrmCHUOc9flC5P+QQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kZXxv0mjU4msynb3D7cQGRtQKRsRltmmBmr8zwHipbFiDyv9GwfmD2aObKKd4aJA9 +cb6mfK5DN95GLX6J8vrPKBeyReshHx5HBPVNxTgcVW7n0BuF63wsMxQ8izauOjfS2 NueKTSI5q0oj8vtudn92UeyCF/j09RmKfbxBed/c= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrey Konovalov , Catalin Marinas , Will Deacon Subject: [PATCH 5.11 180/306] arm64: kasan: fix page_alloc tagging with DEBUG_VIRTUAL Date: Mon, 15 Mar 2021 14:54:03 +0100 Message-Id: <20210315135513.703435877@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Andrey Konovalov commit 86c83365ab76e4b43cedd3ce07a07d32a4dc79ba upstream. When CONFIG_DEBUG_VIRTUAL is enabled, the default page_to_virt() macro implementation from include/linux/mm.h is used. That definition doesn't account for KASAN tags, which leads to no tags on page_alloc allocations. Provide an arm64-specific definition for page_to_virt() when CONFIG_DEBUG_VIRTUAL is enabled that takes care of KASAN tags. Fixes: 2813b9c02962 ("kasan, mm, arm64: tag non slab memory allocated via pagealloc") Cc: Signed-off-by: Andrey Konovalov Reviewed-by: Catalin Marinas Link: https://lore.kernel.org/r/4b55b35202706223d3118230701c6a59749d9b72.1615219501.git.andreyknvl@google.com Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/memory.h | 5 +++++ 1 file changed, 5 insertions(+) --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -315,6 +315,11 @@ static inline void *phys_to_virt(phys_ad #define ARCH_PFN_OFFSET ((unsigned long)PHYS_PFN_OFFSET) #if !defined(CONFIG_SPARSEMEM_VMEMMAP) || defined(CONFIG_DEBUG_VIRTUAL) +#define page_to_virt(x) ({ \ + __typeof__(x) __page = x; \ + void *__addr = __va(page_to_phys(__page)); \ + (void *)__tag_set((const void *)__addr, page_kasan_tag(__page));\ +}) #define virt_to_page(x) pfn_to_page(virt_to_pfn(x)) #else #define page_to_virt(x) ({ \