From: Li RongQing Date: Thu, 2 Apr 2020 07:52:10 +0000 (+0800) Subject: xsk: Fix out of boundary write in __xsk_rcv_memcpy X-Git-Tag: v5.10.7~2790^2~30^2~7 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=db5c97f02373917efe2c218ebf8e3d8b19e343b6;p=platform%2Fkernel%2Flinux-rpi.git xsk: Fix out of boundary write in __xsk_rcv_memcpy first_len is the remainder of the first page we're copying. If this size is larger, then out of page boundary write will otherwise happen. Fixes: c05cd3645814 ("xsk: add support to allow unaligned chunk placement") Signed-off-by: Li RongQing Signed-off-by: Daniel Borkmann Acked-by: Jonathan Lemon Acked-by: Björn Töpel Link: https://lore.kernel.org/bpf/1585813930-19712-1-git-send-email-lirongqing@baidu.com --- diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c index 356f90e..c350108 100644 --- a/net/xdp/xsk.c +++ b/net/xdp/xsk.c @@ -131,8 +131,9 @@ static void __xsk_rcv_memcpy(struct xdp_umem *umem, u64 addr, void *from_buf, u64 page_start = addr & ~(PAGE_SIZE - 1); u64 first_len = PAGE_SIZE - (addr - page_start); - memcpy(to_buf, from_buf, first_len + metalen); - memcpy(next_pg_addr, from_buf + first_len, len - first_len); + memcpy(to_buf, from_buf, first_len); + memcpy(next_pg_addr, from_buf + first_len, + len + metalen - first_len); return; }