Re: [PATCH ovpn-net] ovpn: fix incorrect use of rcu_access_pointer()

Antonio Quartulli <[email protected]> Fri, 24 Jul 2026 08:42:46 +0200
Newsgroups gmane.network.openvpn.devel
Message-ID <[email protected]>
hi Qingfang,

When resending, please split the subject as "ovpn net" so that our patchwork can pick it up correctly.

Thanks a lot!

Il 24 Luglio 2026 03:20:51 CEST, Qingfang Deng <[email protected]> ha scritto:
>Hi Ralf,
>
>On 2026/7/23 15:59, Ralf Lici wrote:
>> rcu_dereference relies on rcu_read_lock_held to check that the caller
>> context is valid. However, ovpn_peer_release_p2p does not hold a normal
>> rcu_read_lock section, it relies on the BH-disabled section established
>> by spin_lock_bh instead.
>> 
>> rcu_read_lock_held does not consider BH-disabled context, so it will
>> return false here. In contrast, rcu_read_lock_bh_held explicitly
>> recognizes BH-disabled/softirq context.
>> 
>> So I think Sashiko is right: rcu_dereference will trigger its RCU
>> lockdep warning with CONFIG_PROVE_RCU enabled. This should use
>> rcu_dereference_bh instead.
>
>I read the code, and found that you are correct. I'll submit a new patch with your suggested change. Thank you.
>
>Best regards,
>
>Qingfang
>

Antonio Quartulli
Edited on mobile, please excuse typos and brevity.