lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6ef40195-9648-40db-8e36-a2a0095aa411@openvpn.net>
Date: Mon, 20 Jan 2025 15:12:28 +0100
From: Antonio Quartulli <antonio@...nvpn.net>
To: Sabrina Dubroca <sd@...asysnail.net>
Cc: netdev@...r.kernel.org, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
 Donald Hunter <donald.hunter@...il.com>, Shuah Khan <shuah@...nel.org>,
 ryazanov.s.a@...il.com, Andrew Lunn <andrew+netdev@...n.ch>,
 Simon Horman <horms@...nel.org>, linux-kernel@...r.kernel.org,
 linux-kselftest@...r.kernel.org, Xiao Liang <shaw.leon@...il.com>
Subject: Re: [PATCH net-next v18 12/25] ovpn: implement TCP transport

On 17/01/2025 18:14, Sabrina Dubroca wrote:
> 2025-01-13, 10:31:31 +0100, Antonio Quartulli wrote:
>> +static int ovpn_tcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
>> +			    int flags, int *addr_len)
>> +{
>> +	int err = 0, off, copied = 0, ret;
>> +	struct ovpn_socket *sock;
>> +	struct ovpn_peer *peer;
>> +	struct sk_buff *skb;
>> +
>> +	rcu_read_lock();
>> +	sock = rcu_dereference_sk_user_data(sk);
>> +	if (!sock || !sock->peer) {
>> +		rcu_read_unlock();
>> +		return -EBADF;
>> +	}
>> +	/* we take a reference to the peer linked to this TCP socket, because
>> +	 * in turn the peer holds a reference to the socket itself.

Going back now to this specific comment:

> 
> Not anymore since v12? [*]
> 
> I think it's ok here because we're only using peer and sk (not
> anything from ovpn_socket), but it is relevant in _sendmsg, which has
> the same peer_hold pattern without this comment.

After applying to _sendmsg() the modifications you suggested (i.e. 
reference peer directly instead of sock->peer), it also only uses peer 
and sk, but not ovpn_socket.
Therefore it should be fine too.

This said, the comment above should go away or at least should be modified.

> 
> [*]
> v11:
>   - https://lore.kernel.org/netdev/20241029-b4-ovpn-v11-8-de4698c73a25@openvpn.net/
>     ovpn_peer_release -> ovpn_socket_put
> 
> v12:
>   - https://lore.kernel.org/netdev/20241202-b4-ovpn-v12-9-239ff733bf97@openvpn.net/
>     ovpn_peer_release doesn't do ovpn_socket_put
> 
>   - https://lore.kernel.org/netdev/20241202-b4-ovpn-v12-7-239ff733bf97@openvpn.net/
>     ovpn_socket_put is done directly at ovpn_peer_remove time, before the final peer_put

Right - the lifetime of ovpn_socket is not tied to ovpn_peer anymore.
However, with the current code I don't think we ever assume that.


Regards,

-- 
Antonio Quartulli
OpenVPN Inc.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ