summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLi RongQing <lirongqing@baidu.com>2020-04-02 15:52:10 +0800
committerDaniel Borkmann <daniel@iogearbox.net>2020-04-06 21:48:05 +0200
commitdb5c97f02373917efe2c218ebf8e3d8b19e343b6 (patch)
tree20fda0873765ba42e4ab7b59f6ee1de2e933fde1 /net
parent5222d69642a09261222fb9703761a029db16cadf (diff)
downloadlinux-db5c97f02373917efe2c218ebf8e3d8b19e343b6.tar.gz
linux-db5c97f02373917efe2c218ebf8e3d8b19e343b6.tar.bz2
linux-db5c97f02373917efe2c218ebf8e3d8b19e343b6.zip
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 <lirongqing@baidu.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Jonathan Lemon <jonathan.lemon@gmail.com> Acked-by: Björn Töpel <bjorn.topel@intel.com> Link: https://lore.kernel.org/bpf/1585813930-19712-1-git-send-email-lirongqing@baidu.com
Diffstat (limited to 'net')
-rw-r--r--net/xdp/xsk.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 356f90e4522b..c350108aa38d 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;
}