Subject: Re: [PATCH net-next] net/tls: Use RCU API to access tls_ctx->netdev

From: Jakub Kicinski <[email-masked]>
Date: Mon, 1 Aug 2022 12:44:19 -0700

On Mon, 1 Aug 2022 11:00:53 +0300 Maxim Mikityanskiy wrote:
> Currently, tls_device_down synchronizes with tls_device_resync_rx using
> RCU, however, the pointer to netdev is stored using WRITE_ONCE and
> loaded using READ_ONCE.
> 
> Although such approach is technically correct (rcu_dereference is
> essentially a READ_ONCE, and rcu_assign_pointer uses WRITE_ONCE to store
> NULL), using special RCU helpers for pointers is more valid, as it
> includes additional checks and might change the implementation
> transparently to the callers.
> 
> Mark the netdev pointer as __rcu and use the correct RCU helpers to
> access it. For non-concurrent access pass the right conditions that
> guarantee safe access (locks taken, refcount value). Also use the
> correct helper in mlx5e, where even READ_ONCE was missing.

Oops, looks like we also got some new sparse warnings from this:

2 new warnings in drivers/net/bonding/bond_main.c
1 new warning  in drivers/net/ethernet/chelsio/inline_crypto/ch_ktls/chcr_ktls.c