]> git.itanic.dy.fi Git - linux-stable/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:32:26 +0000 (15:32 +0200)
commitd44bd323d8bb8031eef4bdc44547925998a11e47
tree0fd5606915b31620c948a2cb11a2f522d9c530fc
parent302b2dfc013baca3dea7ceda383930d9297d231d
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