From patchwork Mon Mar 8 16:10:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 12122883 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6A79C433E0 for ; Mon, 8 Mar 2021 16:12:04 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 58AA26522E for ; Mon, 8 Mar 2021 16:12:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58AA26522E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Cc:To:From:Subject:Mime-Version:Message-Id:Date: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=YQg7xJ2yH26r5vDbAqfmb203ZSBEEeiaBYgIzUD7I7A=; b=N2KSDMvKfnN7SOdMWL2zn4h1Fj T+VARJdkVLBVqoR8cUGi8LHefMPgylt5v6RE6rx6/R7UHmpfHe26KsSxUGDv7Z2YEwt2qylFZ+7x5 /mlV0PeVwu28RUEjso0wnXqziMi+EopDr55PnPzdVuXznskMU5QRhkD9QaSrSRJBii4ZtsyJvw3ta Rnoi8zcY1XYvYer6iWLDNHrIoWJwVCV6xJlfYyhYb+Px7MOzzez/VMKmsHCJasHXmjFgFDVhZsm+K hUJcHQHZKrn9v3UkltMztJCqhXY20Auamo1+jkZntx6kUUoZ4BRsjr2d/yWFb6twV2A3YqjZLDFqV HGO7DANg==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lJISp-000se4-Lv; Mon, 08 Mar 2021 16:10:35 +0000 Received: from mail-qv1-xf4a.google.com ([2607:f8b0:4864:20::f4a]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lJISl-000sbg-MU for linux-arm-kernel@lists.infradead.org; Mon, 08 Mar 2021 16:10:33 +0000 Received: by mail-qv1-xf4a.google.com with SMTP id h12so8009395qvm.9 for ; Mon, 08 Mar 2021 08:10:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:message-id:mime-version:subject:from:to:cc; bh=oHoXOsuCgC7xf9AhbyLfG6oKwbjtqz3UKDIdpKdyom4=; b=f9G5VYb61NRmKnzQ+kJ/qIpehGxvh6Tl91nXblnBclVVfILnCqa4K859ACPoRgJlB8 BoM3WccpS5s0XNN/J9e7i1yxAqR54D7Q8KhM6bWU3bfToS0R9THLQiJSiN2y/7s0jDhG IQx8aMiHoG9fuvf6Jb5LTJ40gTRJ52IIZR37dYZPfL4l2oaPXd+1MIEd3LWw9fihHBKV IwJ7AwEc1xgXPB8PeOlXUPLcQT8OBnuAt4C0L/Xl5l2sDfLhXTDapGBbAgZL+eaOOTif 0v7C7icnv33OwwWvsffPMTXY8frYoUw0gygqncQxcPFTxHvyLA3bQ/l9yoACAqebGhzx Omhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:message-id:mime-version:subject:from :to:cc; bh=oHoXOsuCgC7xf9AhbyLfG6oKwbjtqz3UKDIdpKdyom4=; b=HZhPlKsGHfeXlbsIY0L0wOixDo+o4zt/91LFWvA3LfyghHO7bT6iU5ld2gdaJufeu0 pyNBbCkZ+7qYs+q9C1em0uYKSPblqhHABXqr+v6+itc2dxSQEBK+9sZfjrtf7IYDhAmC yrp8HdYTjCtYX9VhAzpqevsi1jOPRhOG5N/nrb06Vvf8JmWCPRBwGFMPkaOAPiZNdReq yEIMVozgxs4QfS+6JF3l00MP6Y5d89/rLi+AwhwZC/FK54goSS3/XJihzPab8y5EFaRB zIzBVYFvlhNNM8jtASHjCJwO65529vMNOmDxNLovtZeTVWvMk7ZNx7I0SvgjaiUH+Dq7 pU2g== X-Gm-Message-State: AOAM532MetRMhXw5vKWjv5EsC3lulW2ypbXPPzVZ4OGgG+ftoNDqUhpU mcErlNCaBgAfb5n+f82BAde0cEgQmReeU2Za X-Google-Smtp-Source: ABdhPJzK8pae1qjyFps8+oVppA/0pZjgQL3oiraxl7iLzIThic5NbHNq9hzZeXogGGytNeUHqmd0t1gVKDVN4Mck X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:85fb:aac9:69ed:e574]) (user=andreyknvl job=sendgmr) by 2002:a0c:f890:: with SMTP id u16mr21837557qvn.21.1615219829599; Mon, 08 Mar 2021 08:10:29 -0800 (PST) Date: Mon, 8 Mar 2021 17:10:23 +0100 Message-Id: <4b55b35202706223d3118230701c6a59749d9b72.1615219501.git.andreyknvl@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.30.1.766.gb4fecdf3b7-goog Subject: [PATCH] arm64: kasan: fix page_alloc tagging with DEBUG_VIRTUAL From: Andrey Konovalov To: Catalin Marinas , Will Deacon Cc: Andrew Morton , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov , stable@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210308_161031_816661_D667EEBE X-CRM114-Status: GOOD ( 10.72 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- arch/arm64/include/asm/memory.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index c759faf7a1ff..0aabc3be9a75 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -328,6 +328,11 @@ static inline void *phys_to_virt(phys_addr_t x) #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) ({ \