From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fhigh-a2-smtp.messagingengine.com (fhigh-a2-smtp.messagingengine.com [103.168.172.153]) (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 8BE53346AC4; Tue, 12 May 2026 15:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778598309; cv=none; b=U1xeXli55TxEBb9kspQNcHsWm1Peder2W6p9jNxrdGg2ECE+CZKRdmghULUIa/wBWu7ZOk5K9bJWDC8SMA3ut8W+heXL9ZqfggSN22qxr9mMdsxYD0jv0mGngSXWYE5x1vPmi58GwZrSqGfD3W7QUnv8xI5jv9X4pENr+AxEJ+g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778598309; c=relaxed/simple; bh=VUqOtT28QtamBhTUI7hcF8tSInGIdl5ywozCPk2lkrk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=X+LcHrGsbTOQMpKWANVWpPYNx6TDPbD948jqYgwIwBo8sWz23SIoLqingC4dRQXbx/LOxdndchUepXEjO03IE7uU7j23r0POX30b2S20k3feNR4DJiCbggcZVAQj2R3xApzYNEmj+yK4cHYd5VWjQgI7NvXV7DztNIFA5pzSBsE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=queasysnail.net; spf=pass smtp.mailfrom=queasysnail.net; dkim=pass (2048-bit key) header.d=queasysnail.net header.i=@queasysnail.net header.b=AS9onW9l; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=WGi3imwL; arc=none smtp.client-ip=103.168.172.153 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=queasysnail.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=queasysnail.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=queasysnail.net header.i=@queasysnail.net header.b="AS9onW9l"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="WGi3imwL" Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id B602C140020E; Tue, 12 May 2026 11:05:05 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Tue, 12 May 2026 11:05:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=queasysnail.net; h=cc:cc:content-type:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to; s=fm1; t=1778598305; x= 1778684705; bh=UZIvXI70GG2eH5JwWXbZK5ECjIUULOELaOAAhDLAcYo=; b=A S9onW9lMU7lHHTQAq/4mwGFI7BBYj4jYt2f9thwwMz+W1C6ngttcA6jMnUI1VW5N Y+Of+i5TdX8uIcwB/L3+A5QcQPkfktsIbolw1Fy39iRwWDGM0uhjH37EQG2eoYcT IcIleb9ixMIe1+Oqy6erdxcelygS19StpYtcIAu87LvYqtpHZsEyN8BDfKNaPMzV whXp2ovMaiW1IgbTLjwHDzMQACFdwrSh6ct+WzRyCZgrkj1Dz2rsbnoONHf/+SeT c4MJHxazQYYslCvwMgF01GUyr72/zMaejqKZWMgbsj8+Mq3ooGdMIErDKGZhE+s3 2AT5rYlQMBciXgaKS+0Jg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1778598305; x=1778684705; bh=UZIvXI70GG2eH5JwWXbZK5ECjIUULOELaOA AhDLAcYo=; b=WGi3imwLKWQcQOarF2fbzasGfN/tlWfRH58KKRelCpdcsg14Icg 2yoTZIUbpoZEVoIHofrnkaEOlAIyR6WVbxcAgj9bgG433dPty2th1bK2sPD6P6q8 EVZknawJtnU8lrhpc+Vst3yTGQEYkDNQJhKPwYCI8LBerrVrIbIrx6hSDC23m4GE JEPFIXN0v37CPinghww1xBbYlkK6eAsJBAIydf8y0VfLIVkwTeY9z6o7KMGlXs6u +pXPKpNID1CPBorI+v2RJlKHk2UGM90gYw19A5B5oLN1/BDU/r8wZdy14KyoTgm/ x1++TDii2pWcrdq2V9MvaXjeka4FMib35UA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdduvddvudduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtredttddtjeenucfhrhhomhepufgrsghrihhn rgcuffhusghrohgtrgcuoehsugesqhhuvggrshihshhnrghilhdrnhgvtheqnecuggftrf grthhtvghrnhepuefhhfffgfffhfefueeiudegtdefhfekgeetheegheeifffguedvueff fefgudffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epshgusehquhgvrghshihsnhgrihhlrdhnvghtpdhnsggprhgtphhtthhopeelpdhmohgu vgepshhmthhpohhuthdprhgtphhtthhopegrnhhtohhnihhosehophgvnhhvphhnrdhnvg htpdhrtghpthhtohepuggvvhhnvgigvghnsehgmhgrihhlrdgtohhmpdhrtghpthhtohep vgguuhhmrgiivghtsehgohhoghhlvgdrtghomhdprhgtphhtthhopehnvghtuggvvhesvh hgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrnhgurhgvfidonhgvthguvghv sehluhhnnhdrtghhpdhrtghpthhtohepuggrvhgvmhesuggrvhgvmhhlohhfthdrnhgvth dprhgtphhtthhopehkuhgsrgeskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepphgrsggv nhhisehrvgguhhgrthdrtghomhdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvh hgvghrrdhkvghrnhgvlhdrohhrgh X-ME-Proxy: Feedback-ID: i934648bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 May 2026 11:05:01 -0400 (EDT) Date: Tue, 12 May 2026 17:04:59 +0200 From: Sabrina Dubroca To: Antonio Quartulli Cc: David CARLIER , Eric Dumazet , netdev@vger.kernel.org, Andrew Lunn , "David S. Miller" , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: Re: [PATCH net 1/2] ovpn: tcp - use cached peer pointer in ovpn_tcp_close() Message-ID: References: <20260512042036.19870-1-devnexen@gmail.com> <20260512042036.19870-2-devnexen@gmail.com> <4ff6590a-6695-4c6c-b677-a7891b249165@openvpn.net> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: 2026-05-12, 16:17:39 +0200, Antonio Quartulli wrote: > On 12/05/2026 16:11, Sabrina Dubroca wrote: > > 2026-05-12, 15:55:39 +0200, Antonio Quartulli wrote: > > > Hi, > > > > > > On 12/05/2026 06:56, David CARLIER wrote: > > > > Same multi-read pattern shows up in ovpn_tcp_recvmsg(), > > > > ovpn_tcp_sendmsg(), ovpn_tcp_data_ready() and ovpn_tcp_write_space() > > > > - happy to roll those into v2 as well, or punt to a follow-up, > > > > whichever you'd prefer. > > > > > > @Eric, if you have no objection, I'd pick this patch up in my tree and let > > > David follow with a new patch for net-next. > > > > But this patch is not fixing any problem either, right? > > Mh, because the sock outlives the peer, so there is no risk in accessing > sock->peer in this case, right? I guess I got distracted by some of the discussion. I thought this was only about "peer and sock->peer may differ", and not "sock may be gone so sock->peer is not valid". sock->peer can't change behind our backs, because, as David said: sock->peer is only assigned once, in ovpn_socket_new() But the sock doesn't outlive the peer. ovpn_socket_release() does ovpn_peer_put(), and frees the ovpn_socket immediately via kfree(sock). So if: ovpn_tcp_close() starts, finds sk_user_data set and a peer, does peer_hold the peer gets deleted in parallel, ovpn_socket_release() frees the ovpn_socket ovpn_tcp_close() resumes and does ovpn_peer_del(sock->peer) we can indeed hit a UAF on sock. So this patch is needed as-is, sorry for my confusion earlier: Reviewed-by: Sabrina Dubroca The refactoring of all those peer accesses can be done in -next. -- Sabrina