netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access
@ 2024-11-18 11:15 Breno Leitao
  2024-11-18 11:15 ` [PATCH net 1/2] netpoll: Use rcu_access_pointer() in __netpoll_setup Breno Leitao
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Breno Leitao @ 2024-11-18 11:15 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Herbert Xu, Stephen Hemminger
  Cc: netdev, linux-kernel, Breno Leitao, paulmck

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@debian.org>
---
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@debian.org>


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-11-20 17:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18 11:15 [PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access Breno Leitao
2024-11-18 11:15 ` [PATCH net 1/2] netpoll: Use rcu_access_pointer() in __netpoll_setup Breno Leitao
2024-11-18 12:18   ` Michal Kubiak
2024-11-19  3:28   ` Herbert Xu
2024-11-19 10:22     ` Breno Leitao
2024-11-20  3:01       ` Herbert Xu
2024-11-20  3:48         ` Herbert Xu
2024-11-20 17:58           ` Breno Leitao
2024-11-18 11:15 ` [PATCH net 2/2] netpoll: Use rcu_access_pointer() in netpoll_poll_lock Breno Leitao
2024-11-18 12:20   ` Michal Kubiak
2024-11-18 15:37     ` Breno Leitao
2024-11-19  3:02       ` Jakub Kicinski
2024-11-19  3:48   ` Herbert Xu
2024-11-19  3:40 ` [PATCH net 0/2] netpoll: Use RCU primitives for npinfo pointer access patchwork-bot+netdevbpf
2024-11-19  3:53   ` Herbert Xu
2024-11-19 14:34     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).