From patchwork Mon Nov 23 20:07:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11926399 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=-16.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,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 D1578C64E7A for ; Mon, 23 Nov 2020 20:09:12 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5E04C20715 for ; Mon, 23 Nov 2020 20:09:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="fLNjLZHK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5E04C20715 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DE0786B00A6; Mon, 23 Nov 2020 15:09:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D16326B00A7; Mon, 23 Nov 2020 15:09:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBCA66B00A9; Mon, 23 Nov 2020 15:09:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0114.hostedemail.com [216.40.44.114]) by kanga.kvack.org (Postfix) with ESMTP id 7A6DC6B00A6 for ; Mon, 23 Nov 2020 15:09:11 -0500 (EST) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 22689363D for ; Mon, 23 Nov 2020 20:09:11 +0000 (UTC) X-FDA: 77516772102.23.crow06_030f23c27368 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin23.hostedemail.com (Postfix) with ESMTP id 00CE537604 for ; Mon, 23 Nov 2020 20:09:10 +0000 (UTC) X-HE-Tag: crow06_030f23c27368 X-Filterd-Recvd-Size: 6979 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Nov 2020 20:09:10 +0000 (UTC) Received: by mail-wm1-f74.google.com with SMTP id g125so94631wme.9 for ; Mon, 23 Nov 2020 12:09:10 -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=GcVKnuDfFzQJ9e5llEgSJzxpADe2yFJHu5NkpPOoYoA=; b=fLNjLZHKWHQJNdwRPJsSxkIZL/JkuBgX6paJWA75DhPzusGy5pBQlnRoj7DUC4OE9J /dHx0FFxPlcalr/FT45oa5ua3HOb6Jr210oolLSIcOcloAmip5jJ5dZN/mibG+uP1SOt 93odu3MPyMfNZhulD8fxPO3eLk5Y0iXhZ8pMaqR1fwEvp+EGh0dYdUe1nUqEorbD0ksZ 36nqGDWKmy9RjQtEUbBW/h7NncW+6md6FVRMgFl5BMOT1NsLdbYTXRoldvriR3FkeIzp B1Jo4Hd7wx7A+HluESDMn0fFZ5T1x9zUiwB50hJezF6a9/ijx+AQ06wHrkJ4KeBgt4AH ExOA== 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=GcVKnuDfFzQJ9e5llEgSJzxpADe2yFJHu5NkpPOoYoA=; b=UYl2e8HlBJGvzZjCzzb6XXNCafjeKTs2/Ky1q26NdPmZBOLz/vprdjucDKdSRrZEWV YuV8ozdvQ9v0i5mpwjoL1qn5jnGECdIw8L7qg8LkXdGqpRy7uYqKJHUJrQAk4B+2ICsL VmF1OYwcA2jP4/yCnjRkbyQvn8PHsT84KUph+jyKpIVet6/9n5QPJO4hppTtGrTgZfUM lmXO21bYlTvl6b1QfX5NMFr8b5zmz/MCOR8Hq0GQn37vkwLvfD/M21nBWQ6w8grfKDt8 So1PS3EP/eoQH90de4z15WmrdS1hCE9csTl2dGIy2V3jKG60LdhNQ7WmkJwfRmvDZ0gC nRMg== X-Gm-Message-State: AOAM530sWAwcdlnJcMVa3jekxxV5YYNpYehJed8z9AARkatxZl0FoJsV AbhVB49CmW4uLOT0k2Sp908emG3VIcauij9/ X-Google-Smtp-Source: ABdhPJzsYjs2bIFcwXl3lHTmf71+QwbgCoQxk/IAfOMMcr6012AXQF+ky9MJNqswjBQkrZdJsGaFpBBNzpDtDav7 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a7b:c0c2:: with SMTP id s2mr613063wmh.78.1606162149371; Mon, 23 Nov 2020 12:09:09 -0800 (PST) Date: Mon, 23 Nov 2020 21:07:44 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH mm v11 20/42] kasan: rename SHADOW layout macros to META From: Andrey Konovalov To: Andrew Morton Cc: Catalin Marinas , Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , 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 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Alexander Potapenko --- 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 5d5733831ad7..ab28e350bf39 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; } }