From patchwork Mon Nov 2 16:04:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11874399 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 B2046C00A89 for ; Mon, 2 Nov 2020 16:13:04 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 59B5B206E3 for ; Mon, 2 Nov 2020 16:13:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rSrOXdiE"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="qerdM/Iz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59B5B206E3 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=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=p/HVdRUMpAN4oGlluJTih86ZyJPVDlJZxI4WS6ZaxEk=; b=rSrOXdiEA7EAo54jUojBa+DS0 EvZekU3cyASDtt8wqFcIHGG9QKEOSZwTqdosbv/6vUd04T4jRlYIWPZQ5Zo2LoojCp2bVFuSUMjuI +sOYTG/DDdTq4Zj9zF5LuClvzx+vSv1XMcQLnLlGc+lGPddu8PTIR51tM89WsrY70zeO4MBs40958 o1WrqVx6d61HENw/9o2RVs+k1Pn/vzvqX200fpugePPZglHQwR5mG4BQQJBM6GqIrrOke+/VCWVT/ K/n8AZQcOXZduHXeYKEU7kERdiGfNss6+GU1OUvPs4a6o4SK/DETuQ+tF90nrQyelitLXj7/LaAb7 KBHplCfSw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZcQx-0002Jw-JV; Mon, 02 Nov 2020 16:11:51 +0000 Received: from mail-wr1-x449.google.com ([2a00:1450:4864:20::449]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZcKx-0006tX-Cc for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2020 16:05:47 +0000 Received: by mail-wr1-x449.google.com with SMTP id w3so4492041wrt.11 for ; Mon, 02 Nov 2020 08:05:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=85BahkB/ARH3bXDyEMCLh1SMwp72o82khunrv9SMNJc=; b=qerdM/Izbi1Ir7SjWX8KjbxLyou5BnZK6yrX/2wZGjoz7Y5EFAHYQAigA8WeZVccab EUdlk/MFcmnxKo/H8j88caus2xRAEAtASazqPLCW/6jxDkcguxKmCUppusMHUAYgyjMR fk3d+JNyG4rYmrtae4kXSM9/2jP3hYVFJajmnUMtG4JADi/JWeETWt6O01YjeIJfiV66 VDMR8meMi1+Ajk/a5YQzCmhsdTcwsv/oeAJHacJzthpWw13V2ZkkjdoiC2xlDG53j/bN nO3eHqyzZd7/xpOXRTLhaNwoVBY6COSN6zrYVEkOYpCLYlM+OiWgBxDBTP2TpakQ+VEU VGEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=85BahkB/ARH3bXDyEMCLh1SMwp72o82khunrv9SMNJc=; b=oAKvtuDuWpFaqxmscsRXLK1JNo2QmI+LE3k3f/ftrgOcjeL4XnLRo1F0ZtnmHda4zn 2huRY/aGjrmVK433F5w0uNbSH7+tsQvubYkU2nr4QbqRQkH6zC51RLfddI91hZU8SlPc XXhC0BiZH4wfwyDpN5wZzBfbBvXyQOZ/si4dyYxq8ybP7kaqTqTZR6CSIAX8xkCZYvAh e7hTsVG4ITw13TEK0eiOScM7x3OfWrPSXWXabJUMLCyOcM01P84AQEjXHBHT751Na5J0 OM9LfPWtKGbKxJWxtK3V/Nzu2RQ9TcKnds/ucpoeJeRtIbnpHUyct4v9RtOP791GYjxc SV7w== X-Gm-Message-State: AOAM530MkHOSFz7cGb+KWFdv70cQLnuXDjR9k/xfo0kbHlGEc7iu6qy+ xu6wihBi+ztu9RGxnvQasfZqma2w0LYCY+g7 X-Google-Smtp-Source: ABdhPJzWL/sQcMdXihINrLX5IT8Tw5uxLzGmnJMmCAOhOTn/XsVbiVAYvupf4e1ok0Mgjvx3VDb8UlaZPSEF4Ai1 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a7b:c1cc:: with SMTP id a12mr48615wmj.0.1604333136445; Mon, 02 Nov 2020 08:05:36 -0800 (PST) Date: Mon, 2 Nov 2020 17:04:09 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v7 29/41] kasan: rename SHADOW layout macros to META From: Andrey Konovalov To: Catalin Marinas , Will Deacon X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201102_110539_513953_87921EE0 X-CRM114-Status: GOOD ( 14.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, Marco Elver , Elena Petrova , Andrey Konovalov , Kevin Brodsky , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Andrew Morton , Vincenzo Frascino , Dmitry Vyukov Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This is a preparatory commit for the upcoming addition of a new hardware tag-based (MTE-based) KASAN mode. Hardware tag-based KASAN won't be using shadow memory, but will reuse these macros. Rename "SHADOW" to implementation-neutral "META". No functional changes. Signed-off-by: Andrey Konovalov Signed-off-by: Vincenzo Frascino Reviewed-by: Marco Elver --- Change-Id: Id2d836bf43b401bce1221cc06e745185f17b1cc --- mm/kasan/report.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 594bad2a3a5e..8c588588c88f 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -33,11 +33,11 @@ #include "kasan.h" #include "../slab.h" -/* Shadow layout customization. */ -#define SHADOW_BYTES_PER_BLOCK 1 -#define SHADOW_BLOCKS_PER_ROW 16 -#define SHADOW_BYTES_PER_ROW (SHADOW_BLOCKS_PER_ROW * SHADOW_BYTES_PER_BLOCK) -#define SHADOW_ROWS_AROUND_ADDR 2 +/* Metadata layout customization. */ +#define META_BYTES_PER_BLOCK 1 +#define META_BLOCKS_PER_ROW 16 +#define META_BYTES_PER_ROW (META_BLOCKS_PER_ROW * META_BYTES_PER_BLOCK) +#define META_ROWS_AROUND_ADDR 2 static unsigned long kasan_flags; @@ -240,7 +240,7 @@ static void print_address_description(void *addr, u8 tag) static bool row_is_guilty(const void *row, const void *guilty) { - return (row <= guilty) && (guilty < row + SHADOW_BYTES_PER_ROW); + return (row <= guilty) && (guilty < row + META_BYTES_PER_ROW); } static int shadow_pointer_offset(const void *row, const void *shadow) @@ -249,7 +249,7 @@ static int shadow_pointer_offset(const void *row, const void *shadow) * 3 + (BITS_PER_LONG/8)*2 chars. */ return 3 + (BITS_PER_LONG/8)*2 + (shadow - row)*2 + - (shadow - row) / SHADOW_BYTES_PER_BLOCK + 1; + (shadow - row) / META_BYTES_PER_BLOCK + 1; } static void print_memory_metadata(const void *addr) @@ -259,15 +259,15 @@ static void print_memory_metadata(const void *addr) const void *shadow_row; shadow_row = (void *)round_down((unsigned long)shadow, - SHADOW_BYTES_PER_ROW) - - SHADOW_ROWS_AROUND_ADDR * SHADOW_BYTES_PER_ROW; + META_BYTES_PER_ROW) + - META_ROWS_AROUND_ADDR * META_BYTES_PER_ROW; pr_err("Memory state around the buggy address:\n"); - for (i = -SHADOW_ROWS_AROUND_ADDR; i <= SHADOW_ROWS_AROUND_ADDR; i++) { + for (i = -META_ROWS_AROUND_ADDR; i <= META_ROWS_AROUND_ADDR; i++) { const void *kaddr = kasan_shadow_to_mem(shadow_row); char buffer[4 + (BITS_PER_LONG/8)*2]; - char shadow_buf[SHADOW_BYTES_PER_ROW]; + char shadow_buf[META_BYTES_PER_ROW]; snprintf(buffer, sizeof(buffer), (i == 0) ? ">%px: " : " %px: ", kaddr); @@ -276,17 +276,17 @@ static void print_memory_metadata(const void *addr) * function, because generic functions may try to * access kasan mapping for the passed address. */ - memcpy(shadow_buf, shadow_row, SHADOW_BYTES_PER_ROW); + memcpy(shadow_buf, shadow_row, META_BYTES_PER_ROW); print_hex_dump(KERN_ERR, buffer, - DUMP_PREFIX_NONE, SHADOW_BYTES_PER_ROW, 1, - shadow_buf, SHADOW_BYTES_PER_ROW, 0); + DUMP_PREFIX_NONE, META_BYTES_PER_ROW, 1, + shadow_buf, META_BYTES_PER_ROW, 0); if (row_is_guilty(shadow_row, shadow)) pr_err("%*c\n", shadow_pointer_offset(shadow_row, shadow), '^'); - shadow_row += SHADOW_BYTES_PER_ROW; + shadow_row += META_BYTES_PER_ROW; } }