From patchwork Mon Sep 5 21:05:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12966562 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 79684ECAAD3 for ; Mon, 5 Sep 2022 21:09:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DF8958021E; Mon, 5 Sep 2022 17:09:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DA78780214; Mon, 5 Sep 2022 17:09:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8ED9A8021E; Mon, 5 Sep 2022 17:09:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7416A80214 for ; Mon, 5 Sep 2022 17:09:14 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 545121406FE for ; Mon, 5 Sep 2022 21:09:14 +0000 (UTC) X-FDA: 79879272228.13.3749573 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by imf14.hostedemail.com (Postfix) with ESMTP id 08A1E100055 for ; Mon, 5 Sep 2022 21:09:13 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1662412152; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YPa6DnblrUNaCp9j+8qvSRfWbXda4Oig2+szurtqS5U=; b=P0d43fe+3wGAFcrC6LDIh/5J48+Rry8ffhGKlcuU8MyISOKghMHY8IYQT6GECImv5BA1M+ Hgl8GxHRu/SVfoDKtAbLuCg1vxfHq9l2vM7giCDhUTyB8eVf5154B3+bygdw3702ozUpbY b9vde8MCEZBMxx8nzGb1ZyrrVQJJYjg= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Peter Collingbourne , Evgenii Stepanov , Florian Mayer , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm v3 23/34] kasan: use kasan_addr_to_slab in print_address_description Date: Mon, 5 Sep 2022 23:05:38 +0200 Message-Id: <8b744fbf8c3c7fc5d34329ec70b60ee5c8dba66c.1662411799.git.andreyknvl@google.com> In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662412154; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=YPa6DnblrUNaCp9j+8qvSRfWbXda4Oig2+szurtqS5U=; b=B21IF0w3gaujmDSZ0Vv1ObGfGYfReFmaMQfT0I0jw1wgFqoc8w/5s0NVX/wdaOh8GhNIJT h91GGQNk/SoKheSwAAqRlyQkr2qC7dSjnMJ1gkxXsMkS8xazR6fU2HesVkvDTUsymAU4vn +pIKSHOzOKNbWnSoJiV2hZYXc6jZBQQ= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=P0d43fe+; spf=pass (imf14.hostedemail.com: domain of andrey.konovalov@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662412154; a=rsa-sha256; cv=none; b=keRHsmO2XWgGlHaF7PEJ4GvmGFoGad9qW/McltLb3UtWBFUSqORvTGm19N30XGU82CwfN4 ew4M8xoXU9q+AhoDaf87ylw+euzhLhm4NFtia8su2sh2sf8lv55L/rGvaGc6JOQLRhCGTm 05icjwYimSeZ0/msITA8zd4F96Lx/20= X-Rspam-User: X-Stat-Signature: c5aakpfrkpt1x9tdihswiusz8abj1w6s X-Rspamd-Queue-Id: 08A1E100055 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=P0d43fe+; spf=pass (imf14.hostedemail.com: domain of andrey.konovalov@linux.dev designates 94.23.1.103 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Rspamd-Server: rspam04 X-HE-Tag: 1662412153-19827 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: From: Andrey Konovalov Use the kasan_addr_to_slab() helper in print_address_description() instead of separately invoking PageSlab() and page_slab(). Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 7 +++++++ mm/kasan/report.c | 11 ++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index f8e16a242197..50f4338b477f 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -30,6 +30,13 @@ #include "kasan.h" #include "../slab.h" +struct slab *kasan_addr_to_slab(const void *addr) +{ + if (virt_addr_valid(addr)) + return virt_to_slab(addr); + return NULL; +} + depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc) { unsigned long entries[KASAN_STACK_DEPTH]; diff --git a/mm/kasan/report.c b/mm/kasan/report.c index 570f9419b90c..cd31b3b89ca1 100644 --- a/mm/kasan/report.c +++ b/mm/kasan/report.c @@ -213,13 +213,6 @@ struct page *kasan_addr_to_page(const void *addr) return NULL; } -struct slab *kasan_addr_to_slab(const void *addr) -{ - if (virt_addr_valid(addr)) - return virt_to_slab(addr); - return NULL; -} - static void describe_object_addr(struct kmem_cache *cache, void *object, const void *addr) { @@ -297,12 +290,12 @@ static inline bool init_task_stack_addr(const void *addr) static void print_address_description(void *addr, u8 tag) { struct page *page = kasan_addr_to_page(addr); + struct slab *slab = kasan_addr_to_slab(addr); dump_stack_lvl(KERN_ERR); pr_err("\n"); - if (page && PageSlab(page)) { - struct slab *slab = page_slab(page); + if (slab) { struct kmem_cache *cache = slab->slab_cache; void *object = nearest_obj(cache, slab, addr);