Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2374824rdf; Mon, 6 Nov 2023 12:11:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHf7u/iMUjb637HENr07jclcstjH2aosIgZPi5tThZozbY84EiYYxq9jKMoX+GDad5qhPAR X-Received: by 2002:a05:6a20:8f26:b0:181:a38c:8106 with SMTP id b38-20020a056a208f2600b00181a38c8106mr646281pzk.20.1699301474101; Mon, 06 Nov 2023 12:11:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699301474; cv=none; d=google.com; s=arc-20160816; b=pgz5ejd6GQSSshI7wHAlw7YXxShB8tK7gfoWyC3q0RBSBjuS6o+EybMa+b0XVNL9dY 6eySDifsjR7L+9bCrPD1fnofWTXnRbxotVAwiygNYyobUuCInb/Iek5A/j9/UssIrWKj 5lsDlgPKapMz60/HDPWPuP6hL9q/eLVzzJZL9Sjmiw/sNXIUCOdiCVDZHcndDk64PqRg aUzWxa0wuK+6Pp4+UJeFEaK4W0czzsAPvIhiRf+dwEw6ZZXfyLnElSFGcrMSXzZjrUhK NvUrAyQLug9Yy5LLgUwf2qHuTuH3HahV633iTDEQOEAjRQ9dSeKIvmB0LPKf8vlz/sNY R1/Q== 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=5zUveeaHubKwNWv/mUHyod8asGDxf8HEl2nDgxq3m5s=; fh=n5KN85tQTomq0Sa/nFFC9xbnc77mxkBzF8HoolO/QOw=; b=RSBbEBXiLUfIobWRUNaUwms4X2qrPA/AIAC0sDmdljo1vnw/gD2EMbg/2/PXI6gIdR Eg984BRrKd3RQoCqX/4EgSLEPfQjV8kdidcfMr5hf/v1dTiwkcpRoDpNvRMJp5O5PGth 3RaCybKkR4Wy3Fn47NB6kGDdHC2TM3lSDXgZMZ/GJzEpNuA0B4JuEPuQyJ3GRzlzyLV2 3PrL3+EBMtnTSZN9TD7Elm73uQ4FwoJsZ06aNrwIQWHQbJJ2iU2QaL0wY2nb/Hg330/p yb8pxaxQwoa5HZZI/Cm1SNxLQGsINShK74p9ZV0CGC+JtLUQW628KtV8xAOM/N3qM7t8 TwNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=L3cpdQsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id s17-20020a056a0008d100b006910a45a234si9087510pfu.202.2023.11.06.12.11.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 12:11:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=L3cpdQsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 2EDCC8032C75; Mon, 6 Nov 2023 12:11:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232893AbjKFUKl (ORCPT + 99 others); Mon, 6 Nov 2023 15:10:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbjKFUKk (ORCPT ); Mon, 6 Nov 2023 15:10:40 -0500 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [IPv6:2001:41d0:203:375::b0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA45BD77 for ; Mon, 6 Nov 2023 12:10:35 -0800 (PST) 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=1699301434; 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=5zUveeaHubKwNWv/mUHyod8asGDxf8HEl2nDgxq3m5s=; b=L3cpdQsl8rkb7JZtwAIC4eCSnezYGVtiw98SxiDVzYCV5xe1AfbsSj6usun1a4l+c+qqRu z1J/4gwLmo5D3p+Kwl2i4n8TQXJgQGILOLkaKmpXlQWt0svPMKOeoNq+e2E1zahPLmA8Hc UdUKlPDzpckCJ729haSLr62Qg8EuqI4= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Evgenii Stepanov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH RFC 01/20] kasan: rename kasan_slab_free_mempool to kasan_mempool_poison_object Date: Mon, 6 Nov 2023 21:10:10 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 06 Nov 2023 12:11:01 -0800 (PST) From: Andrey Konovalov Rename kasan_slab_free_mempool to kasan_mempool_poison_object. kasan_slab_free_mempool is a slightly confusing name: it is unclear whether this function poisons the object when it is freed into mempool or does something when the object is freed from mempool to the underlying allocator. The new name also aligns with other mempool-related KASAN hooks added in the following patches in this series. Signed-off-by: Andrey Konovalov --- include/linux/kasan.h | 8 ++++---- io_uring/alloc_cache.h | 3 +-- mm/kasan/common.c | 4 ++-- mm/mempool.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/linux/kasan.h b/include/linux/kasan.h index 72cb693b075b..6310435f528b 100644 --- a/include/linux/kasan.h +++ b/include/linux/kasan.h @@ -172,11 +172,11 @@ static __always_inline void kasan_kfree_large(void *ptr) __kasan_kfree_large(ptr, _RET_IP_); } -void __kasan_slab_free_mempool(void *ptr, unsigned long ip); -static __always_inline void kasan_slab_free_mempool(void *ptr) +void __kasan_mempool_poison_object(void *ptr, unsigned long ip); +static __always_inline void kasan_mempool_poison_object(void *ptr) { if (kasan_enabled()) - __kasan_slab_free_mempool(ptr, _RET_IP_); + __kasan_mempool_poison_object(ptr, _RET_IP_); } void * __must_check __kasan_slab_alloc(struct kmem_cache *s, @@ -256,7 +256,7 @@ static inline bool kasan_slab_free(struct kmem_cache *s, void *object, bool init return false; } static inline void kasan_kfree_large(void *ptr) {} -static inline void kasan_slab_free_mempool(void *ptr) {} +static inline void kasan_mempool_poison_object(void *ptr) {} static inline void *kasan_slab_alloc(struct kmem_cache *s, void *object, gfp_t flags, bool init) { diff --git a/io_uring/alloc_cache.h b/io_uring/alloc_cache.h index 241245cb54a6..8de0414e8efe 100644 --- a/io_uring/alloc_cache.h +++ b/io_uring/alloc_cache.h @@ -16,8 +16,7 @@ static inline bool io_alloc_cache_put(struct io_alloc_cache *cache, if (cache->nr_cached < cache->max_cached) { cache->nr_cached++; wq_stack_add_head(&entry->node, &cache->list); - /* KASAN poisons object */ - kasan_slab_free_mempool(entry); + kasan_mempool_poison_object(entry); return true; } return false; diff --git a/mm/kasan/common.c b/mm/kasan/common.c index 256930da578a..e42d6f349ae2 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -261,7 +261,7 @@ static inline bool ____kasan_kfree_large(void *ptr, unsigned long ip) /* * The object will be poisoned by kasan_poison_pages() or - * kasan_slab_free_mempool(). + * kasan_mempool_poison_object(). */ return false; @@ -272,7 +272,7 @@ void __kasan_kfree_large(void *ptr, unsigned long ip) ____kasan_kfree_large(ptr, ip); } -void __kasan_slab_free_mempool(void *ptr, unsigned long ip) +void __kasan_mempool_poison_object(void *ptr, unsigned long ip) { struct folio *folio; diff --git a/mm/mempool.c b/mm/mempool.c index 734bcf5afbb7..768cb39dc5e2 100644 --- a/mm/mempool.c +++ b/mm/mempool.c @@ -107,7 +107,7 @@ static inline void poison_element(mempool_t *pool, void *element) static __always_inline void kasan_poison_element(mempool_t *pool, void *element) { if (pool->alloc == mempool_alloc_slab || pool->alloc == mempool_kmalloc) - kasan_slab_free_mempool(element); + kasan_mempool_poison_object(element); else if (pool->alloc == mempool_alloc_pages) kasan_poison_pages(element, (unsigned long)pool->pool_data, false); -- 2.25.1