Star64_linux/drivers/net/wireguard
Jason A. Donenfeld afdda7b7f7 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>
2023-04-19 17:54:03 +08:00
..
selftest wireguard: ratelimiter: disable timings test by default 2023-04-19 17:54:03 +08:00
allowedips.c wireguard: allowedips: don't corrupt stack when detecting overflow 2023-04-19 17:52:27 +08:00
allowedips.h
cookie.c
cookie.h
device.c wireguard: device: check for metadata_dst with skb_valid_dst() 2023-04-19 17:48:26 +08:00
device.h
main.c
Makefile
messages.h
netlink.c wireguard: netlink: avoid variable-sized memcpy on sockaddr 2023-04-19 17:54:03 +08:00
netlink.h
noise.c lib/crypto: blake2s: move hmac construction into wireguard 2023-04-19 17:49:03 +08:00
noise.h
peer.c
peer.h
peerlookup.c
peerlookup.h
queueing.c
queueing.h
ratelimiter.c
ratelimiter.h
receive.c
send.c
socket.c wireguard: socket: ignore v6 endpoints when ipv6 is disabled 2023-04-19 17:47:26 +08:00
socket.h
timers.c
timers.h
version.h