All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 1/1] driver: tun: Forbid to set IFF_TUN and IFF_TAP at the same time
@ 2016-10-21  6:14 fgao
  2016-10-21 10:50 ` Sergei Shtylyov
  0 siblings, 1 reply; 2+ messages in thread
From: fgao @ 2016-10-21  6:14 UTC (permalink / raw)
  To: davem, jasowang, edumazet, pabeni, netdev; +Cc: gfree.wind, Gao Feng

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>
---
 drivers/net/tun.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 8093e39..c1f89c1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1752,6 +1752,10 @@ 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 */
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next 1/1] driver: tun: Forbid to set IFF_TUN and IFF_TAP at the same time
  2016-10-21  6:14 [PATCH net-next 1/1] driver: tun: Forbid to set IFF_TUN and IFF_TAP at the same time fgao
@ 2016-10-21 10:50 ` Sergei Shtylyov
  0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2016-10-21 10:50 UTC (permalink / raw)
  To: fgao, davem, jasowang, edumazet, pabeni, netdev; +Cc: gfree.wind

Hello.

On 10/21/2016 9:14 AM, 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>
> ---
>  drivers/net/tun.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index 8093e39..c1f89c1 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -1752,6 +1752,10 @@ 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;
> +		}

    {} not needed here.

MBR, Sergei

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-21 10:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21  6:14 [PATCH net-next 1/1] driver: tun: Forbid to set IFF_TUN and IFF_TAP at the same time fgao
2016-10-21 10:50 ` Sergei Shtylyov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.