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]
Date:   Mon, 25 Feb 2019 15:31:19 -0800
From:   Eric Dumazet <eric.dumazet@...il.com>
To:     Dmitry Safonov <dima@...sta.com>,
        Eric Dumazet <eric.dumazet@...il.com>,
        linux-kernel@...r.kernel.org
Cc:     0x7f454c46@...il.com, "David S. Miller" <davem@...emloft.net>,
        Florian Westphal <fw@...len.de>,
        Hannes Frederic Sowa <hannes@...essinduktion.org>,
        netdev@...r.kernel.org
Subject: Re: [PATCH] rtnetlink: Synchronze net in rtnl_unregister()



On 02/25/2019 03:21 PM, Dmitry Safonov wrote:
> Hi Eric,
> 
> On 2/25/19 11:09 PM, Eric Dumazet wrote:
>> On 02/25/2019 01:27 PM, Dmitry Safonov wrote:
>>> While it's possible to document that rtnl_unregister() requires
>>> synchronize_net() afterwards - unlike rtnl_unregister_all(), I believe
>>> the module exit is very much slow-path.
>>
>> rtnl_unregister_all() needs the sychronize_rcu() at this moment
>> because of the kfree(tab), not because of the kfree_rcu(link, rcu);
> 
> I may be wrong here, but shouldn't we wait for grace period to elapse by
> the reason that rtnl_msg_handlers are protected by RCU, not only by rtnl?
> Like, without synchronize_net() in rtnl_unregister() - what prevents
> module exit race to say, rtnetlink_rcv_msg()=>rtnl_get_link()?
> 
> 
>>> --- a/net/core/rtnetlink.c
>>> +++ b/net/core/rtnetlink.c
>>> @@ -308,7 +308,9 @@ int rtnl_unregister(int protocol, int msgtype)
>>>  	rcu_assign_pointer(tab[msgindex], NULL);
>>>  	rtnl_unlock();
>>>  
>>> -	kfree_rcu(link, rcu);
>>> +	synchronize_net();
>>> +
>>> +	kfree(link);
>>
>>
>> I really do not see a difference here (other than this being much slower of course)
>>
>> If the caller needs rcu_barrier(), then add it in the caller ?
> 
> Well, sure - but it seems confusing that rtnl_unregister() will require
> synchronize_rcu(), while rtnl_unregister_all() will not.

rtnl_unregister_all() is a different beast, since it removes the whole rtnl_msg_handlers[protocol]

rtnl_unregister() only removes a subset, with different usages.

> And I thought no one would care about another synchronize_rcu() in exit
> path.

We definitely care about things be done properly.

If synchronize_rcu() is needed there, be it, but kfree_rcu() seems to be fine.

In any case, I believe you need to more carefully explain what is the problem here,
because I could not really see it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ