From patchwork Tue Sep 15 21:15:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11777747 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 8FD6159D for ; Tue, 15 Sep 2020 21:17:09 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5465120770 for ; Tue, 15 Sep 2020 21:17:09 +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="DmRECeLt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5465120770 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 34C0A900083; Tue, 15 Sep 2020 17:17:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2D499900012; Tue, 15 Sep 2020 17:17:06 -0400 (EDT) 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 068AB900083; Tue, 15 Sep 2020 17:17:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0156.hostedemail.com [216.40.44.156]) by kanga.kvack.org (Postfix) with ESMTP id D39D2900012 for ; Tue, 15 Sep 2020 17:17:05 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9BFC3181AEF09 for ; Tue, 15 Sep 2020 21:17:05 +0000 (UTC) X-FDA: 77266556010.18.sack44_5b0ba6727114 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 80164100EC688 for ; Tue, 15 Sep 2020 21:17:05 +0000 (UTC) X-Spam-Summary: 1,0,0,485a25907761f2ef,d41d8cd98f00b204,3ty9hxwokcdqqdthuoadlbweewbu.secbydkn-ccalqsa.ehw@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:4321:5007:6119:6261:6653:6742:7875:7903:9165:9969:10004:10400:10450:10455:11026:11232:11473:11658:11914:12043:12048:12297:12438:12555:12683:12895:12986:13161:13229:14181:14394:14659:14721:19904:19999:21080:21092:21365:21444:21451:21627:21990:30003:30045:30054:30090,0,RBL:209.85.221.74:@flex--andreyknvl.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yfctcu59kej3tn4froqpeo354joopybr4a81jxirz69fbx6kma1s95dqqdqhk.jmhzbagjcbgudki17i8ahp8oeishhaxo7955qz58adjceixn3yarwe7gkbdkqpq.h-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,Dom ainCache X-HE-Tag: sack44_5b0ba6727114 X-Filterd-Recvd-Size: 6916 Received: from mail-wr1-f74.google.com (mail-wr1-f74.google.com [209.85.221.74]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Sep 2020 21:17:05 +0000 (UTC) Received: by mail-wr1-f74.google.com with SMTP id s8so1694188wrb.15 for ; Tue, 15 Sep 2020 14:17:04 -0700 (PDT) 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=5DI33wLk49GBiOtTKNywoiQR13ppWemjtswafD/fR5U=; b=DmRECeLtjagddPxzdBOI/cbUSIcCj9YlPlFtWUGZkzza+NWDct/TWNwEPz49SkuWzo 4XQ7FcE4/MEiXpjPl01IHdiQwJYMt00fu0owgHpTvGvGT+eMNRTAQyUBSw7MGEz1LPds fJU/HHM7oIvGTYV1Mc+eNzlXkwhdz871BCVnbNulA2XQm1qI86ZIPP6YCV3EtqYxFvYG iRkHaw+QV9t140r1KzUFLN2g2XUIEAYeKG0F4vY/BOAepISVUVn/Xo6bguhF2wAvuhih 7oSjhQJQ5xC5tLBr1fJslldAHgfLvHYyb5euCX1qmVxpt9cZDAZ7p/g2Hr0elLpu77GO gnUw== 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=5DI33wLk49GBiOtTKNywoiQR13ppWemjtswafD/fR5U=; b=RDCWh0F6hse2kW9e5O59ei3q3GZ8DXu0a0vOy8ETnsDs76xsEtmWuSfeoT4pvnQ+Jf a04Eip57cYzHGpDs0FQLAtbdlh9Y540ka3szFMjulrexZGpTWGtMJ9CQW9ynClNyNGWn 0S/z69mh7tMXDTdUexBBV+RWdz0iPSoITzVRlzPgF47tLfibPSOX4c5ini5tnbcJA7b/ ZXHc92DvYtmtDssUY/90py2DhFMCQ/fZAFHAZ3Z4kaQgMDxnU5ppXX50LfJ2ihnwYZUQ QK45lFoqj1XGJhjJE+0U9FefKKn2HuG4xv+nOlUgm/PuYYv835iraJTQy/wOMxzlibXM l2wQ== X-Gm-Message-State: AOAM532XLB+SL1NGYcFQd7dDEs1J2xP1uiGOXaj+S3SjQxqPJB4BbEm+ A1k3wjaLXc10tNu4graTnzB7SvdR5uWcrIFe X-Google-Smtp-Source: ABdhPJx/IVWOUWzO63QUKRnkUC+iv4qskfpZBykHR2uWLCKAJcd6r7yMu0uGFJNhTPzIa56S3Bl1rZixp5HAYJUE X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a5d:6343:: with SMTP id b3mr24815500wrw.179.1600204623954; Tue, 15 Sep 2020 14:17:03 -0700 (PDT) Date: Tue, 15 Sep 2020 23:15:59 +0200 In-Reply-To: Message-Id: <3f3ee8faf0eb24b7bf6121a5708c4f4ac9ff68d9.1600204505.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.28.0.618.gf4bc123cb7-goog Subject: [PATCH v2 17/37] kasan: rename SHADOW layout macros to META From: Andrey Konovalov To: Dmitry Vyukov , Vincenzo Frascino , Catalin Marinas , kasan-dev@googlegroups.com Cc: Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Elena Petrova , Branislav Rankov , Kevin Brodsky , Will Deacon , Andrew Morton , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov X-Rspamd-Queue-Id: 80164100EC688 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 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 --- 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 2cce7c9beea3..6306673e7062 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -36,11 +36,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; @@ -243,7 +243,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) @@ -252,7 +252,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) @@ -262,15 +262,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); @@ -279,17 +279,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; } }