From: Jay Vosburgh <jv@jvosburgh.net>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: netdev@vger.kernel.org, Andy Gospodarek <andy@greyhouse.net>,
Johannes Berg <johannes.berg@intel.com>,
Jiri Pirko <jiri@nvidia.com>
Subject: Re: [PATCH net-next] net: bonding: correctly annotate RCU in bond_should_notify_peers()
Date: Sun, 21 Jul 2024 10:09:53 -0700 [thread overview]
Message-ID: <2730155.1721581793@famine> (raw)
In-Reply-To: <20240719094119.35c62455087d.I68eb9c0f02545b364b79a59f2110f2cf5682a8e2@changeid>
Johannes Berg <johannes@sipsolutions.net> wrote:
>From: Johannes Berg <johannes.berg@intel.com>
>
>RCU use in bond_should_notify_peers() looks wrong, since it does
>rcu_dereference(), leaves the critical section, and uses the
>pointer after that.
>
>Luckily, it's called either inside a nested RCU critical section
>or with the RTNL held.
>
>Annotate it with rcu_dereference_rtnl() instead, and remove the
>inner RCU critical section.
>
>Fixes: 4cb4f97b7e36 ("bonding: rebuild the lock use for bond_mii_monitor()")
>Reviewed-by: Jiri Pirko <jiri@nvidia.com>
>Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Acked-by: Jay Vosburgh <jv@jvosburgh.net>
>---
> drivers/net/bonding/bond_main.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>index d19aabf5d4fb..2ed0da068490 100644
>--- a/drivers/net/bonding/bond_main.c
>+++ b/drivers/net/bonding/bond_main.c
>@@ -1121,13 +1121,10 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
> return bestslave;
> }
>
>+/* must be called in RCU critical section or with RTNL held */
> static bool bond_should_notify_peers(struct bonding *bond)
> {
>- struct slave *slave;
>-
>- rcu_read_lock();
>- slave = rcu_dereference(bond->curr_active_slave);
>- rcu_read_unlock();
>+ struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave);
>
> if (!slave || !bond->send_peer_notif ||
> bond->send_peer_notif %
>--
>2.45.2
>
next prev parent reply other threads:[~2024-07-21 17:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-19 16:41 [PATCH net-next] net: bonding: correctly annotate RCU in bond_should_notify_peers() Johannes Berg
2024-07-21 17:09 ` Jay Vosburgh [this message]
2024-07-23 10:25 ` Paolo Abeni
2024-07-23 11:30 ` Johannes Berg
2024-07-23 13:12 ` Paolo Abeni
2024-07-23 13:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2730155.1721581793@famine \
--to=jv@jvosburgh.net \
--cc=andy@greyhouse.net \
--cc=jiri@nvidia.com \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).