[PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access
From: Breno Leitao
Date: Mon Nov 18 2024 - 06:19:11 EST
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.
Signed-off-by: Breno Leitao <leitao@xxxxxxxxxx>
---
Breno Leitao (2):
netpoll: Use rcu_access_pointer() in __netpoll_setup
netpoll: Use rcu_access_pointer() in netpoll_poll_lock
include/linux/netpoll.h | 2 +-
net/core/netpoll.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
---
base-commit: 8ffade77b6337a8767fae9820d57d7a6413dd1a1
change-id: 20241115-netpoll_rcu-eb1296511b71
Best regards,
--
Breno Leitao <leitao@xxxxxxxxxx>