[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241118-netpoll_rcu-v1-0-a1888dcb4a02@debian.org>
Date: Mon, 18 Nov 2024 03:15:16 -0800
From: Breno Leitao <leitao@...ian.org>
To: "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Herbert Xu <herbert@...dor.apana.org.au>,
Stephen Hemminger <stephen@...workplumber.org>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Breno Leitao <leitao@...ian.org>, paulmck@...nel.org
Subject: [PATCH net 0/2] 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.
Signed-off-by: Breno Leitao <leitao@...ian.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@...ian.org>
Powered by blists - more mailing lists