]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
wireguard: netlink: access device through ctx instead of peer
authorJason A. Donenfeld <Jason@zx2c4.com>
Thu, 14 Mar 2024 22:49:10 +0000 (16:49 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Apr 2024 13:28:36 +0000 (15:28 +0200)
commitc991567e6c638079304cc15dff28748e4a3c4a37
treeddb4ccd40e810d8fac1f4a575ef85609ae99f134
parent13d107794304306164481d31ce33f8fdb25a9c04
wireguard: netlink: access device through ctx instead of peer

[ Upstream commit 71cbd32e3db82ea4a74e3ef9aeeaa6971969c86f ]

The previous commit fixed a bug that led to a NULL peer->device being
dereferenced. It's actually easier and faster performance-wise to
instead get the device from ctx->wg. This semantically makes more sense
too, since ctx->wg->peer_allowedips.seq is compared with
ctx->allowedips_seq, basing them both in ctx. This also acts as a
defence in depth provision against freed peers.

Cc: stable@vger.kernel.org
Fixes: e7096c131e51 ("net: WireGuard secure network tunnel")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireguard/netlink.c