Message ID | 1477047735-26003-1-git-send-email-fgao@ikuai8.com |
---|---|
State | Rejected, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, 2016-10-21 at 19:02 +0800, fgao@ikuai8.com wrote: > From: Gao Feng <fgao@ikuai8.com> > > Current tun driver permits the ifr_flags is set with IFF_TUN and > IFF_TAP at the same time. But actually there is only IFF_TUN flag > works. And it does not make sense these two flags are set, so add > this check. > > Signed-off-by: Gao Feng <fgao@ikuai8.com> > --- > v2: Remove useless {} > v1: Initial patch > > drivers/net/tun.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/net/tun.c b/drivers/net/tun.c > index 8093e39..faaa189 100644 > --- a/drivers/net/tun.c > +++ b/drivers/net/tun.c > @@ -1752,6 +1752,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) > if (err < 0) > return err; > > + if ((ifr->ifr_flags & (IFF_TUN | IFF_TAP)) == (IFF_TUN | IFF_TAP)) > + return -EINVAL; > + > /* Set dev type */ > if (ifr->ifr_flags & IFF_TUN) { > /* TUN device */ This might break some applications. It might be too late to add this check without a grace period.
Hi Eric, On Fri, Oct 21, 2016 at 7:28 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote: > On Fri, 2016-10-21 at 19:02 +0800, fgao@ikuai8.com wrote: >> From: Gao Feng <fgao@ikuai8.com> >> >> Current tun driver permits the ifr_flags is set with IFF_TUN and >> IFF_TAP at the same time. But actually there is only IFF_TUN flag >> works. And it does not make sense these two flags are set, so add >> this check. >> >> Signed-off-by: Gao Feng <fgao@ikuai8.com> >> --- >> v2: Remove useless {} >> v1: Initial patch >> >> drivers/net/tun.c | 3 +++ >> 1 file changed, 3 insertions(+) >> >> diff --git a/drivers/net/tun.c b/drivers/net/tun.c >> index 8093e39..faaa189 100644 >> --- a/drivers/net/tun.c >> +++ b/drivers/net/tun.c >> @@ -1752,6 +1752,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) >> if (err < 0) >> return err; >> >> + if ((ifr->ifr_flags & (IFF_TUN | IFF_TAP)) == (IFF_TUN | IFF_TAP)) >> + return -EINVAL; >> + >> /* Set dev type */ >> if (ifr->ifr_flags & IFF_TUN) { >> /* TUN device */ > > > This might break some applications. Yes. I consider about this case. But I think there should be very least applications which set these two flags at the same time. > > It might be too late to add this check without a grace period. > > > Yes, It needs some discussions. Regards Feng
From: fgao@ikuai8.com Date: Fri, 21 Oct 2016 19:02:15 +0800 > From: Gao Feng <fgao@ikuai8.com> > > Current tun driver permits the ifr_flags is set with IFF_TUN and > IFF_TAP at the same time. But actually there is only IFF_TUN flag > works. And it does not make sense these two flags are set, so add > this check. > > Signed-off-by: Gao Feng <fgao@ikuai8.com> We've allowed this for too long to start failing on it now, sorry.
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 8093e39..faaa189 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1752,6 +1752,9 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) if (err < 0) return err; + if ((ifr->ifr_flags & (IFF_TUN | IFF_TAP)) == (IFF_TUN | IFF_TAP)) + return -EINVAL; + /* Set dev type */ if (ifr->ifr_flags & IFF_TUN) { /* TUN device */