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: 11895549 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80B23138B for ; Tue, 10 Nov 2020 22:12:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3752A20E65 for ; Tue, 10 Nov 2020 22:12:03 +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="J2IH1uzo" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3752A20E65 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 026B36B00A7; Tue, 10 Nov 2020 17:12:02 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F17C86B00A8; Tue, 10 Nov 2020 17:12:01 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB7D86B00A9; Tue, 10 Nov 2020 17:12:01 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id AC1D96B00A7 for ; Tue, 10 Nov 2020 17:12:01 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 5A1CE1EF2 for ; Tue, 10 Nov 2020 22:12:01 +0000 (UTC) X-FDA: 77469907242.03.brush79_0310600272f8 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 274DD28A4EB for ; Tue, 10 Nov 2020 22:12:01 +0000 (UTC) X-Spam-Summary: 1,0,0,7cc35600ce43f777,d41d8cd98f00b204,3lxcrxwokcp4gtjxk4qt1rmuumrk.iusrot03-ssq1giq.uxm@flex--andreyknvl.bounces.google.com,,RULES_HIT:41:69:152:355:379:541:800:960:973:982:988:989:1260:1277:1313:1314:1345:1359:1431:1437:1516:1518:1535:1543:1593:1594:1711:1730:1747:1777:1792:1981:2194:2199:2393:2553:2559:2562:2693:2901:3138:3139:3140:3141:3142:3152:3354:3865:3866:3867:3871:4117:4250:5007:6119:6261:6653:6742:7875:7903:9165:9969:10004:10400:10450:10455:11026:11232:11473:11658:11914:12043:12297:12438:12555:12683:12895:13161:13229:14181:14394:14659:14721:19904:19999:21080:21092:21365:21444:21451:21627:21990:30003:30045:30054:30090,0,RBL:209.85.221.73:@flex--andreyknvl.bounces.google.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100;04ygphmpnymdp8z38kk8o3car3xm7ypybr4a81jxirz69fbx6kma1s95dqqdqhk.jmhzbagjcbgudki17i8ahp8oeishhaxo795tgenksb5uhixn3yarwe7gkbdkqpq.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:no t bulk,S X-HE-Tag: brush79_0310600272f8 X-Filterd-Recvd-Size: 6928 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 22:12:00 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id w17so5433020wrp.11 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=c3LqRgBQQUKwxy1yJjoaa11FtPhU9tnj5N+OPKBxT8pFv30k1t/t0QxvCEOlypADXI qc9JkIiDp6IRsb22vaDl2D50BoNR/gqokgugyBQt0ufF6a6X2za62bV87LpriD1iLjhq hdT34BFCRbyrWelhOAlYu3jnv10Wi4Y4tLuJIEh9PVWAL49ieNE4P8JJ7TnN9Q40CuoL X4A6i2G19tKrKtX2EbVp3yFWURtvp/fYq5s7yJf+a4ANi3+SeUBvCYeJbANC/7VrD9P/ YpnlNLj7C7OPF+XOJ3B4TD1+TRTxoiwnAfz0gxRr2fx3mRdlNwAqQb1J2P7ktG5N2C8O rM+A== X-Gm-Message-State: AOAM531iWBE+aQBdlIjnJthATlKddq/fP4FUZaAsFgwW9Ih3OmvwcQis Hz21yQ2Ya6RvDZ8vTnKtPscp1ZCwVU1Be3/K 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 Cc: Will Deacon , Vincenzo Frascino , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , Andrew Morton , 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 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; } }