WSL2-Linux-Kernel/drivers/net/wireguard
Jason A. Donenfeld c60801e4e2 wireguard: netlink: avoid variable-sized memcpy on sockaddr
[ Upstream commit 26c013108c ]

Doing a variable-sized memcpy is slower, and the compiler isn't smart
enough to turn this into a constant-size assignment.

Further, Kees' latest fortified memcpy will actually bark, because the
destination pointer is type sockaddr, not explicitly sockaddr_in or
sockaddr_in6, so it thinks there's an overflow:

    memcpy: detected field-spanning write (size 28) of single field
    "&endpoint.addr" at drivers/net/wireguard/netlink.c:446 (size 16)

Fix this by just assigning by using explicit casts for each checked
case.

Fixes: e7096c131e ("net: WireGuard secure network tunnel")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reported-by: syzbot+a448cda4dba2dac50de5@syzkaller.appspotmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-09-28 11:11:51 +02:00
..
selftest wireguard: ratelimiter: disable timings test by default 2022-09-28 11:11:50 +02:00
Makefile wireguard: do not use -O3 2021-06-04 14:25:14 -07:00
allowedips.c wireguard: allowedips: don't corrupt stack when detecting overflow 2022-08-17 14:23:37 +02:00
allowedips.h wireguard: allowedips: free empty intermediate nodes when removing single node 2021-06-04 14:25:14 -07:00
cookie.c
cookie.h
device.c wireguard: device: check for metadata_dst with skb_valid_dst() 2022-05-09 09:14:35 +02:00
device.h wireguard: receive: use ring buffer for incoming handshakes 2021-12-08 09:04:46 +01:00
main.c wireguard: allowedips: allocate nodes in kmem_cache 2021-06-04 14:25:14 -07:00
messages.h
netlink.c wireguard: netlink: avoid variable-sized memcpy on sockaddr 2022-09-28 11:11:51 +02:00
netlink.h
noise.c lib/crypto: blake2s: move hmac construction into wireguard 2022-05-30 09:28:59 +02:00
noise.h
peer.c wireguard: peer: allocate in kmem_cache 2021-06-04 14:25:14 -07:00
peer.h wireguard: peer: allocate in kmem_cache 2021-06-04 14:25:14 -07:00
peerlookup.c
peerlookup.h
queueing.c wireguard: queueing: use CFI-safe ptr_ring cleanup function 2022-04-08 14:24:09 +02:00
queueing.h wireguard: receive: use ring buffer for incoming handshakes 2021-12-08 09:04:46 +01:00
ratelimiter.c wireguard: ratelimiter: use kvcalloc() instead of kvzalloc() 2021-12-08 09:04:46 +01:00
ratelimiter.h
receive.c wireguard: receive: drop handshakes if queue lock is contended 2021-12-08 09:04:46 +01:00
send.c wireguard: queueing: get rid of per-peer ring buffers 2021-02-23 15:59:34 -08:00
socket.c wireguard: socket: ignore v6 endpoints when ipv6 is disabled 2022-04-08 14:24:09 +02:00
socket.h
timers.c
timers.h
version.h