All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] tun: allow positive return values on dev_get_valid_name() call
@ 2017-10-25 18:50 Julien Gomes
  2017-10-25 20:40 ` Cong Wang
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Julien Gomes @ 2017-10-25 18:50 UTC (permalink / raw)
  To: netdev; +Cc: davem, xiyou.wangcong, Julien Gomes

If the name argument of dev_get_valid_name() contains "%d", it will try
to assign it a unit number in __dev__alloc_name() and return either the
unit number (>= 0) or an error code (< 0).
Considering positive values as error values prevent tun device creations
relying this mechanism, therefor we should only consider negative values
as errors here.

Signed-off-by: Julien Gomes <julien@arista.com>
---
 drivers/net/tun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index ea29da91ea5a..4d2400c253ba 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -2253,7 +2253,7 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr)
 		if (!dev)
 			return -ENOMEM;
 		err = dev_get_valid_name(net, dev, name);
-		if (err)
+		if (err < 0)
 			goto err_free_dev;
 
 		dev_net_set(dev, net);
-- 
2.14.2

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

* Re: [PATCH net] tun: allow positive return values on dev_get_valid_name() call
  2017-10-25 18:50 [PATCH net] tun: allow positive return values on dev_get_valid_name() call Julien Gomes
@ 2017-10-25 20:40 ` Cong Wang
  2017-10-26  1:10 ` David Miller
  2017-10-26  1:11 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Cong Wang @ 2017-10-25 20:40 UTC (permalink / raw)
  To: Julien Gomes; +Cc: Linux Kernel Network Developers, David Miller

On Wed, Oct 25, 2017 at 11:50 AM, Julien Gomes <julien@arista.com> wrote:
> If the name argument of dev_get_valid_name() contains "%d", it will try
> to assign it a unit number in __dev__alloc_name() and return either the
> unit number (>= 0) or an error code (< 0).
> Considering positive values as error values prevent tun device creations
> relying this mechanism, therefor we should only consider negative values
> as errors here.
>
> Signed-off-by: Julien Gomes <julien@arista.com>

Good catch! I missed this case indeed. We'd better document it
in the future.

Acked-by: Cong Wang <xiyou.wangcong@gmail.com>

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

* Re: [PATCH net] tun: allow positive return values on dev_get_valid_name() call
  2017-10-25 18:50 [PATCH net] tun: allow positive return values on dev_get_valid_name() call Julien Gomes
  2017-10-25 20:40 ` Cong Wang
@ 2017-10-26  1:10 ` David Miller
  2017-10-26  1:11 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-10-26  1:10 UTC (permalink / raw)
  To: julien; +Cc: netdev, xiyou.wangcong

From: Julien Gomes <julien@arista.com>
Date: Wed, 25 Oct 2017 11:50:50 -0700

> If the name argument of dev_get_valid_name() contains "%d", it will try
> to assign it a unit number in __dev__alloc_name() and return either the
> unit number (>= 0) or an error code (< 0).
> Considering positive values as error values prevent tun device creations
> relying this mechanism, therefor we should only consider negative values
> as errors here.
> 
> Signed-off-by: Julien Gomes <julien@arista.com>

Applied, thanks.

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

* Re: [PATCH net] tun: allow positive return values on dev_get_valid_name() call
  2017-10-25 18:50 [PATCH net] tun: allow positive return values on dev_get_valid_name() call Julien Gomes
  2017-10-25 20:40 ` Cong Wang
  2017-10-26  1:10 ` David Miller
@ 2017-10-26  1:11 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2017-10-26  1:11 UTC (permalink / raw)
  To: julien; +Cc: netdev, xiyou.wangcong

From: Julien Gomes <julien@arista.com>
Date: Wed, 25 Oct 2017 11:50:50 -0700

> If the name argument of dev_get_valid_name() contains "%d", it will try
> to assign it a unit number in __dev__alloc_name() and return either the
> unit number (>= 0) or an error code (< 0).
> Considering positive values as error values prevent tun device creations
> relying this mechanism, therefor we should only consider negative values
> as errors here.
> 
> Signed-off-by: Julien Gomes <julien@arista.com>

Applied.

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

end of thread, other threads:[~2017-10-26  1:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-25 18:50 [PATCH net] tun: allow positive return values on dev_get_valid_name() call Julien Gomes
2017-10-25 20:40 ` Cong Wang
2017-10-26  1:10 ` David Miller
2017-10-26  1:11 ` David Miller

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.