All of lore.kernel.org
 help / color / mirror / Atom feed
From: Donald Hunter <donald.hunter@gmail.com>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org,  Ido Schimmel <idosch@nvidia.com>,
	 Jiri Pirko <jiri@nvidia.com>,
	 eric.dumazet@gmail.com
Subject: Re: [PATCH v2 net-next 01/14] rtnetlink: prepare nla_put_iflink() to run under RCU
Date: Mon, 26 Feb 2024 08:59:47 +0000	[thread overview]
Message-ID: <m2bk83ob24.fsf@gmail.com> (raw)
In-Reply-To: <CANn89i+PPT7QDQKs9c-fUeshr_+Heh_mCLfFxwCEtbnUM5fjxA@mail.gmail.com> (Eric Dumazet's message of "Sat, 24 Feb 2024 12:08:56 +0100")

Eric Dumazet <edumazet@google.com> writes:
>>
>> And use of them here:
>>
>> > diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c
>> > index 98c669ad5141479b509ee924ddba3da6bca554cd..f7fabba707ea640cab8863e63bb19294e333ba2c 100644
>> > --- a/drivers/net/can/vxcan.c
>> > +++ b/drivers/net/can/vxcan.c
>> > @@ -119,7 +119,7 @@ static int vxcan_get_iflink(const struct net_device *dev)
>> >
>> >       rcu_read_lock();
>> >       peer = rcu_dereference(priv->peer);
>> > -     iflink = peer ? peer->ifindex : 0;
>> > +     iflink = peer ? READ_ONCE(peer->ifindex) : 0;
>> >       rcu_read_unlock();
>> >
>> >       return iflink;
>>
>>
>> > We do not need an rcu_read_lock() only to fetch dev->ifindex, if this
>> > is what concerns you.
>>
>> In which case, it seems that no .ndo_get_iflink implementations should
>> need the rcu_read_* calls?
>
> rcu_read_lock() is needed in all cases a dereference is performed,
> expecting RCU protection of the pointer.
>
> In vxcan_get_iflink(), we access priv->peer, then peer->ifindex.
>
> rcu_read_lock() is needed because of the second dereference, peer->ifindex.
>
> Without rcu_read_lock(), peer could be freed before we get a chance to
> read peer->ifindex.

Thanks for the detailed explanation.

  reply	other threads:[~2024-02-26 10:19 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-22 10:50 [PATCH v2 net-next 00/14] rtnetlink: reduce RTNL pressure for dumps Eric Dumazet
2024-02-22 10:50 ` [PATCH v2 net-next 01/14] rtnetlink: prepare nla_put_iflink() to run under RCU Eric Dumazet
2024-02-23 13:29   ` Donald Hunter
2024-02-24  8:21     ` Eric Dumazet
2024-02-24 10:46       ` Donald Hunter
2024-02-24 11:08         ` Eric Dumazet
2024-02-26  8:59           ` Donald Hunter [this message]
2024-02-22 10:50 ` [PATCH v2 net-next 02/14] ipv6: prepare inet6_fill_ifla6_attrs() for RCU Eric Dumazet
2024-02-23 14:35   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 03/14] ipv6: prepare inet6_fill_ifinfo() for RCU protection Eric Dumazet
2024-02-22 16:36   ` Jiri Pirko
2024-02-22 16:43     ` Eric Dumazet
2024-02-23  7:19       ` Jiri Pirko
2024-02-22 16:45     ` Eric Dumazet
2024-02-23  7:16       ` Jiri Pirko
2024-02-22 10:50 ` [PATCH v2 net-next 04/14] ipv6: use xarray iterator to implement inet6_dump_ifinfo() Eric Dumazet
2024-02-23 14:42   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 05/14] netlink: fix netlink_diag_dump() return value Eric Dumazet
2024-02-23 12:30   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 06/14] netlink: hold nlk->cb_mutex longer in __netlink_dump_start() Eric Dumazet
2024-02-22 16:20   ` Jiri Pirko
2024-06-09  8:17     ` Tetsuo Handa
2024-06-09  8:29       ` Tetsuo Handa
2024-06-10 12:59         ` Eric Dumazet
2024-06-10 13:21           ` Tetsuo Handa
2024-02-22 10:50 ` [PATCH v2 net-next 07/14] rtnetlink: change nlk->cb_mutex role Eric Dumazet
2024-02-22 10:50 ` [PATCH v2 net-next 08/14] rtnetlink: add RTNL_FLAG_DUMP_UNLOCKED flag Eric Dumazet
2024-02-23 15:19   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 09/14] ipv6: switch inet6_dump_ifinfo() to RCU protection Eric Dumazet
2024-02-23 15:19   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 10/14] inet: allow ip_valid_fib_dump_req() to be called with RTNL or RCU Eric Dumazet
2024-02-23 15:22   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 11/14] nexthop: allow nexthop_mpath_fill_node() to be called without RTNL Eric Dumazet
2024-02-23 15:21   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 12/14] inet: switch inet_dump_fib() to RCU protection Eric Dumazet
2024-02-23 15:25   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 13/14] rtnetlink: make rtnl_fill_link_ifmap() RCU ready Eric Dumazet
2024-02-23 13:03   ` Donald Hunter
2024-02-22 10:50 ` [PATCH v2 net-next 14/14] rtnetlink: provide RCU protection to rtnl_fill_prop_list() Eric Dumazet
2024-02-23 13:03   ` Donald Hunter
2024-02-26 11:50 ` [PATCH v2 net-next 00/14] rtnetlink: reduce RTNL pressure for dumps 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=m2bk83ob24.fsf@gmail.com \
    --to=donald.hunter@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=idosch@nvidia.com \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.