Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp867632iog; Mon, 13 Jun 2022 14:54:34 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vTA1Po/7g290LKa3s1L8Mjlix9ZqXQBlkjq2fuCUKIFYXrmofU/Qgx/TEaa4mYHMxFAG3b X-Received: by 2002:a17:902:b68a:b0:168:c167:819f with SMTP id c10-20020a170902b68a00b00168c167819fmr1173432pls.96.1655157274051; Mon, 13 Jun 2022 14:54:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655157274; cv=none; d=google.com; s=arc-20160816; b=ibyAiWGFpnbdDW+OSTvdWlVqGIY6XJ5QzSl8k2maytcMXE3BDeIgirtFNtrF9p6MF+ 8QV2bctTnhg4HD1CvAm5t7poKBmLGEzVD9ltQkVgfvZ/SlQLeUN9hZWF2+a1oHh5GB/W 1DKz2gRjREWRZ9NCMrf1vOLBxWq2HJ9QASt2r1P8ei6EeVCuhntY+SS79MZt1LGwTK9/ f/QPQNv0sLedEEqKo3RTc36q8k8ozw/gKkqwf+92uKbl59SKkVAFd26lqLc0YAg7e6Ag TP651qq5ycNlXVcn14D5MAoWkaHzqLU+8MkHHs18F/byk4Bt/XghjA7wsakxB/ndfcLB HMKQ== 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=5YxZt8AJdg20zeg5mlaLc0cE80lCSk74fkwRwLQH28g=; b=EJml6YSzsjx5M4j1TtOBq1HhqMtDGQyi8+u4f2ZjLajuroH94Mw0/GCNtnDlltC+XW 7+cMG8iehhYngE/uTGyGFvkNW3KVFb/xnBDb4Ypiloj7klm7nIDm7XjXT/TF9nSHCGq5 qWBq3vbdL2BXS2AbmM1YrRsvIdPG/gM/jfwuaxn20IV6U5hr1hLA7TVI17/qKNgQpXLH cUdCstGUEeVwlFMb42KGw3TRL0BLvKXGlAv1CSaKR/ym9mAf7XdciDWisYoEniPV8qv7 ntSOeURSea9013OASla3jnWOMsYUYoNUG4Ub4somD4giVUY3HXqhYCCdlo5OYtkE61Mb IY+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="vNtdLTu/"; 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 f64-20020a636a43000000b003fa6b42a47bsi3669436pgc.837.2022.06.13.14.54.22; Mon, 13 Jun 2022 14:54:34 -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="vNtdLTu/"; 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 S1351204AbiFMUyx (ORCPT + 99 others); Mon, 13 Jun 2022 16:54:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350763AbiFMUxS (ORCPT ); Mon, 13 Jun 2022 16:53:18 -0400 Received: from out0.migadu.com (out0.migadu.com [IPv6:2001:41d0:2:267::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0363DDFDE for ; Mon, 13 Jun 2022 13:15:27 -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=1655151325; 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=5YxZt8AJdg20zeg5mlaLc0cE80lCSk74fkwRwLQH28g=; b=vNtdLTu/n3uZXNxwSADnWXXhRvSCEmqvLH3FjLwQYNnr7TcYt1H3qoRfDAzhIfr++YtDwz DKhTZe2bKI12WI17MUbeLtNkumWSZskhDTHfG69P2kj/KpodD0zAj2B3BsQUqDUogXpISQ 4ac6Q6f0pE/XLiSdQl54Sxg/q37QO3s= 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 03/32] kasan: move is_kmalloc check out of save_alloc_info Date: Mon, 13 Jun 2022 22:13:54 +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,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 Move kasan_info.is_kmalloc check out of save_alloc_info(). This is a preparatory change that simplifies the following patches in this series. 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 753775b894b6..a6107e8375e0 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