Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3953101imw; Mon, 18 Jul 2022 18:17:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uqrJnL9bojfRkS8dmnbmA2DdXlo1ukXcTVgwcytTtMsVdWqFa9m8/mHRNPXQaoT48vLmNU X-Received: by 2002:a17:906:5a5b:b0:72b:39cf:6042 with SMTP id my27-20020a1709065a5b00b0072b39cf6042mr27660411ejc.301.1658193427932; Mon, 18 Jul 2022 18:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658193427; cv=none; d=google.com; s=arc-20160816; b=iToDcV3yMJ9Kr4L3iKLGVylvz3yqtAbK8fj1zmnR2rm6fKhtAtbWkSM5liuER71Nw7 1BZwvktCR+1//0cDtASIzxeyQEFEMHxUFUd+RU8rT7uFugBmK93ovtJNp6LiCKPX2zbg iJ2igmAc3/W0N7LpH8lo9ukQHxk4jnqsNO+DDcIaFNsT609iwSEn5+4zcqWabLIi11Jl FjXnY3L79ZX3b3dF7hdqSjC6tXLQIsnaDn9gPH9jYuQsIdBTMaKNIAFw/Q1v7D/ftrNb 5EnHBKO7bytEGLU+MiETCRAXL4hHSgoN/miawPRIM9qARnKs3GCeCjYA/RHGqNmcwDQy yh7g== 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=O4rrLBlHP9NeNLXeiOhUcDB35KsXuF54OmWKXqnLQEA=; b=PI3l9MIyFKHhyXoQ1C2OFKZC1Yq4DuBRpzSNARGA8lzGVPJ1+2OitTy83NLuDavUvJ BtnDeX+Ogm9MVm+c+oMw/LP2c+NaOAiyNTkywhMXuZGkfNYkmL30xFOOwP/DegS+IADf /Li13Sbp0lvwCL2N+9ZsYTZewSl7De2NFlHLHYGL+q0bld5cn4XOWkNTh1xpwejmNMSc UtF6gzzut+VNXZQTA5v1KbTrJJx5+GwI9oPyT1iCWOlL173k8DRqxKGK0aWuxmW4z9Bu eNrr2BrkM1OeEkR7VyeIhXmwdeSHha2l2Qfe3kaGPRUiBHhf0mHceLLacps5MlmeR6Gv hrKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=LVpP162e; 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 c15-20020a05640227cf00b0043b72785901si2575593ede.413.2022.07.18.18.16.41; Mon, 18 Jul 2022 18:17:07 -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=LVpP162e; 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 S236653AbiGSAOA (ORCPT + 99 others); Mon, 18 Jul 2022 20:14:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236650AbiGSANt (ORCPT ); Mon, 18 Jul 2022 20:13:49 -0400 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8EAA110 for ; Mon, 18 Jul 2022 17:13:46 -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=1658189617; 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=O4rrLBlHP9NeNLXeiOhUcDB35KsXuF54OmWKXqnLQEA=; b=LVpP162eLUxzWlXtaxlkTzHQo3R5Fis/5GLAtxi/j6wpKDGiKXVYJoi7lSpsJ8H2ipShH9 U67DZCr01gJUMpX9uvkhL3FAd85KZadfQH+1BRwA8i0tq68mD/rOmLQleoXo9DYfuRbNhW /JFX9VzJnoP/OSo0f9jEPUzSBkqyKBQ= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Peter Collingbourne , Evgenii Stepanov , Florian Mayer , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm v2 23/33] kasan: use kasan_addr_to_slab in print_address_description Date: Tue, 19 Jul 2022 02:10:03 +0200 Message-Id: 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 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(). 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 3dc57a199893..cfb85b65fa44 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