From patchwork Wed Nov 4 23:18:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11883265 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=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 4D7ACC00A89 for ; Thu, 5 Nov 2020 05:11:33 +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 AA95C206D5 for ; Thu, 5 Nov 2020 05:11:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mrV3tM1I"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="IRATQeJJ"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="ZSx/SUZk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA95C206D5 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=p/HVdRUMpAN4oGlluJTih86ZyJPVDlJZxI4WS6ZaxEk=; b=mrV3tM1II3MWgsqSzpqUvjt6Z TEdnvWEf1Sg8qK78bc2rSvuglxUEpWrgDVQPfs6XtdE2ZEobjqrEbwIskrkar97dBgNG4rLa4rglt byq/PAxO7GikHHG0px+gptkN3z3OtSDA9/BFbCvEURRJ/GkTSnfhn9PeZT/fO2OmbvDAbVkRsX7Z0 N+1QTmA9UClSeCP91xSHghTSRx7Y6pcQi7WZ/O6Iz9tTQbGQxSUFYvXDon4AgxR/i/CnGG56orDKq ZLjzwo0p/ImYSbY4LNRo4jhSXa+Isdx6seO7xOSBTb7i6bE2P1RHcNQDzJYTKs5gULIzf0vHyqG3V m3pF2zlLA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaXWa-0006YW-9a; Thu, 05 Nov 2020 05:09:28 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaW5D-000145-O8 for linux-arm-kernel@merlin.infradead.org; Thu, 05 Nov 2020 03:37:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=85BahkB/ARH3bXDyEMCLh1SMwp72o82khunrv9SMNJc=; b=IRATQeJJxmeValWU1A+w6G/NEZ eIlyLk76ZjDvOzDPU/ZUTmiyb15pljL7QFMs93Izf3VhjhRUuUnY11C2sChbhPrVmJFYI9+0i9cvG JF/sr+j+Hvf75+ISJcCanHLasde6P+CfpMmgmQZ9dSqYk9/fYMMgJ32lxaUvXqgdO4NAKoNf4u3xb W54wBwAQ7fgEUu1PNLBi1CCDGViNvR6XVAbmQxG+Us+RwXqgMq2EZyNG8dlrvx90F6fkkpyouoXPW dMbofEgF5Ex6p2gmal37QlA7ZfCaXLNMct2JJho4J6ItxuA5SxNh8p+I+ItOeD5aGd6AjKao1VNMJ QM9SkIag==; Received: from mail-qt1-x84a.google.com ([2607:f8b0:4864:20::84a]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kaS5N-00044W-CA for linux-arm-kernel@lists.infradead.org; Wed, 04 Nov 2020 23:21:03 +0000 Received: by mail-qt1-x84a.google.com with SMTP id l12so47697qtu.22 for ; Wed, 04 Nov 2020 15:21:01 -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=ZSx/SUZkoPccCRj9OftK35AirVXNnRtp71K5sDqNMlvALJiDEVVRbRbzni4v+KpEn6 DR5qqfRr/HSb/5m93J1kjvN9bTrwdSivj2gbYskR57KH3/2fnHjS49zgRnf0XLBh7rTs TLIRmN9t69+li/zc8WOODCJDawuxRFoF7JJjpm5OVD4kXwtUqZ64BCR+rdIOLKZHXzaQ aY/VSzpkX3qDkZyveOcv4Yk62lSY8x0QOg95iZjPHujmoFBUFcpb42QtebEUpYUUDvYs fGiNAL0NQynN6Gx32F2eyMAHd93Z8x7NZ1jLXOSvuSzfc4TN6tOuhfaz1zohnDWnSxBI 9TVA== 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=lLhG1V8CwUGBqmCAqmmlqvM291RC4rhSQDgGP1viVICwpUASpD5ul6j1RE2HKjM8C8 F7GR2wNK5QubimAMCCbM6fMdYJnpoKbAhNF778ZoGEJdZKICFjBFcZmtqT2GmFgYwKxs vUNTQm4vlC7kydWwqN/4uN2xyGNeZWw7jkFgGjERdevx743XFWv6/f1HYkr8rjOSxWHW O+TYnGH/JuQbokxXRTqG8cmdL/SK6MI+Yp02oQjPQ5pejuKCFMu8AP69riUCwDnqPd2Q v7LJ7kxc+N7YVGoV+m4TuiL2S9xsD9jUOeAtfalp4PeMs5fKgwp9YEdyvaQ2RBuM22kL nv/A== X-Gm-Message-State: AOAM533kdO8Uu8Npo8I7LtRA4X92QjS2DcwS9/OYH7LJpvXEUEkTdOET fkHLMamCcUNNVIx7K6fw6NHtfw1dtczKdQ93 X-Google-Smtp-Source: ABdhPJxfI6kOiOxV7S8W+SnVGnmgLZBRR87caA7tfhL0oTiavOqISUFp7aEvbTK9SlXVrVm0rxc3OyFfrW6Sbyp4 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a0c:a8e4:: with SMTP id h36mr421233qvc.24.1604531999270; Wed, 04 Nov 2020 15:19:59 -0800 (PST) Date: Thu, 5 Nov 2020 00:18:37 +0100 In-Reply-To: Message-Id: <5ec82ee9aaa25e2f15ddfbe292632de1d78b87b5.1604531793.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.1.341.ge80a0c044ae-goog Subject: [PATCH v8 22/43] kasan: rename SHADOW layout macros to META From: Andrey Konovalov To: Catalin Marinas X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201104_232101_522790_166B25EA X-CRM114-Status: GOOD ( 14.74 ) 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 , Andrey Konovalov , Kevin Brodsky , Will Deacon , Branislav Rankov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Alexander Potapenko , Evgenii Stepanov , Andrey Ryabinin , Andrew Morton , 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 --- 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; } }