summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2024-02-02 17:32:20 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-03-01 13:41:53 +0100
commitcfc86a96708f070617a187530bd2fb13044f8a51 (patch)
tree943b7f604d43f11da6da00e44da431ab6e69c6ec /net
parent4186af04565587140d51a4eadee060387f06d53e (diff)
downloadlinux-stable-cfc86a96708f070617a187530bd2fb13044f8a51.tar.gz
linux-stable-cfc86a96708f070617a187530bd2fb13044f8a51.tar.bz2
linux-stable-cfc86a96708f070617a187530bd2fb13044f8a51.zip
xsk: Add truesize to skb_add_rx_frag().
[ Upstream commit 2127c604383666675789fd4a5fc2aead46c73aad ] xsk_build_skb() allocates a page and adds it to the skb via skb_add_rx_frag() and specifies 0 for truesize. This leads to a warning in skb_add_rx_frag() with CONFIG_DEBUG_NET enabled because size is larger than truesize. Increasing truesize requires to add the same amount to socket's sk_wmem_alloc counter in order not to underflow the counter during release in the destructor (sock_wfree()). Pass the size of the allocated page as truesize to skb_add_rx_frag(). Add this mount to socket's sk_wmem_alloc counter. Fixes: cf24f5a5feea ("xsk: add support for AF_XDP multi-buffer on Tx path") Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Link: https://lore.kernel.org/bpf/20240202163221.2488589-1-bigeasy@linutronix.de Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/xdp/xsk.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 688e641cd278..da1582de6e84 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -711,7 +711,8 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
memcpy(vaddr, buffer, len);
kunmap_local(vaddr);
- skb_add_rx_frag(skb, nr_frags, page, 0, len, 0);
+ skb_add_rx_frag(skb, nr_frags, page, 0, len, PAGE_SIZE);
+ refcount_add(PAGE_SIZE, &xs->sk.sk_wmem_alloc);
}
}