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: <CANn89iJ3Lau_3W5bJdmRWL9BFUf3a40XqNgfjr7nCEu5PQ_otg@mail.gmail.com>
Date: Mon, 4 Aug 2025 00:36:31 -0700
From: Eric Dumazet <edumazet@...gle.com>
To: Qingfang Deng <dqfext@...il.com>
Cc: Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>, 
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>, linux-ppp@...r.kernel.org, 
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] ppp: remove rwlock usage

On Sun, Aug 3, 2025 at 11:20 PM Qingfang Deng <dqfext@...il.com> wrote:
>
> In struct channel, the upl lock is implemented using rwlock_t,
> protecting access to pch->ppp and pch->bridge.
>
> As previously discussed on the list, using rwlock in the network fast
> path is not recommended.
> This patch replaces the rwlock with a spinlock for writers, and uses RCU
> for readers.
>
> - pch->ppp and pch->bridge are now declared as __rcu pointers.
> - Readers use rcu_dereference_bh() under rcu_read_lock_bh().
> - Writers use spin_lock_bh() to update, followed by synchronize_rcu()
>   where required.
>
> Signed-off-by: Qingfang Deng <dqfext@...il.com>
> ---

....
For all your patch :

Since the spinlock is now only used from the control path in process
context, what is the reason you use _bh() suffix
blocking BH while holding it ?

Also, a mere rcu_read_lock() is enough for ppp_dev_name() and
ppp_unit_number() : No need to disable BH there.

> -       write_lock_bh(&pch->upl);
> -       ppp = pch->ppp;
> -       pch->ppp = NULL;
> -       write_unlock_bh(&pch->upl);
> +       spin_lock_bh(&pch->upl);
> +       ppp = rcu_replace_pointer(pch->ppp, NULL, lockdep_is_held(&pch->upl));
> +       spin_unlock_bh(&pch->upl);
> +       synchronize_rcu();
> +
>         if (ppp) {

You probably could move the synchronize_rcu() here, there is no need
to call it if ppp is NULL

>                 /* remove it from the ppp unit's list */
>                 ppp_lock(ppp);
> --
> 2.43.0
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ