Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3578021rwb; Mon, 5 Sep 2022 14:33:09 -0700 (PDT) X-Google-Smtp-Source: AA6agR6d5EX6gumz58fgWkxJwtLRY6Pa59G67z9t0tjYn6icgURyBrzNiNdgSsbmVzAC2a5cODRr X-Received: by 2002:a17:907:6e0b:b0:73d:5850:ca15 with SMTP id sd11-20020a1709076e0b00b0073d5850ca15mr37985874ejc.344.1662413589606; Mon, 05 Sep 2022 14:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662413589; cv=none; d=google.com; s=arc-20160816; b=C0uePcJAZk+7AUAHHYBzoW3w+UXkJD4rm4dLfCdU6PQ2U9y22pRKOoFIt57y7UTqDS gkkIOj73xryT1Xdhf+nF9W3rMPyDdhAFJ3A431u9nzpuAhj2ow8PPymfeLc/T7T3JSoo 4ebr133lIsPPjJWfjWpvLbIref7WVfbIOqaU93mfexxPT2+WgSTISkwvca1O25vaHRoZ t5pbpQCQODfS0MUveD0WGTp3tLSLaDLYe5mjjog7HuTvbjjdn6kip/02DGg/FsfKgcRq RFO3Ad5vYH5VYzf44w+x9GicSSdrrjhkENY/HiGFNNcKUmQjBW8doBsTTF9A3F/CR71i xQvw== 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=FRkYVowObuO3yDrt4EDyhkJ3yebxJfyebNr4InttO9I=; b=cDff9jMhMPDsqKTpNWzeK7zRN43+24g0LazEDDW15YtHpGKHU/pgWJniW9rW16Punn Usvizds7i4Z5ntd52t9gy3F58rBm7ai6kaz+E0bLdCnANjbX39q0lp4p3DQ2De+1O2xm WYkpWKE9+/QiJGtKoORW1xugO6jY5B3MOvIJDMpt4q9Oh7ArmxvT7iMQpJlt8jlDISxH gaVjjJiuc7laTcJQjoJSArQvFmM9nfkSu6iGO6E/QgvkGWy1LpguWD2/CYFFoidFNNkb ZCsZS1llgIWOaHLoCryD9A//+vP6ffJ2q6mAUcu7eqyDhSR3ebXtv7SlX5IoMeQg5lSO QrCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=xXX054y0; 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 sc6-20020a1709078a0600b0073dba60b49bsi10179321ejc.303.2022.09.05.14.32.43; Mon, 05 Sep 2022 14:33:09 -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=xXX054y0; 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 S232637AbiIEVGF (ORCPT + 99 others); Mon, 5 Sep 2022 17:06:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232012AbiIEVF5 (ORCPT ); Mon, 5 Sep 2022 17:05:57 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD92259265 for ; Mon, 5 Sep 2022 14:05:56 -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=1662411955; 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=FRkYVowObuO3yDrt4EDyhkJ3yebxJfyebNr4InttO9I=; b=xXX054y0wY+V4A4LcLCE7sgBItHVmTzEXBn8sHXvZMLT6rRBmTyyI3YXsQOkOAcQYpT1Aj mq5uY5VgQBSr0ctxFSeM9rmfFyuuEhoYYgZAAPkm/SOKM/bCEsgiqqP6fRpnsN8X2qvzxc i2fw2ad0j/KhP/jYgpQHoY4x/5gN0qA= 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 03/34] kasan: move is_kmalloc check out of save_alloc_info Date: Mon, 5 Sep 2022 23:05:18 +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. 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 90b6cadd2dac..6a75237ed308 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -424,15 +424,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); @@ -467,8 +462,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; } @@ -513,8 +508,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