Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3411167pxx; Mon, 2 Nov 2020 08:11:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJxTf5QsIx8r6glShQtOWuyuBAh2ru40ecLZ/xERm5TCLY3LgPPfne5d8O7JD3DHjYjVOq9K X-Received: by 2002:a05:6402:a57:: with SMTP id bt23mr6302439edb.62.1604333482199; Mon, 02 Nov 2020 08:11:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604333482; cv=none; d=google.com; s=arc-20160816; b=gRYaw1VOgETVIcV2rH6RrH+eAJbYaO3SB7dqUGmga8BcOsfvQPEj0jETv9PeHrZoko m01dM9O3a/gyJZLwHlf5OhZ8oCq48QUDwUTWztRLozuPIOLDigIOBEEGffb3KtYKnh+y bqFcJ1Jsax1JJJgoC5ckKhvGCDVamy2TiJN7m5gnno+1su7f63ume2zGV77caq8G3Au6 9/aoavMBlcz3ynqQzV8SdBoHZ3DWg9j3QMZdHR0es0MhYUmotHTJcfhDstrvwnhqDwvL MHyivS/G92sh+E5GgerIAmRCBYBjoSv+OOcs/sVIDYV8KrTXOUYfH4UcaN3OWiK87JOp ghfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:sender:dkim-signature; bh=85BahkB/ARH3bXDyEMCLh1SMwp72o82khunrv9SMNJc=; b=SotVrMhFz29POywA25jZLuNEh/PJwpX6+lD+AS6XfeJ9adOzhsrulq6BrCn7tW4LR2 rLjPwwuKbwr/R+m60ORadEgk7cfKdwWyYX3QEDSdeJfXOZXq6nZbnL6UBYQKRn1axG62 1TPWlYjh4tDjAcvNFTinb91G4HoErKsZBlt4DFQ9ScNjEoYW2v8aPyfxCG8WD04TYbZ1 eaT2n6hpS51bopEsaN6IA/P9aArv2MjcqU2vDRF7VoITICoLIXlPWnNXYZeUTYHg61U+ Ke4pRrQXuMLQUq64/yB/A3lcbznx6dea4VkD+DtuKEtl3d50N0eBpr50qnCwzTYmAGfG Tftg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="qerdM/Iz"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b1si11477044ejb.290.2020.11.02.08.10.59; Mon, 02 Nov 2020 08:11:22 -0800 (PST) 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=@google.com header.s=20161025 header.b="qerdM/Iz"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727286AbgKBQGk (ORCPT + 99 others); Mon, 2 Nov 2020 11:06:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727138AbgKBQFi (ORCPT ); Mon, 2 Nov 2020 11:05:38 -0500 Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66353C0617A6 for ; Mon, 2 Nov 2020 08:05:38 -0800 (PST) Received: by mail-wr1-x44a.google.com with SMTP id t17so6623643wrm.13 for ; Mon, 02 Nov 2020 08:05:38 -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=Lyg5XlZQ2eY75EB0BBMO8Y7+pmdT7kITbZC7lEfyxsi+JYM7Kn2KWCBBa7d0nB3z5L /K3G2Mj+UaUj14a8v7oD6AJsWfwpLF7P9ldb6wRdRDi1eH4B2DSwthL/JyMXthTTn9OK j6eeCV21pMxTnQA3rQwo2MP7MuyW7ebkVy24Lzj0GBf/z1gCtKH9RFL3r/J/bUyRxUHG 6TWv9hHzNrubOyoOBj+cADToB1sEnIVBzlf378+c1qpRUfKD+EHAO2PftmC1PdDXBU3m u5VhhTj2B40f/PmkRfMexuxn5YJNdNDGSjqqSh3GaBqyRMezkuxESPhcdVuIUNIgRery CYlw== X-Gm-Message-State: AOAM531ZXAhSh+BuSB8Ve2/zBLjSPGUDsa1ETzUkvCIOoXfe3blH1FxP b3v9xwlSoi7vPeucGhWoUMj5pTfl5ffMwNl1 Sender: "andreyknvl via sendgmr" 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 Cc: Vincenzo Frascino , kasan-dev@googlegroups.com, Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Elena Petrova , Branislav Rankov , Kevin Brodsky , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; } } -- 2.29.1.341.ge80a0c044ae-goog