From patchwork Tue Dec 19 22:28:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 13499295 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6ECD3C46CCD for ; Tue, 19 Dec 2023 22:29:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4DFF8D0001; Tue, 19 Dec 2023 17:29:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CFE986B0096; Tue, 19 Dec 2023 17:29:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BC5328D0001; Tue, 19 Dec 2023 17:29:16 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id A50466B0095 for ; Tue, 19 Dec 2023 17:29:16 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6554F1C108C for ; Tue, 19 Dec 2023 22:29:16 +0000 (UTC) X-FDA: 81585009912.14.8409FBC Received: from out-183.mta1.migadu.com (out-183.mta1.migadu.com [95.215.58.183]) by imf30.hostedemail.com (Postfix) with ESMTP id EC09D80022 for ; Tue, 19 Dec 2023 22:29:13 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=qtqOsejh; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.183 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1703024954; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=65Nj55va0LyidH/qJFPAhjUaSN3kZxL0lL8iCsNvyX4=; b=iilQsaLTz6EHwb1w0gTbbuUO98W0UIBQ1uG9N3FOT28ZVUC9V+WFwjjiEvdGWgKx0HVDtM Slw65Eux6qZiJupK63LQTrDSM1ueVQsEO+bU8QViPIN4cg5ygZnlP0aC+gqzjxpWLeVExE Lo3rC816p7/cJCWDZ6xqMuryuigXM0g= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=qtqOsejh; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf30.hostedemail.com: domain of andrey.konovalov@linux.dev designates 95.215.58.183 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1703024954; a=rsa-sha256; cv=none; b=8nsozKxQw2xfY/aZ8+J1s2tbE59Gh18FF3qjH5xdawWeEupu2fPKYuowo9pKksQbL7lkIa Vp5f25L0k3DGFlTT2HqgGJIp+Hj0WFnqAU36Z/dcKIGsTnx1mQJll2loq03FJP+agR9PV/ Pb9aB7NTS4BKdoDCDGDXukvxIF/hfdc= 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=1703024952; 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=65Nj55va0LyidH/qJFPAhjUaSN3kZxL0lL8iCsNvyX4=; b=qtqOsejhFRAQXz/SAXNo9IB1G73IEgw3a9jUz4FGb8dWQiMSemlTQ9pIavZ+Zr7zX4kUJ8 0olVIm0l45jMoaa0ZeX7DsQotFdRhNCybCgNQh0s4gGlUfcs17lifVGwAZhMGf9p4P7gCO LcI0++R63ENC8BHKVFsfmjkGqnOvA4Y= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Evgenii Stepanov , Breno Leitao , Alexander Lobakin , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 01/21] kasan: rename kasan_slab_free_mempool to kasan_mempool_poison_object Date: Tue, 19 Dec 2023 23:28:45 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EC09D80022 X-Stat-Signature: wfakeeuasrea4i7zsfhk7gmzrwoqn3w4 X-HE-Tag: 1703024953-257281 X-HE-Meta: U2FsdGVkX1+dyQON7DwrJcbkpLr2jWF/MIAKQd+VvZ8JdISnkmrdxlY44mBtjZR/JdPx1d/7vDWW5K1aijVQhKmLPgk+tWt92fPlfXjxAYPwV8SUciIbZTvrAnfxQ6xC2QBoUL7yBKA6n0xHsA3LQhT5UAEFFY8McJpra2hWHteNN0J/IP4RKGLpwis5h7hUnhl2e8dS7IETW5oyOhaPvFs3AST06gdn46GFJvoMrGO3x60MRHGdMLsGtvk3weSVCJrZO1LKgAG7NKzEmIyQOZ26hnfxLtE3qGNJP/tSRy6uc5WROxQhp7IMb+EXXh4Mbo3R+YvE7kytL2qBVRwJhH4W+420fDiu7SGsxogjtt/zpKyuBl2DXZOvPZFw5gm6oF8H/wWy7rdiA+AHkNH34cuQRQSpxFu9Mo95SbT1nHHWtsYwg18BiIAC9XESPDAw9Fjmlia7R7Lq5H8azr0nEmuW0KdVNGj7eqoXD+5fB6xYsqCB+qZHP6NnuUW5KiPaiMOIU4buVvey2sN9YitcuRhpEmHb08b2JEsOKOZkWM9d7DQgfguFRobxh235xia9lwAxHEjDmOYIQAy95s4k1LW3icHNDl7HxcI6F0vb/F+x3SKFUieh61m6HMQJoPhSYXWGgi9DkPxUKCoBmnbiFspRMVsNjcAw/XEdIGXIhz//lzX2bPfBeTXJDRHxlmajO8Y9dr39BqwZJyqyXVKOY6N8P/BnGD43v9I98dygtobDFdL8WwXbAdAMAyUcJz9uUGb/bYDnBls/gU3XmpLa+Jl4E1ObZ+y9R5olo72DKKFcgfMjxzVfLdAbc01fBYTGpk+FluxOj1HRACIjKimXnNJYbdULSZxD+r78n0vmsQGB2cFmL5TiUcNBdQUC0UjCMpYMhB791+x/UuApWuiFoL9MFnnUDK5M2yuoYsrznj8k8d8Jf2OwTDqSJlBPeL3yawOw8Ic4lHckUMuXGh3 9xFlbQQJ hNXoxXc4S+RyLXVdt5bT0YucDOA81Ag9jB0tr0TeSce2uL/zS/Zv75nGFwhKHzRR3lRDtqLX7lrz/b6Ybahv1PeP63bOfKIHcjl7E2bk1RTC0rt1ldrmrkffXuFzplAznZetSd3s1vLLWIo0V1AqfuWCO7C8/bgOCZn6lyoRC+KKoT4sutYAIrZSoWpBnsnETmehi3L1iRNqjw9l87piHOia4EA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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 fe6c4b43ad9f..e0394d0ee7f1 100644 --- a/mm/kasan/common.c +++ b/mm/kasan/common.c @@ -271,7 +271,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; @@ -282,7 +282,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 b3d2084fd989..7e1c729f292b 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);