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: <60A73B7A161A82449A7DB7B382BFD15537141B06@SZXEMA504-MBS.china.huawei.com>
Date:	Wed, 26 Aug 2015 07:48:05 +0000
From:	"Zhangjie (HZ)" <zhangjie14@...wei.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
CC:	Jason Wang <jasowang@...hat.com>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	Qinchuanyu <qinchuanyu@...wei.com>, Yewudi <yewudi@...wei.com>,
	liuyongan 00175866 <l00175866@...esmail.huawei.com.cn>,
	Wangbicheng <wangbicheng@...wei.com>,
	Yan Chen <Y.Chen@...wei.com>
Subject: RE: [Question] Usage of dev_hold()/dev_put()

Eric,
Thank you for your patient apply.
There is still a question, 
In receive path, driver does not call dev_hold(), when skb goes to host stack, skb->dev is likely to be used. 
If device is destroyed before that, it seems dangerous.

Thank you!
Zhangjie
-----Original Message-----
From: Eric Dumazet [mailto:eric.dumazet@...il.com] 
Sent: Tuesday, August 25, 2015 10:25 PM
To: Zhangjie (HZ)
Cc: Jason Wang; netdev@...r.kernel.org; Qinchuanyu; Yewudi; liuyongan 00175866; Wangbicheng; Yan Chen
Subject: Re: [Question] Usage of dev_hold()/dev_put()

On Tue, 2015-08-25 at 08:28 +0000, Zhangjie (HZ) wrote:
> Hi,
> 
> The comment of function dev_hold() and dev_put() are really simple.
> 
> Actually, I can’t find a rule to follow.
> 
> Where should I call dev_hold()/dev_put()?
> 
> Are they necessary during xmit or receive or only in register/release?
> 
> I find that, for tap, it calls dev_hold()/dev_put() for every
> tun_sendmsg/tun_recvmsg:
> 
> So, should I call dev_hold()/dev_put() for each quote, such like:
> “skb->dev = dev” ?
> 
> But, for physical nic, I can’t find dev_hold()/dev_put() during xmit 
> or receive.
> 
> What kind of scene is it necessary to call dev_hold()/dev_put()?
> 
>  
> 
> Look forward for your feedback. 
> 
> Thank you ! J
> 
> Zhangjie
> 
> 
Please do not send HTML mails, otherwise they do not reach netdev mailing list

In general, you need to use dev_hold() for every reference on 'dev'
stored in the object.

However they are some paths were you do not need that : For example in transmit path, skb are stored either in a qdisc or device driver internal queue/ring. At device dismantle we properly delete all these skb, so we do not have to worry about used dev_hold()/dev_put() in transmit.

In drivers/net/tun.c, the dev_hold()/dev_put() only is required so that device doesnt disappear between tun_get() and actual use of it after a potentially long copy from user space (that might trigger page faults)



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ