Re: [PATCH net v2 8/8] xsk: fix u64 descriptor address truncation on 32-bit architectures
From: Stanislav Fomichev <hidden>
Date: 2026-04-21 22:23:53
Also in:
bpf
On 04/21, Jason Xing wrote:
On Tue, Apr 21, 2026 at 3:49 AM Stanislav Fomichev [off-list ref] wrote:quoted
On 04/20, Jason Xing wrote:quoted
From: Jason Xing <kernelxing@tencent.com> In copy mode TX, xsk_skb_destructor_set_addr() stores the 64-bit descriptor address into skb_shinfo(skb)->destructor_arg (void *) via a uintptr_t cast: skb_shinfo(skb)->destructor_arg = (void *)((uintptr_t)addr | 0x1UL); On 32-bit architectures uintptr_t is 32 bits, so the upper 32 bits of the descriptor address are silently dropped. In XDP_ZEROCOPY unaligned mode the chunk offset is encoded in bits 48-63 of the descriptor address (XSK_UNALIGNED_BUF_OFFSET_SHIFT = 48), meaning the offset is lost entirely. The completion queue then returns a truncated address to userspace, making buffer recycling impossible. Fix this by handling the 32-bit case directly in xsk_skb_destructor_set_addr(): when !CONFIG_64BIT, allocate an xsk_addrs struct (the same path already used for multi-descriptor SKBs) to store the full u64 address.Is it easier to make XSK `depends on 64BIT` to avoid dealing with that? DoesOf course, it would be super easy. Actually the initial version looks like this. One line of coder is simply enough.quoted
anybody seriously run af_xdp on 32 bit systems?But my worry as you guess is if there exists a 32 bit system? I doubt it. That's why I put some effort into adding the compatibility code to cover the case. Good news is that it doesn't add any side effects of the 64 bit system since they are protected under IS_ENABLED condition.
If someone complains, we can follow up? af_xdp is all u64 everywhere, including uapi, I doubt someone is using it on 32 bit systems. We don't test this part on 32 bit systems on nipa either..