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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5354BAEE.9000005@hp.com>
Date:	Mon, 21 Apr 2014 14:30:06 +0800
From:	"Li, ZhenHua" <zhen-hual@...com>
To:	Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
CC:	"David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Veaceslav Falico <vfalico@...hat.com>,
	Nicolas Dichtel <nicolas.dichtel@...nd.com>,
	Jiri Pirko <jiri@...nulli.us>,
	stephen hemminger <stephen@...workplumber.org>,
	Jerry Chu <hkchu@...gle.com>,
	Sathya Perla <sathya.perla@...lex.com>,
	Subbu Seetharaman <subbu.seetharaman@...lex.com>,
	Ajit Khaparde <ajit.khaparde@...lex.com>,
	netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] net: Add rtnl_lock for netif_device_attach/detach

The comment is trying to explain why add a lock here.

On 04/19/2014 03:01 AM, Sergei Shtylyov wrote:
> Hello.
>
> On 04/16/2014 11:08 AM, Li, Zhen-Hua wrote:
>
>> From: "Li, Zhen-Hua" <zhen-hual@...com>
>
>> As netif_running is called in netif_device_attach/detach. There 
>> should be
>> rtnl_lock/unlock called, to avoid dev stat change during 
>> netif_device_attach
>> and detach being called.
>> I checked NIC some drivers,  some of them have 
>> netif_device_attach/detach
>> called between rtnl_lock/unlock, while some drivers do not.
>
>> This patch is tring to find a generic way to fix this for all NIC 
>> drivers.
>
>> Signed-off-by: Li, Zhen-Hua <zhen-hual@...com>
>> ---
>>   net/core/dev.c |   18 ++++++++++++++++++
>>   1 file changed, 18 insertions(+)
>
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 5b3042e..795bbc5 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -2190,10 +2190,19 @@ EXPORT_SYMBOL(__dev_kfree_skb_any);
>>    */
>>   void netif_device_detach(struct net_device *dev)
>>   {
>> +    /**
>
>   Hm, why kernel-doc style comment here?
>
>> +     * As netif_running is called , rtnl_lock and unlock are needed to
>> +     * avoid __LINK_STATE_START bit changes during this function call.
>> +     */
>> +    int need_unlock;
>> +
>> +    need_unlock = rtnl_trylock();
>>       if (test_and_clear_bit(__LINK_STATE_PRESENT, &dev->state) &&
>>           netif_running(dev)) {
>>           netif_tx_stop_all_queues(dev);
>>       }
>> +    if (need_unlock)
>> +        rtnl_unlock();
>>   }
>>   EXPORT_SYMBOL(netif_device_detach);
>>
>> @@ -2205,11 +2214,20 @@ EXPORT_SYMBOL(netif_device_detach);
>>    */
>>   void netif_device_attach(struct net_device *dev)
>>   {
>> +    /**
>
>   ... and here?
>
>> +     * As netif_running is called , rtnl_lock and unlock are needed to
>> +     * avoid __LINK_STATE_START bit changes during this function call.
>> +     */
>
> WBR, Sergei
>

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ