Re: [PATCH 1/2] tuntap: forbid calling TUNSETIFF when detached

2013-01-11 Thread Jason Wang
On 01/11/2013 10:55 PM, Eric Dumazet wrote: > On Fri, 2013-01-11 at 16:50 +0800, Jason Wang wrote: > >> >> +if (rcu_dereference_protected(tfile->detached, lockdep_rtnl_is_held())) >> +return -EINVAL; >> + > Thats an open coded rtnl_dereference() > > (please cleanup the whole tun.c

Re: [PATCH 1/2] tuntap: forbid calling TUNSETIFF when detached

2013-01-11 Thread Jason Wang
On 01/11/2013 10:42 PM, Stefan Hajnoczi wrote: > On Fri, Jan 11, 2013 at 04:50:41PM +0800, Jason Wang wrote: >> @@ -1546,6 +1544,9 @@ static int tun_set_iff(struct net *net, struct file >> *file, struct ifreq *ifr) >> struct net_device *dev; >> int err; >> >> +if (rcu_dereference_p

Re: [PATCH 1/2] tuntap: forbid calling TUNSETIFF when detached

2013-01-11 Thread Eric Dumazet
On Fri, 2013-01-11 at 16:50 +0800, Jason Wang wrote: > > + if (rcu_dereference_protected(tfile->detached, lockdep_rtnl_is_held())) > + return -EINVAL; > + Thats an open coded rtnl_dereference() (please cleanup the whole tun.c file) -- To unsubscribe from this list: send the

Re: [PATCH 1/2] tuntap: forbid calling TUNSETIFF when detached

2013-01-11 Thread Stefan Hajnoczi
On Fri, Jan 11, 2013 at 04:50:41PM +0800, Jason Wang wrote: > @@ -1546,6 +1544,9 @@ static int tun_set_iff(struct net *net, struct file > *file, struct ifreq *ifr) > struct net_device *dev; > int err; > > + if (rcu_dereference_protected(tfile->detached, lockdep_rtnl_is_held())) >

[PATCH 1/2] tuntap: forbid calling TUNSETIFF when detached

2013-01-11 Thread Jason Wang
Michael points out that even after Stefan's fix the TUNSETIFF is still allowed to create a new tap device. This because we only check tfile->tun but the tfile->detached were introduced. Fix this by failing early in tun_set_iff() if the file is detached. After this fix, there's no need to do the che