netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* xdp/xsk.c: Possible bug in xdp_umem_reg version check
@ 2024-07-07 15:05 Julian Schindel
  2024-07-09  9:23 ` Magnus Karlsson
  0 siblings, 1 reply; 8+ messages in thread
From: Julian Schindel @ 2024-07-07 15:05 UTC (permalink / raw)
  To: bpf
  Cc: Björn Töpel, Magnus Karlsson, Maciej Fijalkowski,
	Stanislav Fomichev, netdev

Hi,

I hope this is the correct way to ask about this issue, I haven't used
the kernel mailing list before.

Between different compilations of an AF_XDP project, I encountered
"random" EINVAL errors when calling setsockopt XDP_UMEM_REG with the
same parameter.

I think this might be caused by this patch:
https://lore.kernel.org/all/20231127190319.1190813-2-sdf@google.com/
It added "tx_metadata_len" to the "xdp_umem_reg" struct.
In the  "xsk_setsockopt" code in xdp/xsk.c, the provided "optlen" is
checked against the length of "xdp_umem_reg_v2" and "xdp_umem_reg" to
check which version of "xdp_umem_reg", the user supplied.

At least on my machine (x86_64, Fedora 40, 6.9.7), these two structs
have the same size (32 bytes) due to the compiler adding padding to
"xdp_umem_reg_v2". This means if the user supplies "xdp_umem_reg_v2", it
is falsely treated as "xdp_umem_reg".

I'm not sure whether there is some implicit struct packing happening or
whether this is indeed a bug.

Best regards,
Julian


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-07-11  8:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-07 15:05 xdp/xsk.c: Possible bug in xdp_umem_reg version check Julian Schindel
2024-07-09  9:23 ` Magnus Karlsson
2024-07-09 11:25   ` Julian Schindel
2024-07-10  4:45     ` Stanislav Fomichev
2024-07-10  6:32       ` Julian Schindel
2024-07-11  3:48         ` Stanislav Fomichev
2024-07-11  5:23           ` Julian Schindel
2024-07-11  8:11           ` Magnus Karlsson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).