Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3907566imw; Mon, 18 Jul 2022 17:12:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v64F4blccpTIXC0zOmH9Su304rDeGgo94u/dZ/hYdsIcwV82fKDyoNrbdHMoOJRtkj+QHk X-Received: by 2002:a05:6402:7da:b0:43a:6fe3:b7a9 with SMTP id u26-20020a05640207da00b0043a6fe3b7a9mr41163670edy.410.1658189578399; Mon, 18 Jul 2022 17:12:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658189578; cv=none; d=google.com; s=arc-20160816; b=w39FjdqBZtHdnFPHAlrX7KfY/xxI+/po8DjRlTn7AkkZmCv2Krl0HfhHs3jvWc0WZb gXxYnmrMw6KgypSIh/2bCbRXJN2+lRn4v8Tfnf/JsRnQAt2YrqvSdb7aY12SZmnGkH7D B4zCaangkS7ISK7HhiUpPOEcvq1daWFz5vlwDZDlrY70CAL24Z5eHiLAa/DsZg2pXwiz 6vbRfNwheDJQkKH8RsAJ9lLMtD04ZBJh4gnAYMt5LoMRKn97Y1rIuGboSNUuHHrQDUOm bHdHuqxrpglON0UO02sj0U4vN2yiCvhDKwhXgFYAPqUsG3/DkZoDI9BYrWM0Vj9B1qQv HN5Q== 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=GtkG5Wr6mLxaj0KDnAXzT5VwvOshmWOEVZwvcH5Zewg=; b=G/BLJoz8Q1tpvkjFBe3LVqyuFZP6BKwEZsYRiZg/4P4KI69+pWhOmQXcXWQEUA35nO SFdw54qEFZoOYOPNkN8wacCdhdic4LrOgY1P6FF45n6bXiCiRQd6Q9ueREAMDbSzeQgQ 1faqT9d7pFpb85TK5lf7VMkHqHqStoW8NWcGrPgZ5/eOudZ+A1cBxomyHMibO9jNw51b 6uAg4LoeM2o1qSysmQyxZ98isIKzoRSa8wnb4vPdgPjvR5nLs4lx9Bwwjv3mxTFgODjo WDAS2BmsnK7m8lfy+o2niqbIrSmCRRUCvz5phvhNOtfOaJcKiI7S2vuE+aV4tDK/arzg rHmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mN9bAq9G; 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 x3-20020a05640226c300b004356d09e34asi1493400edd.216.2022.07.18.17.12.33; Mon, 18 Jul 2022 17:12:58 -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=mN9bAq9G; 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 S235816AbiGSAK0 (ORCPT + 99 others); Mon, 18 Jul 2022 20:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233699AbiGSAKX (ORCPT ); Mon, 18 Jul 2022 20:10:23 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64CED2A411 for ; Mon, 18 Jul 2022 17:10:22 -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=1658189421; 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=GtkG5Wr6mLxaj0KDnAXzT5VwvOshmWOEVZwvcH5Zewg=; b=mN9bAq9GONsrVCTbjG80C24gOTIMa+xuIqPBtuKnd9t1EmZu9qiGd5NezacM1d9GvjRLK8 Gwe7MocFUFwRFZIXlCMnNgD+irIrHoko8uTkz6ClE3gAJYdZQGZizTArRoI4ljcXTyzo/6 slVf9IOinbUllaQpiZY1CbQC+FZddzs= 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 03/33] kasan: move is_kmalloc check out of save_alloc_info Date: Tue, 19 Jul 2022 02:09:43 +0200 Message-Id: <52c77b163f90a7d24a0a38f713b3849439387431.1658189199.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 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 Move kasan_info.is_kmalloc check out of save_alloc_info(). This is a preparatory change that simplifies the following patches in this series. Reviewed-by: Marco Elver Signed-off-by: Andrey Konovalov --- mm/kasan/common.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 4b2bbb6063cb..a6fd597f73f5 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -423,15 +423,10 @@ void __kasan_slab_free_mempool(void *ptr, unsigned long ip) } } -static void save_alloc_info(struct kmem_cache *cache, void *object, - gfp_t flags, bool is_kmalloc) +static void save_alloc_info(struct kmem_cache *cache, void *object, gfp_t flags) { struct kasan_alloc_meta *alloc_meta; - /* Don't save alloc info for kmalloc caches in kasan_slab_alloc(). */ - if (cache->kasan_info.is_kmalloc && !is_kmalloc) - return; - alloc_meta = kasan_get_alloc_meta(cache, object); if (alloc_meta) kasan_set_track(&alloc_meta->alloc_track, flags); @@ -466,8 +461,8 @@ void * __must_check __kasan_slab_alloc(struct kmem_cache *cache, kasan_unpoison(tagged_object, cache->object_size, init); /* Save alloc info (if possible) for non-kmalloc() allocations. */ - if (kasan_stack_collection_enabled()) - save_alloc_info(cache, (void *)object, flags, false); + if (kasan_stack_collection_enabled() && !cache->kasan_info.is_kmalloc) + save_alloc_info(cache, (void *)object, flags); return tagged_object; } @@ -512,8 +507,8 @@ static inline void *____kasan_kmalloc(struct kmem_cache *cache, * Save alloc info (if possible) for kmalloc() allocations. * This also rewrites the alloc info when called from kasan_krealloc(). */ - if (kasan_stack_collection_enabled()) - save_alloc_info(cache, (void *)object, flags, true); + if (kasan_stack_collection_enabled() && cache->kasan_info.is_kmalloc) + save_alloc_info(cache, (void *)object, flags); /* Keep the tag that was set by kasan_slab_alloc(). */ return (void *)object; -- 2.25.1