* [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes
@ 2026-10-14 5:23 Kees Cook
2026-10-14 5:23 ` [PATCH v7 1/2] mm/slab: Mark the kmem_buckets_create() context as a Context: section Kees Cook
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Kees Cook @ 2026-10-14 5:23 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Kees Cook, Harry Yoo, Andrew Morton, Hao Li, Christoph Lameter,
David Rientjes, Roman Gushchin, Pedro Falcato, Kuniyuki Iwashima,
Christian Brauner, Jan Kara, Johannes Weiner, Michal Hocko,
Shakeel Butt, Muchun Song, linux-mm, cgroups, linux-kernel,
linux-hardening
Hi!
As Vlastimil suggested[1], these are the first two patches of v6, split
out for 7.4. The rest of the skb buckets series will come back for 7.5.
2/2 now keeps SLAB_ACCOUNT on the msg_msg bucket caches and allocates
with GFP_KERNEL_ACCOUNT as well, so a msg_msg is charged with
CONFIG_SLAB_BUCKETS either way.
Thanks!
-Kees
v7:
- split v6's 1/8 and 2/8 out for 7.4; 3/8 to 8/8 will return for 7.5
(Vlastimil)
- 2/2: keep SLAB_ACCOUNT in kmem_buckets_create(), and add Cc: stable
(Vlastimil, Andrew, Harry)
v6: https://lore.kernel.org/all/20261006092030.got.500-kees@kernel.org/
v5: https://lore.kernel.org/all/20261002231120.late.500-kees@kernel.org/
v4: https://lore.kernel.org/all/20260921075811.too.775-kees@kernel.org/
v3: https://lore.kernel.org/all/20260702170728.168755-1-pfalcato@suse.de/
[1] https://lore.kernel.org/all/be34b92e-e82c-4f69-ac9d-b045081ea418@kernel.org/
Kees Cook (2):
mm/slab: Mark the kmem_buckets_create() context as a Context: section
ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again
ipc/msgutil.c | 3 ++-
mm/slab_common.c | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
--
2.55.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v7 1/2] mm/slab: Mark the kmem_buckets_create() context as a Context: section
2026-10-14 5:23 [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes Kees Cook
@ 2026-10-14 5:23 ` Kees Cook
2026-10-14 5:23 ` [PATCH v7 2/2] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again Kees Cook
2026-10-14 8:15 ` [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes Vlastimil Babka (SUSE)
2 siblings, 0 replies; 5+ messages in thread
From: Kees Cook @ 2026-10-14 5:23 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Kees Cook, Harry Yoo, Andrew Morton, Hao Li, Christoph Lameter,
David Rientjes, Roman Gushchin, linux-mm, Pedro Falcato,
Kuniyuki Iwashima, linux-hardening, linux-kernel
kmem_buckets_create() had the same sentence about calling context as
kmem_cache_create(), but lacked the "Context:" prefix, so kernel-doc
rendered in the body instead of as a "context" section.
Give it the missing prefix. Additionally fix the "a interrupt" typo
__kmem_cache_create_args() had.
Fixes: b32801d1255be ("mm/slab: Introduce kmem_buckets_create() and family")
Reviewed-by: Harry Yoo (Meta) <harry@kernel.org>
Acked-by: Pedro Falcato <pfalcato@suse.de>
Reviewed-by: Hao Li <hao.li@linux.dev>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Signed-off-by: Kees Cook <kees@kernel.org>
---
mm/slab_common.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/slab_common.c b/mm/slab_common.c
index b19ba1b31484..270408ce5a9d 100644
--- a/mm/slab_common.c
+++ b/mm/slab_common.c
@@ -311,7 +311,7 @@ __kmem_cache_alias(const char *name, unsigned int size, slab_flags_t flags,
* &SLAB_TYPESAFE_BY_RCU - Slab page (not individual objects) freeing delayed
* by a grace period - see the full description before using.
*
- * Context: Cannot be called within a interrupt, but can be interrupted.
+ * Context: Cannot be called within an interrupt, but can be interrupted.
*
* Return: a pointer to the cache on success, NULL on failure.
*/
@@ -422,7 +422,7 @@ static struct kmem_cache *kmem_buckets_cache __ro_after_init;
* to/from userspace.
* @ctor: A constructor for the objects, run when new allocations are made.
*
- * Cannot be called within an interrupt, but can be interrupted.
+ * Context: Cannot be called within an interrupt, but can be interrupted.
*
* Return: a pointer to the cache on success, NULL on failure. When
* CONFIG_SLAB_BUCKETS is not enabled, ZERO_SIZE_PTR is returned, and
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v7 2/2] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again
2026-10-14 5:23 [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes Kees Cook
2026-10-14 5:23 ` [PATCH v7 1/2] mm/slab: Mark the kmem_buckets_create() context as a Context: section Kees Cook
@ 2026-10-14 5:23 ` Kees Cook
2026-10-14 13:16 ` Harry Yoo
2026-10-14 8:15 ` [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes Vlastimil Babka (SUSE)
2 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2026-10-14 5:23 UTC (permalink / raw)
To: Vlastimil Babka
Cc: Kees Cook, Christian Brauner, Jan Kara, Andrew Morton,
Roman Gushchin, Johannes Weiner, Michal Hocko, Shakeel Butt,
Muchun Song, cgroups, linux-mm, Pedro Falcato, Kuniyuki Iwashima,
linux-hardening, stable, linux-kernel
Since commit 734bbc1c97ea7 ("ipc, msg: Use dedicated slab buckets for
alloc_msg()"), alloc_msg() allocates with GFP_KERNEL, and a msg_msg is
accounted only through SLAB_ACCOUNT on its bucket caches. With
CONFIG_SLAB_BUCKETS=n, kmem_buckets_create() creates no caches and
kmem_buckets_alloc() is a GFP_KERNEL kmalloc() from the general caches,
which do not account it; the same happens when kmem_buckets_create()
fails. Either way, the allocation is not charged to the sender's memory
cgroup.
Allocate with GFP_KERNEL_ACCOUNT again, as before that commit, so the
allocation is charged whichever cache serves it.
Build tested ARCH=x86_64 defconfig with GCC 16.2.0, with
CONFIG_SLAB_BUCKETS as y and n.
Fixes: 734bbc1c97ea7 ("ipc, msg: Use dedicated slab buckets for alloc_msg()")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <kees@kernel.org>
---
ipc/msgutil.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/ipc/msgutil.c b/ipc/msgutil.c
index e28f0cecb2ec..12663a40e9ae 100644
--- a/ipc/msgutil.c
+++ b/ipc/msgutil.c
@@ -58,7 +58,8 @@ static struct msg_msg *alloc_msg(size_t len)
size_t alen;
alen = min(len, DATALEN_MSG);
- msg = kmem_buckets_alloc(msg_buckets, sizeof(*msg) + alen, GFP_KERNEL);
+ msg = kmem_buckets_alloc(msg_buckets, sizeof(*msg) + alen,
+ GFP_KERNEL_ACCOUNT);
if (msg == NULL)
return NULL;
--
2.55.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes
2026-10-14 5:23 [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes Kees Cook
2026-10-14 5:23 ` [PATCH v7 1/2] mm/slab: Mark the kmem_buckets_create() context as a Context: section Kees Cook
2026-10-14 5:23 ` [PATCH v7 2/2] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again Kees Cook
@ 2026-10-14 8:15 ` Vlastimil Babka (SUSE)
2 siblings, 0 replies; 5+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-10-14 8:15 UTC (permalink / raw)
To: Vlastimil Babka, Kees Cook
Cc: Harry Yoo, Andrew Morton, Hao Li, Christoph Lameter,
David Rientjes, Roman Gushchin, Pedro Falcato, Kuniyuki Iwashima,
Christian Brauner, Jan Kara, Johannes Weiner, Michal Hocko,
Shakeel Butt, Muchun Song, linux-mm, cgroups, linux-kernel,
linux-hardening
On Tue, 13 Oct 2026 22:23:41 -0700, Kees Cook wrote:
> As Vlastimil suggested[1], these are the first two patches of v6, split
> out for 7.4. The rest of the skb buckets series will come back for 7.5.
>
> 2/2 now keeps SLAB_ACCOUNT on the msg_msg bucket caches and allocates
> with GFP_KERNEL_ACCOUNT as well, so a msg_msg is charged with
> CONFIG_SLAB_BUCKETS either way.
>
> [...]
Applied to mm/slab.git slab/for-7.4/misc, thanks!
[1/2] mm/slab: Mark the kmem_buckets_create() context as a Context: section
commit: 655668f0caf32a42fef10aaf31137e52f46a0260
[2/2] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again
commit: 49c0b3dedf7c8c64e432e63dd7b24f00909916d8
Best regards,
--
Vlastimil Babka (SUSE) <vbabka@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v7 2/2] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again
2026-10-14 5:23 ` [PATCH v7 2/2] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again Kees Cook
@ 2026-10-14 13:16 ` Harry Yoo
0 siblings, 0 replies; 5+ messages in thread
From: Harry Yoo @ 2026-10-14 13:16 UTC (permalink / raw)
To: Kees Cook
Cc: Vlastimil Babka, Christian Brauner, Jan Kara, Andrew Morton,
Roman Gushchin, Johannes Weiner, Michal Hocko, Shakeel Butt,
Muchun Song, cgroups, linux-mm, Pedro Falcato, Kuniyuki Iwashima,
linux-hardening, stable, linux-kernel
On Tue, Oct 13, 2026 at 10:23:43PM -0700, Kees Cook wrote:
> Since commit 734bbc1c97ea7 ("ipc, msg: Use dedicated slab buckets for
> alloc_msg()"), alloc_msg() allocates with GFP_KERNEL, and a msg_msg is
> accounted only through SLAB_ACCOUNT on its bucket caches. With
> CONFIG_SLAB_BUCKETS=n, kmem_buckets_create() creates no caches and
> kmem_buckets_alloc() is a GFP_KERNEL kmalloc() from the general caches,
> which do not account it; the same happens when kmem_buckets_create()
> fails. Either way, the allocation is not charged to the sender's memory
> cgroup.
>
> Allocate with GFP_KERNEL_ACCOUNT again, as before that commit, so the
> allocation is charged whichever cache serves it.
>
> Build tested ARCH=x86_64 defconfig with GCC 16.2.0, with
> CONFIG_SLAB_BUCKETS as y and n.
>
> Fixes: 734bbc1c97ea7 ("ipc, msg: Use dedicated slab buckets for alloc_msg()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Kees Cook <kees@kernel.org>
Looks good to me,
Reviewed-by: Harry Yoo (Meta) <harry@kernel.org>
Thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-10-14 13:16 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-14 5:23 [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes Kees Cook
2026-10-14 5:23 ` [PATCH v7 1/2] mm/slab: Mark the kmem_buckets_create() context as a Context: section Kees Cook
2026-10-14 5:23 ` [PATCH v7 2/2] ipc, msg: Account msg_msg allocations with GFP_KERNEL_ACCOUNT again Kees Cook
2026-10-14 13:16 ` Harry Yoo
2026-10-14 8:15 ` [PATCH v7 0/2] mm/slab, ipc: kmem_buckets kernel-doc and msg_msg accounting fixes Vlastimil Babka (SUSE)
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.