Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2934201iog; Mon, 20 Jun 2022 07:47:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uVpwpt77dU2PugrNgNCRxQfxlpDgLrgsJTOLiNQxRE/EILluEPOyJcG5fNjqQavoQG8/iv X-Received: by 2002:a17:902:f806:b0:16a:f71:cc86 with SMTP id ix6-20020a170902f80600b0016a0f71cc86mr13627674plb.111.1655736471447; Mon, 20 Jun 2022 07:47:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736471; cv=none; d=google.com; s=arc-20160816; b=r5Ki0n01/PmpotC1R3FA3fX7j2FfQwfnIqLQC1KDpTNTGZ+fI12USm4XxDFMGGoX6T ZyxlBMV7Ec6RH1+g7NucrFeBMoTbjoMusVEaexcgx/W59BzVwrStf5Jj1LqUDOxYPGlm I/pU3qzt1YtBda80BkGrOYcduHHWUEXOnoNRLOlw+/MVq85KUlULepMXN8dqMDgMe3hg 0+qb8rat3dMf7W+6JqOPNePueSncjEOdIw7Oy/wFVEMMwBn7FpFYHwyLUVT1x9p35LrW 7VUf754vMOza5w5xHnjz+VXrEuE2YhqwZzt5kjydPk3dkPfF4BnDgqMI3iuqCx3KeM4H xTKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=G3ftVDEg1TDDghcSSxJkEC5/y2JJbqzI/pYg/LWTE5M=; b=BaCKvc8yZPI2FzNpY0P/KYalkK7LXtnpEqIGD7VTGFiFXPDJYweV3YNn4uk5dDmyAV B0npzDIsHw/cePhDGkFq9jyhbWSI07xa+XoSJwU7wxd75Lv7VSIbl8CTML1Hi0kfv9LI YeATtY+S5Y4wZpcuLxvRqF42GcoMdzDdkTMGhN17whgJTILahuKHERdZ8pHNDUZKH2Jv gXYG7hFdRkYCO/6JGzanPHqmioHTpPiWrvttE0YdtcNMuP3CfGaVHMCvV4VeOvnsB321 /7c4QbzVPnOG4iuG4NaDhuhfQ2RREbq90cey7TwtygkKEb5TH/ackHybS3W//0/5b6+L 3gjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=eQi9zaET; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a056a001a8b00b0051e67c938fesi16761806pfv.272.2022.06.20.07.47.38; Mon, 20 Jun 2022 07:47:51 -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=@google.com header.s=20210112 header.b=eQi9zaET; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235376AbiFTOZJ (ORCPT + 99 others); Mon, 20 Jun 2022 10:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351146AbiFTOYh (ORCPT ); Mon, 20 Jun 2022 10:24:37 -0400 Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13B9328E3F for ; Mon, 20 Jun 2022 06:40:22 -0700 (PDT) Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-31772f8495fso99753027b3.4 for ; Mon, 20 Jun 2022 06:40:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=G3ftVDEg1TDDghcSSxJkEC5/y2JJbqzI/pYg/LWTE5M=; b=eQi9zaETbW4lHIIHxYGnQFaf8AKQt0sBKp0IbSlyW9dV5l1FyBP28/JhSX7ZhHu+EC tq9L0qSxqCjnYc8aQp21Dd+5qgn0BytcW0NQTRXtMcAQa7B+KEsgsbEmNd6TAlPi9AIQ ZZOT1mZeBnc/gpoJG9mRYLpUl2CTZMQwYc/Cjht516keHKmlelKQqbybpmzoSewBOAlb P8TTBOQauRSlBcojdTn+Vvy+OZRLdawcAIc/nuA2hRx8y0fw6cRh3e48d3wxu6Ao3go3 YpU8fhOcLfj3jeqCwfG7NEi3xcWiwxHToSWrmUMunOpsbs0chbwsMR1i5RxQjQsiyVuX j7cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=G3ftVDEg1TDDghcSSxJkEC5/y2JJbqzI/pYg/LWTE5M=; b=mZMa72Xi4lapTNSqoRdAfJyKkBlgsUVZ3KM7W18CQFVWzIipL768KxCT38LV0c32d5 XskxA3e08Zw+rFbXGgnKNO85a0VLyGrHuYaCi7TzYdhm4IWCCiSLUg0PJazTsaGvy0Hc 15H4HGhSdx25vkOh8ZDHYZ9tpxonEjHXP1OxtRSf10seAWCIvOYQnlC6sPZYhf6XDpyk YDuMBzAexGTvyONtdZVBH/+yvEcpcG0QgyxHJwRO6lRfStJzFxtiq4TzvGiBzLoyHeVU 4Su7slcOQjzsjvDFrFSllZWQ/3sqM4xq1RO2LJT6HMaM+KFUHWPOMBO2WFfxeoMTuknu rSDA== X-Gm-Message-State: AJIora9Q1H4GdYm6TuKLei29g9ysTicIMtJ0w6TwUhXviG/tOzGJkZgi pCjy9Wf0qN2nXyLIDs+gFRRFO96t5smW+6MXx+XNbA== X-Received: by 2002:a81:3a12:0:b0:314:6097:b801 with SMTP id h18-20020a813a12000000b003146097b801mr27848775ywa.512.1655732421684; Mon, 20 Jun 2022 06:40:21 -0700 (PDT) MIME-Version: 1.0 References: <184ac9df81406e73611e1f639c5d4d09f8d7693a.1655150842.git.andreyknvl@google.com> In-Reply-To: <184ac9df81406e73611e1f639c5d4d09f8d7693a.1655150842.git.andreyknvl@google.com> From: Marco Elver Date: Mon, 20 Jun 2022 15:39:45 +0200 Message-ID: Subject: Re: [PATCH 07/32] kasan: introduce kasan_get_alloc_track To: andrey.konovalov@linux.dev Cc: Alexander Potapenko , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Mon, 13 Jun 2022 at 22:16, wrote: > > From: Andrey Konovalov > > Add a kasan_get_alloc_track() helper that fetches alloc_track for a slab > object and use this helper in the common reporting code. > > For now, the implementations of this helper are the same for the Generic > and tag-based modes, but they will diverge later in the series. > > This change hides references to alloc_meta from the common reporting code. > This is desired as only the Generic mode will be using per-object metadata > after this series. > > Signed-off-by: Andrey Konovalov Reviewed-by: Marco Elver > --- > mm/kasan/generic.c | 14 +++++++++++++- > mm/kasan/kasan.h | 4 +++- > mm/kasan/report.c | 8 ++++---- > mm/kasan/tags.c | 14 +++++++++++++- > 4 files changed, 33 insertions(+), 7 deletions(-) > > diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c > index 98c451a3b01f..f212b9ae57b5 100644 > --- a/mm/kasan/generic.c > +++ b/mm/kasan/generic.c > @@ -381,8 +381,20 @@ void kasan_save_free_info(struct kmem_cache *cache, > *(u8 *)kasan_mem_to_shadow(object) = KASAN_SLAB_FREETRACK; > } > > +struct kasan_track *kasan_get_alloc_track(struct kmem_cache *cache, > + void *object) > +{ > + struct kasan_alloc_meta *alloc_meta; > + > + alloc_meta = kasan_get_alloc_meta(cache, object); > + if (!alloc_meta) > + return NULL; > + > + return &alloc_meta->alloc_track; > +} > + > struct kasan_track *kasan_get_free_track(struct kmem_cache *cache, > - void *object, u8 tag) > + void *object, u8 tag) > { > if (*(u8 *)kasan_mem_to_shadow(object) != KASAN_SLAB_FREETRACK) > return NULL; > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h > index bcea5ed15631..4005da62a1e1 100644 > --- a/mm/kasan/kasan.h > +++ b/mm/kasan/kasan.h > @@ -282,8 +282,10 @@ depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc); > void kasan_set_track(struct kasan_track *track, gfp_t flags); > void kasan_save_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags); > void kasan_save_free_info(struct kmem_cache *cache, void *object, u8 tag); > +struct kasan_track *kasan_get_alloc_track(struct kmem_cache *cache, > + void *object); > struct kasan_track *kasan_get_free_track(struct kmem_cache *cache, > - void *object, u8 tag); > + void *object, u8 tag); > > #if defined(CONFIG_KASAN_GENERIC) && \ > (defined(CONFIG_SLAB) || defined(CONFIG_SLUB)) > diff --git a/mm/kasan/report.c b/mm/kasan/report.c > index 35dd8aeb115c..f951fd39db74 100644 > --- a/mm/kasan/report.c > +++ b/mm/kasan/report.c > @@ -251,12 +251,12 @@ static void describe_object_addr(struct kmem_cache *cache, void *object, > static void describe_object_stacks(struct kmem_cache *cache, void *object, > const void *addr, u8 tag) > { > - struct kasan_alloc_meta *alloc_meta; > + struct kasan_track *alloc_track; > struct kasan_track *free_track; > > - alloc_meta = kasan_get_alloc_meta(cache, object); > - if (alloc_meta) { > - print_track(&alloc_meta->alloc_track, "Allocated"); > + alloc_track = kasan_get_alloc_track(cache, object); > + if (alloc_track) { > + print_track(alloc_track, "Allocated"); > pr_err("\n"); > } > > diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c > index e0e5de8ce834..7b1fc8e7c99c 100644 > --- a/mm/kasan/tags.c > +++ b/mm/kasan/tags.c > @@ -38,8 +38,20 @@ void kasan_save_free_info(struct kmem_cache *cache, > kasan_set_track(&alloc_meta->free_track, GFP_NOWAIT); > } > > +struct kasan_track *kasan_get_alloc_track(struct kmem_cache *cache, > + void *object) > +{ > + struct kasan_alloc_meta *alloc_meta; > + > + alloc_meta = kasan_get_alloc_meta(cache, object); > + if (!alloc_meta) > + return NULL; > + > + return &alloc_meta->alloc_track; > +} > + > struct kasan_track *kasan_get_free_track(struct kmem_cache *cache, > - void *object, u8 tag) > + void *object, u8 tag) > { > struct kasan_alloc_meta *alloc_meta; > > -- > 2.25.1 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/184ac9df81406e73611e1f639c5d4d09f8d7693a.1655150842.git.andreyknvl%40google.com.