[PATCH bpf-next] xsk: fix destination buffer address when copying with metadata

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



While working on a simplified test for [0] it occurred to me that
the following looks fishy:

	data = xsk_umem__get_data(xsk->umem_area, rx_desc->addr);
	data_meta = data - sizeof(my metadata);

Since the data points to umem frame at addr X, data_mem points to
the end of umem frame X-1.

I don't think it's by design?

0: https://lore.kernel.org/bpf/20221028181431.05173968@xxxxxxxxxx/T/#t

Cc: Björn Töpel <bjorn@xxxxxxxxxx>
Cc: Magnus Karlsson <magnus.karlsson@xxxxxxxxx>
Cc: Maciej Fijalkowski <maciej.fijalkowski@xxxxxxxxx>
Cc: Jonathan Lemon <jonathan.lemon@xxxxxxxxx>
Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxx>
---
 net/xdp/xsk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 9f0561b67c12..0547fe37ba7e 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -163,7 +163,7 @@ static void xsk_copy_xdp(struct xdp_buff *to, struct xdp_buff *from, u32 len)
 	} else {
 		from_buf = from->data_meta;
 		metalen = from->data - from->data_meta;
-		to_buf = to->data - metalen;
+		to_buf = to->data;
 	}
 
 	memcpy(to_buf, from_buf, len + metalen);
-- 
2.38.1.431.g37b22c650d-goog





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux