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: <20250210195217.GZ554665@kernel.org>
Date: Mon, 10 Feb 2025 19:52:17 +0000
From: Simon Horman <horms@...nel.org>
To: "Matthieu Baerts (NGI0)" <matttbe@...nel.org>
Cc: mptcp@...ts.linux.dev, Mat Martineau <martineau@...nel.org>,
	Geliang Tang <geliang@...nel.org>,
	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v3 12/15] mptcp: pm: reuse sending nlmsg code in
 get_addr

On Fri, Feb 07, 2025 at 02:59:30PM +0100, Matthieu Baerts (NGI0) wrote:
> From: Geliang Tang <tanggeliang@...inos.cn>
> 
> The netlink messages are sent both in mptcp_pm_nl_get_addr() and
> mptcp_userspace_pm_get_addr(), this makes the code somewhat repetitive.
> This is because the netlink PM and userspace PM use different locks to
> protect the address entry that needs to be sent via the netlink message.
> The former uses rcu read lock, and the latter uses msk->pm.lock.
> 
> The current get_addr() flow looks like this:
> 
> 	lock();
> 	entry = get_entry();
> 	send_nlmsg(entry);
> 	unlock();
> 
> After holding the lock, get the entry from the list, send the entry, and
> finally release the lock.
> 
> This patch changes the process by getting the entry while holding the lock,
> then making a copy of the entry so that the lock can be released. Finally,
> the copy of the entry is sent without locking:
> 
> 	lock();
> 	entry = get_entry();
> 	*copy = *entry;
> 	unlock();
> 
> 	send_nlmsg(copy);
> 
> This way we can reuse the send_nlmsg() code in get_addr() interfaces
> between the netlink PM and userspace PM. They only need to implement their
> own get_addr() interfaces to hold the different locks, get the entry from
> the different lists, then release the locks.
> 
> Signed-off-by: Geliang Tang <tanggeliang@...inos.cn>
> Reviewed-by: Matthieu Baerts (NGI0) <matttbe@...nel.org>
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@...nel.org>

Reviewed-by: Simon Horman <horms@...nel.org>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ