From patchwork Fri Nov 13 22:15:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Konovalov X-Patchwork-Id: 11905001 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 67585C55ABD for ; Fri, 13 Nov 2020 22:23:17 +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 16081207DE for ; Fri, 13 Nov 2020 22:23:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hNK8AtVu"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="F819WbWf"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="cFI3+DUN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 16081207DE 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=A7JSefqM9ELnSc4f3szjyvdShClxIHIv7+TZTV1QGmI=; b=hNK8AtVuWCXH+8Rk1x9FSqN4i mPB4ojprPUgQX2G4iIxu02/eu0iRxeQ+jS2L2pYlE7EDx3Rh+btBlAmYxIGHKVo0x/0KVr/yYk11P 9TBatgovIWFdUNXDSc4mrqzmmJNYxpjP/FheXjYUvT5+AInEdLb4sW3ep3ub389A/qaamaWgYCvmL +Wp4p4lCFqhHGrVqa4oWzrV4S/WN+3VqUAt5XUToshv+B44cmXQ7ovAzK6rZZLygcIj7eHXwYuZM+ JDpIPJGXywVxVuqoEzDPnJxTa8Pq3cbPkemxAfGA78C2fVa6aPtpHK/y4595MDVRquehIIDtqJB2U tkJU3/ndw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdhSo-0002Qu-Bh; Fri, 13 Nov 2020 22:22:38 +0000 Received: from casper.infradead.org ([90.155.50.34]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdhNY-0000CV-6T for linux-arm-kernel@merlin.infradead.org; Fri, 13 Nov 2020 22:17:12 +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=QYRwj45esNxqkksolgMCeqJEQQGw+HRSTbdJ2ZvWQ1s=; b=F819WbWf9z5aFflYfv9UxHLAKU VpjBNL6KP8R8SUCYtYOI61hfImEEBamxUGSSaNZGyiLjiC1mdEnAvL+jskhC5oCQTe1x77cvDtTg8 Zlidxy0EUp3Ko0lUxsgZshxrqzDV4g2gy3YNe09ZuicGtSwTF6YG4qzDzeC+YKuulqDfAo+vekP+S Ueo/YjCTisFC0RitsvMyAkTazrf2yyjO+7ZXh319VL+B4buUuwH4oV34fLlPHvCRm6Ddmmx0A/3Ep E6IVLLOQt1f+Aj730qlduZXz3W1JDzKbxsnKOwebyFXWIF/9f72XKz6AvWHEsKVJSSEdh//SH2ZC1 65ZBi1zw==; Received: from mail-wm1-x349.google.com ([2a00:1450:4864:20::349]) by casper.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdhNT-00088D-07 for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 22:17:10 +0000 Received: by mail-wm1-x349.google.com with SMTP id y1so4708596wma.5 for ; Fri, 13 Nov 2020 14:17:04 -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=QYRwj45esNxqkksolgMCeqJEQQGw+HRSTbdJ2ZvWQ1s=; b=cFI3+DUNXc9zoE0dd9K3hPxn/jBFVW3ahi80mEd2ySS83lhVRG4JQ7Z5/TWKSbYhZ4 PI9BEHFrfBpG2+IHkZxPxhaQkjlyRa7DZg98vAnuKnzeFqwLeZKxQascwe9/PVk01zBp ByIzJ8U42iIsUmmBJ93jmk4WEv9PWYArFrnAD4aXv2XEP1TG3a+ZHbGkkPiWIltMdqWX MVjkIxh+xOpVY5FJlyLRBIVQ2RZI2bSgjC7SFO2KKusbz/GwgDRMTDL+//g725dYvTl4 Kh1jLxswZBPHbnqGKUYBpOKUkIEyaA/e5mMYkbGpsViwnChrlkRTu3s53uY12jCFRZye 0xkw== 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=QYRwj45esNxqkksolgMCeqJEQQGw+HRSTbdJ2ZvWQ1s=; b=PZTAzvuwOSPIEKiXtFkadiR9pHGN+0BN0iIBgYqDl3kZw1ygUu6MZaH2+jIwSTfImg 6dv7mltiBUR1kavg6h7XNEiTbBPxEyUpkf/zCpNIwhXkEPYuetFcJ9DVbo1IujBaW7Rp qaNfwq0t72Iew2buOnmVAoWzfrCDz9RSFPw5LJW23G5HQyte4mP3KY3s2+0rRsuSiyTE 61spPMWeibHYM+7de+n8LLIuqWQhSiLO6uF+Aqq02gLfGm+6lQnhEAkAEPxSxjjt9aOb PUznw3Wn9gyfq72bIDVeGVWdk1uW7JlEEyO3WAbSziVG2HIgAnnNNhrtemLSKj2F9D41 2sEg== X-Gm-Message-State: AOAM532mrX84ot3kbuhogNlrkMxcYqWB0dxfZzSTKwB3R+0MWSicUlR0 kQGminyc2DuE0rdwQqFaE46PLOJ7STbOae1M X-Google-Smtp-Source: ABdhPJy2t8mXpkKGyRiu3xQl7ElMvtgFvArCdRdYwoZ9lCMUkAzsyDJc9a4VHKEOK1rddlTLbeNqm/JViG8hQ2u7 X-Received: from andreyknvl3.muc.corp.google.com ([2a00:79e0:15:13:7220:84ff:fe09:7e9d]) (user=andreyknvl job=sendgmr) by 2002:a1c:4302:: with SMTP id q2mr4664612wma.182.1605305823252; Fri, 13 Nov 2020 14:17:03 -0800 (PST) Date: Fri, 13 Nov 2020 23:15:48 +0100 In-Reply-To: Message-Id: <34062aea525fd3eda186646689d41dc74accd852.1605305705.git.andreyknvl@google.com> Mime-Version: 1.0 References: X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH mm v10 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-20201113_221707_443438_C221697A X-CRM114-Status: GOOD ( 14.37 ) 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; } }