mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-15 08:14:15 +08:00
wireguard: netlink: access device through ctx instead of peer
[ Upstream commit71cbd32e3d
] 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:e7096c131e
("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>
This commit is contained in:
parent
302b2dfc01
commit
d44bd323d8
@ -164,8 +164,8 @@ get_peer(struct wg_peer *peer, struct sk_buff *skb, struct dump_ctx *ctx)
|
||||
if (!allowedips_node)
|
||||
goto no_allowedips;
|
||||
if (!ctx->allowedips_seq)
|
||||
ctx->allowedips_seq = peer->device->peer_allowedips.seq;
|
||||
else if (ctx->allowedips_seq != peer->device->peer_allowedips.seq)
|
||||
ctx->allowedips_seq = ctx->wg->peer_allowedips.seq;
|
||||
else if (ctx->allowedips_seq != ctx->wg->peer_allowedips.seq)
|
||||
goto no_allowedips;
|
||||
|
||||
allowedips_nest = nla_nest_start(skb, WGPEER_A_ALLOWEDIPS);
|
||||
|
Loading…
Reference in New Issue
Block a user