Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3592465rwb; Mon, 5 Sep 2022 14:54:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR55N0OY8I29SJhAnySKLtKdJJw/i9+U9CO3YUc0v847K/K6Dn2gIkWHMeC8yPALQEfL9DmW X-Received: by 2002:a17:90b:3504:b0:1fe:49ba:b71a with SMTP id ls4-20020a17090b350400b001fe49bab71amr20878970pjb.99.1662414884782; Mon, 05 Sep 2022 14:54:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662414884; cv=none; d=google.com; s=arc-20160816; b=zonJpeII7DLRFrT4CqxDB8GTFcVBvpmpyU6EIjgtdPOt4NMVkQUOAu7lWR6sqevHpJ EJpjD0uQZrFd0b+cHwV6FcP0i6eNhvDWxTAngoqoNvLxvlMY9szqzBei1jNjIAAoBgu+ frnNbmychCcYYLHVen6jzDlB42J2iJHm1hoXIIxd/Gg38mjuHbWtQeku24F9NwStiNtW GVtUkcYTopbMPrTTtvvtEUipQy6Nk/WhlUex/cW0KTwMRcIThZ8kki943Tiv1UufQnPV EAk8ogR1UCG0Onldrb4QLGpv4eBYfqs/6VCmDfsFlDuFK7bKqG2iiiDJ72YyBNKV43oB sSQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YPa6DnblrUNaCp9j+8qvSRfWbXda4Oig2+szurtqS5U=; b=YP1VNA/SUnZ4QNDvzN054vXSahiSpyDROij9H0iLY7gcvMUH++oDXl+PFdGfF2RYHX DpkZCwCtfj+EnrIRcZMxi1/536x6ZkleP7bAaHw+BgzM4pOpv2ZcKw0aYQiQt9QSSz4s oewhVWhIPLGptH6OdnhZ3Id+ZJHe4LUS+QTBvI4t0x5h7Je4JssvYNoV+mQvyGIJfD4Z OSby8IA+tQsevGw4ZGHl2kPAOIafwHS76a8wRbu8CUtr/7jWC4FuZQo/FUf9NQVkd+Ov fYjefD8UVOohWaIOTKSIqws/L4q3gR4coSUCFY79E44oa3keXhrkzeC+TJd7m2LwMm1m /pNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=P0d43fe+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a056a000ac200b00535dfe411cfsi12130016pfl.189.2022.09.05.14.54.33; Mon, 05 Sep 2022 14:54:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=P0d43fe+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237896AbiIEVKT (ORCPT + 99 others); Mon, 5 Sep 2022 17:10:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238049AbiIEVJ2 (ORCPT ); Mon, 5 Sep 2022 17:09:28 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 597E9659FA for ; Mon, 5 Sep 2022 14:09:19 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.25.1