lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m2bk83ob24.fsf@gmail.com>
Date: Mon, 26 Feb 2024 08:59:47 +0000
From: Donald Hunter <donald.hunter@...il.com>
To: Eric Dumazet <edumazet@...gle.com>
Cc: "David S . Miller" <davem@...emloft.net>,  Jakub Kicinski
 <kuba@...nel.org>,  Paolo Abeni <pabeni@...hat.com>,
  netdev@...r.kernel.org,  Ido Schimmel <idosch@...dia.com>,  Jiri Pirko
 <jiri@...dia.com>,  eric.dumazet@...il.com
Subject: Re: [PATCH v2 net-next 01/14] rtnetlink: prepare nla_put_iflink()
 to run under RCU

Eric Dumazet <edumazet@...gle.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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ