]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Merge branch 'netpoll-use-rcu-primitives-for-npinfo-pointer-access'
authorJakub Kicinski <kuba@kernel.org>
Tue, 19 Nov 2024 02:59:34 +0000 (18:59 -0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 19 Nov 2024 03:01:47 +0000 (19:01 -0800)
Breno Leitao says:

====================
netpoll: Use RCU primitives for npinfo pointer access

The net_device->npinfo pointer is marked with __rcu, indicating it requires
proper RCU access primitives:

  struct net_device {
...
struct netpoll_info __rcu *npinfo;
...
  };

Direct access to this pointer can lead to issues such as:
- Compiler incorrectly caching/reusing stale pointer values
- Missing memory ordering guarantees
- Non-atomic pointer loads

Replace direct NULL checks of npinfo with rcu_access_pointer(),
which provides the necessary memory ordering guarantees without the
overhead of a full RCU dereference, since we only need to verify
if the pointer is NULL.

In both cases, the RCU read lock is not held when the function is being
called. I checked that by using lockdep_assert_in_rcu_read_lock(), and
seeing the warning on both cases.
====================

Link: https://patch.msgid.link/20241118-netpoll_rcu-v1-0-a1888dcb4a02@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

Trivial merge