From patchwork Mon Nov 23 20:07:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11926593 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=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,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 A20ECC2D0E4 for ; Mon, 23 Nov 2020 20:18:35 +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 20740206E5 for ; Mon, 23 Nov 2020 20:18:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="3Oua0a6M"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="fLNjLZHK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20740206E5 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=X7pFl5iMCEySzEbBkIuxr5QTtI8c0svs7Ee0dPZFvmE=; b=3Oua0a6MiTyxLNNo7kIgfc7XD R7IS2DPeHHIMTikvsynC9wsPkx1ZAt2zmZHp5Y1cqAzYVS02UWjRDvj/foUz30KIQ1ic2cMHm6Wsa 83Ie9HAQxqF8wWk6ZwPdUYUHlb7ach+M87wgI9YpEbWYvn9lXrJadvwM0drt/Nd4mKqouYe/rl/mx TIcTICnrERdWKVMz+bJiAkWwyRgUehilq3c2Gcmq3RLCJU/3iF64yvpV0YUFMwjL8oqbyhAWyGGAs XeQyA/5GJOmIeK2KAkqtj5gjH2d3dBX4+dp/BgVWG4l0pFbVPRYggm8hzkstLb1q7sDiX+/syk47W ZnHxMU1KQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1khIFK-0002A8-MS; Mon, 23 Nov 2020 20:15:39 +0000 Received: from mail-wm1-x34a.google.com ([2a00:1450:4864:20::34a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1khI9A-0008BH-VM for linux-arm-kernel@lists.infradead.org; Mon, 23 Nov 2020 20:09:37 +0000 Received: by mail-wm1-x34a.google.com with SMTP id a130so315021wmf.0 for ; Mon, 23 Nov 2020 12:09:10 -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=GcVKnuDfFzQJ9e5llEgSJzxpADe2yFJHu5NkpPOoYoA=; b=fLNjLZHKWHQJNdwRPJsSxkIZL/JkuBgX6paJWA75DhPzusGy5pBQlnRoj7DUC4OE9J /dHx0FFxPlcalr/FT45oa5ua3HOb6Jr210oolLSIcOcloAmip5jJ5dZN/mibG+uP1SOt 93odu3MPyMfNZhulD8fxPO3eLk5Y0iXhZ8pMaqR1fwEvp+EGh0dYdUe1nUqEorbD0ksZ 36nqGDWKmy9RjQtEUbBW/h7NncW+6md6FVRMgFl5BMOT1NsLdbYTXRoldvriR3FkeIzp B1Jo4Hd7wx7A+HluESDMn0fFZ5T1x9zUiwB50hJezF6a9/ijx+AQ06wHrkJ4KeBgt4AH ExOA== 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=GcVKnuDfFzQJ9e5llEgSJzxpADe2yFJHu5NkpPOoYoA=; b=omgizmWF7Xfe03FL8wBsvZKGUWRWDiUmiKicYDX7e3rV4z+Gj7lTB5mRrvrpnWPxcz acoQWiEDg2CTv4qt3wfL0dJsCGHZTQTGNYdDk3PIAWBHbGLCacmAn+Y8iQRAkKLKSvYV zjdpWCh1FBta6ydz7KOAB9a3543X/0CWXgt+JI8big/rKQQmwcyQv520hsw7R56sYwzT i/yKZMYbnfzsAoGzQwWPKrcdo6klG97fm9u8DSx+G5NCuwA3WwlZn9ZW5L9GoG6/J7RM alYaWwDHP4FLo1Hu48K4TQ85TUgMdOmd2aWVZQLuqrRVUJRvK/b0BWqIKr0tr7bOp5mG xTvw== X-Gm-Message-State: AOAM5314Mj6MFxXS5VI9POGtfHN60kYUk77QWozd+I3S4tULSfZCFjEl XRMQYotnx0fprogn92yDvAglD6cw2uXrqTGg X-Google-Smtp-Source: ABdhPJzsYjs2bIFcwXl3lHTmf71+QwbgCoQxk/IAfOMMcr6012AXQF+ky9MJNqswjBQkrZdJsGaFpBBNzpDtDav7 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a7b:c0c2:: with SMTP id s2mr613063wmh.78.1606162149371; Mon, 23 Nov 2020 12:09:09 -0800 (PST) Date: Mon, 23 Nov 2020 21:07:44 +0100 In-Reply-To: Message-Id: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.454.gaff20da3a2-goog Subject: [PATCH mm v11 20/42] kasan: rename SHADOW layout macros to META From: Andrey Konovalov To: Andrew Morton X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201123_150913_106924_E783D909 X-CRM114-Status: GOOD ( 15.21 ) 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 , Catalin Marinas , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Konovalov , Andrey Ryabinin , 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 5d5733831ad7..ab28e350bf39 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; } }