[PATCH slab/for-next v2 05/14] net: skbuff: specify SLAB_MAY_ACCOUNT for skbuff_head_cache
Harry Yoo (Meta)
harry at kernel.org
Wed Nov 25 21:37:06 UTC 2026
AF_UNIX sets sk->sk_allocation to GFP_KERNEL_ACCOUNT, so skbs can be
allocated from skbuff_head_cache with __GFP_ACCOUNT. Specify
SLAB_MAY_ACCOUNT when the object may be charged to a memcg.
__GFP_ACCOUNT without SLAB_MAY_ACCOUNT will not be allowed.
Path: unix_dgram_sendmsg() -> sock_alloc_send_pskb(sk->sk_allocation)
-> alloc_skb_with_frags() -> __alloc_skb()
-> kmem_cache_alloc_node(skbuff_head_cache)
Cc: "David S. Miller" <davem at davemloft.net>
Cc: Eric Dumazet <edumazet at google.com>
Cc: Jakub Kicinski <kuba at kernel.org>
Cc: Paolo Abeni <pabeni at redhat.com>
Cc: Simon Horman <horms at kernel.org>
Cc: Jason Xing <kerneljasonxing at gmail.com>
Cc: Willem de Bruijn <willemb at google.com>
Cc: Mina Almasry <almasrymina at google.com>
Cc: "Björn Töpel" <bjorn at kernel.org>
Cc: Sebastian Andrzej Siewior <bigeasy at linutronix.de>
Cc: Jiayuan Chen <jiayuan.chen at linux.dev>
Cc: netdev at vger.kernel.org
Acked-by: Jakub Kicinski <kuba at kernel.org>
Signed-off-by: Harry Yoo (Meta) <harry at kernel.org>
---
net/core/skbuff.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 1ac1e327ac4c..91c076f32fcb 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -5313,7 +5313,7 @@ void __init skb_init(void)
sizeof(struct sk_buff),
0,
SLAB_HWCACHE_ALIGN|SLAB_PANIC|
- FLAG_SKB_NO_MERGE,
+ SLAB_MAY_ACCOUNT|FLAG_SKB_NO_MERGE,
offsetof(struct sk_buff, cb),
sizeof_field(struct sk_buff, cb),
NULL);
--
2.54.0
More information about the Linux-security-module-archive
mailing list