From patchwork Tue Nov 10 22:10:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11895635 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 C0F0AC4742C for ; Tue, 10 Nov 2020 22:20:13 +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 3F3F120674 for ; Tue, 10 Nov 2020 22:20:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="assVv5fP"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="J2IH1uzo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3F3F120674 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=F9qkJ2KYt4TJa9Kkh6Od9/0e4pw2ypk1VR/Y/VUShNw=; b=assVv5fP9SnZq2RVa/gWRNaBP 34w6yCf2XH930dbY4uZAB93Vbit/9picB/CxR0L5ZeGUHCH9zL8lzXwzmKBWlJkb9s2wQW2HCgu6Z NVGOBsCce+F9J1aKcJaxojga8TMn5eqxm8u5HnwoS+03Q5FDH4lCAdPPe87BPQmJ4mRdz/WyBLg0g ilhPgoIusGZ7mZcK1+MYAtQuCJjDWjMmcqqb9GN57tgmcKVLk4BaqBVEf20s12vIBozJuGULBAOKk 4EwZi7bu1cV8GuT0zj0yIurFmXt63+dXIhm4bk6OwcodVlFtrlGPjgOLxc7AkeWSLOnwTF/xOdL18 VWK729N7A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcbz7-000884-8Z; Tue, 10 Nov 2020 22:19:29 +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 1kcbrv-0004m8-EZ for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 22:12:16 +0000 Received: by mail-wr1-x449.google.com with SMTP id b6so6152403wrn.17 for ; Tue, 10 Nov 2020 14:12:00 -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=7o8isZnuO2uqhDb/44rZc/AlL83I+HH/9hRL3CzWT88=; b=J2IH1uzohUU0Sq0wco4PYCWV+sIspm9HTgd9anFGPWaBwTQmaOses08ZieVq3CDEgS cQF72MNYAyyetG25P504Uj8WLSdvXM6rgLds9xZsFTpW2TXC/uJQhKeZjLx4ZDm3yUNG 5+VTBUg0ICuzVu3QxaIQFlJzSqRw3b914m5TA2hdfyBTQvv4DtZkLrSAJfIJykJzADlw NNN/8lVQdM4o0VpjS9KCcwaGVFTGbETytDATc+U/a5mkVzjsZ43fgd4PWCEHIrfzOE9l 2BQ8hZnRVGfapHzX7zOP5LqUkpQ6w92dfDOClkxlYaC3pFDI6mf63PjQJLXYBTssgJMw lNIQ== 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=7o8isZnuO2uqhDb/44rZc/AlL83I+HH/9hRL3CzWT88=; b=oN1LM4IN/NQ9xrtfNLFtxke2Jn7X9LC0lww/X6eHGSt2l0Hb0vNpCDReJ778eAUjuu mmBAr8odLTPFgQ3MRJOP9i4sOSXReXpyHYqgELJ2Px5bHAy22KmbKGp6m/T1iedEoGSd Fp0vO48K+pwk4i/tehR7AFMuy1gpYURijlClQrhpx83TCn1Jz1gQ1U+jLBGUFBV5tcB0 +VMQtWyhiMwe6SAyM2KfUPLS7xfHc+VySUqAv9J+vcqzO9AeL+odASdGCqX1ygcVrjSc YFByl3NMMlTY2EqFDN8c+q7qk5KuoKOylGqVagss7E6ls2XMyq8BMHX+CktDNpGyx3IR 1ILQ== X-Gm-Message-State: AOAM533f/0sR1S/CrwgVDTzYHlM+P659hSJLcIqTJNSt/y459Xtcl+xL eXClg3fJfumlv1bU1cr6EIc+CoqnpnIoKlJW X-Google-Smtp-Source: ABdhPJxeLUZXzNAqQFQiugSBgH/qwQWIMmhJELUOhB6jZj+GbCoeaSWzQqfGZVlbT5vH59NPz0d+Mh8A4e9jJPwj X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a1c:3b87:: with SMTP id i129mr275365wma.134.1605046319530; Tue, 10 Nov 2020 14:11:59 -0800 (PST) Date: Tue, 10 Nov 2020 23:10:19 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.222.g5d2a92d10f8-goog Subject: [PATCH v9 22/44] kasan: rename SHADOW layout macros to META From: Andrey Konovalov To: Catalin Marinas X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201110_171203_600964_C299DECD X-CRM114-Status: GOOD ( 15.02 ) 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 , Andrey Konovalov , Kevin Brodsky , Will Deacon , 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 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 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; } }