From patchwork Thu Sep 24 22:50:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11798335 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 E41081580 for ; Thu, 24 Sep 2020 22:51:41 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id AB6CD2344C for ; Thu, 24 Sep 2020 22:51:41 +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="pi/15Azt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AB6CD2344C 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 3B36A8E0016; Thu, 24 Sep 2020 18:51:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 317A38E0001; Thu, 24 Sep 2020 18:51:40 -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 18A708E0016; Thu, 24 Sep 2020 18:51:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id F107A8E0001 for ; Thu, 24 Sep 2020 18:51:39 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id A81A7181AE864 for ; Thu, 24 Sep 2020 22:51:39 +0000 (UTC) X-FDA: 77299453518.03.loaf97_5f07fa427162 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 843D728A4E8 for ; Thu, 24 Sep 2020 22:51:39 +0000 (UTC) X-Spam-Summary: 1,0,0,45e6be5168795123,d41d8cd98f00b204,3-sjtxwokcpqwjznaugjrhckkcha.ykihejqt-iigrwyg.knc@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.73:@flex--andreyknvl.bounces.google.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100;04yf1hrsr7eik67arjbu1udtjxzypopybr4a81jxirz69fbx6kma1s95dqqdqhk.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: loaf97_5f07fa427162 X-Filterd-Recvd-Size: 6914 Received: from mail-wr1-f73.google.com (mail-wr1-f73.google.com [209.85.221.73]) by imf41.hostedemail.com (Postfix) with ESMTP for ; Thu, 24 Sep 2020 22:51:38 +0000 (UTC) Received: by mail-wr1-f73.google.com with SMTP id r16so278593wrm.18 for ; Thu, 24 Sep 2020 15:51:38 -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=6hEKAMD+f8HNSFJwh5TzY+nY9DWh+cKlQh2Jz/ohGSg=; b=pi/15Azt45EHWLyUtjCxlXB5enq1782kvIDG+8HU2qG3e2rtDhEkXonPnUZsi06Eto c470mfbeiXK1NxgcOSWoL1FRIOH44mHG2yJWE2hMsbi+6XfZYtLci63nTh7d84PsAyFX dCHugDmII/ET/tP7V/7iM7bhqtIUIxH60N8YAamPYhpXIint60KGfsU9905K+TupFc+T TcjCakSKr6Y5tFD6HtzMRmulXqXdEw4zPQMyaagB+ooFRbjjiVu3+BCr3DKJehbnar7t vzEv+kSY/nVc/4CY+RkziGeXHqBN1urvE15zA2G5G5h+QTf/ungLkJFTENh7nMT35UG1 CbNg== 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=6hEKAMD+f8HNSFJwh5TzY+nY9DWh+cKlQh2Jz/ohGSg=; b=FQBsAVZXuh1R1pszMTg6bs0xxegYPEQAbjwCN0GyKJk7Cwd0hrdhtThrDz8ulpAjgd u9eGdrQlHrXaNvGz8UUsL12uX1omvZp1X8RGr1im5fR336AVlU34Ojgo+TunmXS7m84s Dmh6LbhPU3xFJAH/Lpxd6okUAEVYAxIjuBRRyiXQoE+bp3kp60SrV9FQ5ZEJJJJQZ907 4JRk+SHSoxp5oGMnh0dLnxeJzjBJf3h3eJXVL2CH6d/0HRuOZ0PHLuRaP/Uc1zRzVxSk Q35q4+CP7UL4wvCc0/fx7UfidlGA9fZgkqkG/5vmcJoVIBurM23TQnN3gFi+cgFSyv7s HnUA== X-Gm-Message-State: AOAM530ntMSkeA0YMkLda2BsfJc47Ex2E1ugBk2cS8mZVshIdGYSYv8w zy2aBgaHSIuzLvAv0tOPvMiajL4bcxBGMqLO X-Google-Smtp-Source: ABdhPJy0Fc1EN8k6vuF5Zj2ENRUtTKs2pMRCxeNs9SFwi0xHDZj+TUg7dvgNLRkvlDFHpH1o2pdr0pz+NHKwkSyE X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a7b:c4d9:: with SMTP id g25mr846564wmk.15.1600987897744; Thu, 24 Sep 2020 15:51:37 -0700 (PDT) Date: Fri, 25 Sep 2020 00:50:26 +0200 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.28.0.681.g6f77f65b4e-goog Subject: [PATCH v3 19/39] 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-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 --- 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 67aa30b45805..13b27675a696 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -31,11 +31,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; @@ -238,7 +238,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) @@ -247,7 +247,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) @@ -257,15 +257,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); @@ -274,17 +274,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; } }