From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9EF445BE4; Mon, 1 Apr 2024 16:00:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711987256; cv=none; b=SduJx3lLgGdhsFA7YTCqmp2zPRWfg8jG7D6iqHwXLY7yz/UsEp4ShfTmzaAer3VKfZfJz2jX2/fO5FSljrN5yKa2AZUccrqt5uEIcsHIXNwoNnZXHF72ciTey2/ukKUgqFMZov5Ou7Yras2jXWlxoDVn5mvYWcaLxVSq8P2noyE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711987256; c=relaxed/simple; bh=/XFIfuuZMOTJOsoJqcMa4VWApLr+t7504GtiLBi5Xug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UvK8yPDrFagdU8Ep7yJgAp2+3jij9+yQPrJ7nqUJLqwHo+ZXamMo7mE+500qNpdIq+O0naxlRgCB1vfm3NAgbz6kuXRAKEbtEWCB+JoExzu5XAhCX2gH3yFqJgV1SjrlGeGEfcA6vYAFOyEmJy4UqHpvpFi0tWJjmNQlVUb8IQ4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=16uB3Aj9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="16uB3Aj9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5B2CFC433C7; Mon, 1 Apr 2024 16:00:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1711987255; bh=/XFIfuuZMOTJOsoJqcMa4VWApLr+t7504GtiLBi5Xug=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=16uB3Aj9/Nt/A9SqZrAf1u+nL/XAq1ZQe4JjnjpszayqhdngZrMCP8aWigu2Icwui 60saor7Pwsc7/ZYurh9gkvXEd4Tu0k1jryUmbZfV3AFCADmosm1pfJeqhqtomaWyXe UQaLYRe2NgrZqxlLiKRQXzNbySR50KVRh4NhJtl0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Jason A. Donenfeld" , Jiri Pirko , Paolo Abeni , Sasha Levin Subject: [PATCH 6.8 202/399] wireguard: netlink: access device through ctx instead of peer Date: Mon, 1 Apr 2024 17:42:48 +0200 Message-ID: <20240401152555.213635013@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240401152549.131030308@linuxfoundation.org> References: <20240401152549.131030308@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jason A. Donenfeld [ 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 Reviewed-by: Jiri Pirko Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- drivers/net/wireguard/netlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlink.c index c17aee454fa3b..f7055180ba4aa 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -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); -- 2.43.0