* [PATCH net] dsa: fix promiscuity leak on slave dev open error
@ 2015-06-25 13:50 giladb
2015-06-26 15:04 ` Andrew Lunn
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: giladb @ 2015-06-25 13:50 UTC (permalink / raw)
To: davem
Cc: netdev, Gilad Ben-Yossef, Gilad Ben-Yossef, Florian Fainelli,
Guenter Roeck, Andrew Lunn, Scott Feldman
From: Gilad Ben-Yossef <gilad@benyossef.com>
DSA master netdev promiscuity counter was not being properly
decremented on slave device open error path.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: Gilad Ben-Yossef <giladb@ezchip.com>
CC: David S. Miller <davem@davemloft.net>
CC: Florian Fainelli <f.fainelli@gmail.com>
CC: Guenter Roeck <linux@roeck-us.net>
CC: Andrew Lunn <andrew@lunn.ch>
CC: Scott Feldman <sfeldma@gmail.com>
---
net/dsa/slave.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 04ffad3..0917123 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -112,7 +112,7 @@ static int dsa_slave_open(struct net_device *dev)
clear_promisc:
if (dev->flags & IFF_PROMISC)
- dev_set_promiscuity(master, 0);
+ dev_set_promiscuity(master, -1);
clear_allmulti:
if (dev->flags & IFF_ALLMULTI)
dev_set_allmulti(master, -1);
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH net] dsa: fix promiscuity leak on slave dev open error
2015-06-25 13:50 [PATCH net] dsa: fix promiscuity leak on slave dev open error giladb
@ 2015-06-26 15:04 ` Andrew Lunn
2015-06-28 13:19 ` Gilad Ben-Yossef
2015-06-26 16:40 ` Florian Fainelli
2015-06-28 23:57 ` David Miller
2 siblings, 1 reply; 7+ messages in thread
From: Andrew Lunn @ 2015-06-26 15:04 UTC (permalink / raw)
To: giladb
Cc: davem, netdev, Gilad Ben-Yossef, Florian Fainelli, Guenter Roeck,
Scott Feldman
On Thu, Jun 25, 2015 at 04:50:13PM +0300, giladb@ezchip.com wrote:
> From: Gilad Ben-Yossef <gilad@benyossef.com>
>
> DSA master netdev promiscuity counter was not being properly
> decremented on slave device open error path.
>
> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> CC: Gilad Ben-Yossef <giladb@ezchip.com>
> CC: David S. Miller <davem@davemloft.net>
> CC: Florian Fainelli <f.fainelli@gmail.com>
> CC: Guenter Roeck <linux@roeck-us.net>
> CC: Andrew Lunn <andrew@lunn.ch>
> CC: Scott Feldman <sfeldma@gmail.com>
Hi Gilad
Acked-by: Andrew Lunn <andrew@lunn.ch>
FYI: I grep'ed the whole kernel. This seems to be the only place 0 is
passed to dev_set_promiscuity(), i.e. the same bug is not present
anywhere else.
Thanks
Andrew
> ---
> net/dsa/slave.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 04ffad3..0917123 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -112,7 +112,7 @@ static int dsa_slave_open(struct net_device *dev)
>
> clear_promisc:
> if (dev->flags & IFF_PROMISC)
> - dev_set_promiscuity(master, 0);
> + dev_set_promiscuity(master, -1);
> clear_allmulti:
> if (dev->flags & IFF_ALLMULTI)
> dev_set_allmulti(master, -1);
> --
> 1.7.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] dsa: fix promiscuity leak on slave dev open error
2015-06-25 13:50 [PATCH net] dsa: fix promiscuity leak on slave dev open error giladb
2015-06-26 15:04 ` Andrew Lunn
@ 2015-06-26 16:40 ` Florian Fainelli
2015-06-28 23:57 ` David Miller
2 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2015-06-26 16:40 UTC (permalink / raw)
To: giladb, davem
Cc: netdev, Gilad Ben-Yossef, Guenter Roeck, Andrew Lunn, Scott Feldman
On 25/06/15 06:50, giladb@ezchip.com wrote:
> From: Gilad Ben-Yossef <gilad@benyossef.com>
>
> DSA master netdev promiscuity counter was not being properly
> decremented on slave device open error path.
>
> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
> CC: Gilad Ben-Yossef <giladb@ezchip.com>
> CC: David S. Miller <davem@davemloft.net>
> CC: Florian Fainelli <f.fainelli@gmail.com>
> CC: Guenter Roeck <linux@roeck-us.net>
> CC: Andrew Lunn <andrew@lunn.ch>
> CC: Scott Feldman <sfeldma@gmail.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> net/dsa/slave.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 04ffad3..0917123 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -112,7 +112,7 @@ static int dsa_slave_open(struct net_device *dev)
>
> clear_promisc:
> if (dev->flags & IFF_PROMISC)
> - dev_set_promiscuity(master, 0);
> + dev_set_promiscuity(master, -1);
> clear_allmulti:
> if (dev->flags & IFF_ALLMULTI)
> dev_set_allmulti(master, -1);
>
--
Florian
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] dsa: fix promiscuity leak on slave dev open error
2015-06-26 15:04 ` Andrew Lunn
@ 2015-06-28 13:19 ` Gilad Ben-Yossef
2015-06-28 17:09 ` Andrew Lunn
0 siblings, 1 reply; 7+ messages in thread
From: Gilad Ben-Yossef @ 2015-06-28 13:19 UTC (permalink / raw)
To: Andrew Lunn
Cc: Gilad Ben-Yossef, David Miller, Netdev, Florian Fainelli,
Guenter Roeck, Scott Feldman
On Fri, Jun 26, 2015 at 6:04 PM, Andrew Lunn <andrew@lunn.ch> wrote:
> On Thu, Jun 25, 2015 at 04:50:13PM +0300, giladb@ezchip.com wrote:
>> From: Gilad Ben-Yossef <gilad@benyossef.com>
>>
>> DSA master netdev promiscuity counter was not being properly
>> decremented on slave device open error path.
>>
...
> Acked-by: Andrew Lunn <andrew@lunn.ch>
Thank you Andrew.
>
> FYI: I grep'ed the whole kernel. This seems to be the only place 0 is
> passed to dev_set_promiscuity(), i.e. the same bug is not present
> anywhere else.
>
It has occurred to me that dev_set_promiscuity() and its brethren
dev_set_allmulti() may not be the best of interfaces:
- On cursory inspection of code using these function their name
implies the value of the relevant counter is set to the value passed
as parameter, not incremented by it.
- No caller I've managed to spot passes anything but -1 or 1
It seems an interface of
int dev_set_promiscuity(struct net_device *dev, bool on);
int dev_set_allmulti(struct net_device *dev, bool on);
would be as functional (for current users), more readable and less
error prone but I am not sure such a tiny problem (if you can call
this a problem) is worth the churn...
Gilad
--
Gilad Ben-Yossef
Chief Coffee Drinker
gilad@benyossef.com
Israel Cell: +972-52-8260388
US Cell: +1-973-8260388
http://benyossef.com
"If you take a class in large-scale robotics, can you end up in a
situation where the homework eats your dog?"
-- Jean-Baptiste Queru
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] dsa: fix promiscuity leak on slave dev open error
2015-06-28 13:19 ` Gilad Ben-Yossef
@ 2015-06-28 17:09 ` Andrew Lunn
0 siblings, 0 replies; 7+ messages in thread
From: Andrew Lunn @ 2015-06-28 17:09 UTC (permalink / raw)
To: Gilad Ben-Yossef
Cc: Gilad Ben-Yossef, David Miller, Netdev, Florian Fainelli,
Guenter Roeck, Scott Feldman
> It has occurred to me that dev_set_promiscuity() and its brethren
> dev_set_allmulti() may not be the best of interfaces:
>
> - On cursory inspection of code using these function their name
> implies the value of the relevant counter is set to the value passed
> as parameter, not incremented by it.
> - No caller I've managed to spot passes anything but -1 or 1
>
> It seems an interface of
>
> int dev_set_promiscuity(struct net_device *dev, bool on);
>
> int dev_set_allmulti(struct net_device *dev, bool on);
on suggests it is an absolute, when in fact you are passing an
increment, so i don't think it is much of an improvement.
Adding #define, PROMISC_INC and PROMISC_DEC might be clearer, and
since this is not a fast path, you could consider parameter
validation. Or dev_get_promiscuity(), det_put_promiscuity().
> would be as functional (for current users), more readable and less
> error prone but I am not sure such a tiny problem (if you can call
> this a problem) is worth the churn...
There was only one instance of it wrong, so it is not a very big
problem. I would say it is not worth the churn.
Andrew
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH net] dsa: fix promiscuity leak on slave dev open error
2015-06-25 13:50 [PATCH net] dsa: fix promiscuity leak on slave dev open error giladb
2015-06-26 15:04 ` Andrew Lunn
2015-06-26 16:40 ` Florian Fainelli
@ 2015-06-28 23:57 ` David Miller
2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2015-06-28 23:57 UTC (permalink / raw)
To: giladb; +Cc: netdev, gilad, f.fainelli, linux, andrew, sfeldma
From: <giladb@ezchip.com>
Date: Thu, 25 Jun 2015 16:50:13 +0300
> From: Gilad Ben-Yossef <gilad@benyossef.com>
>
> DSA master netdev promiscuity counter was not being properly
> decremented on slave device open error path.
>
> Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
Applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH net] dsa: fix promiscuity leak on slave dev open error
@ 2015-06-25 13:32 Gilad Ben-Yossef
0 siblings, 0 replies; 7+ messages in thread
From: Gilad Ben-Yossef @ 2015-06-25 13:32 UTC (permalink / raw)
To: davem
Cc: netdev, Gilad Ben-Yossef, Florian Fainelli, Guenter Roeck,
Andrew Lunn, Scott Feldman
DSA master netdev promiscuity counter was not being properly
decremented on slave device open error path.
Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: Gilad Ben-Yossef <giladb@ezchip.com>
CC: David S. Miller <davem@davemloft.net>
CC: Florian Fainelli <f.fainelli@gmail.com>
CC: Guenter Roeck <linux@roeck-us.net>
CC: Andrew Lunn <andrew@lunn.ch>
CC: Scott Feldman <sfeldma@gmail.com>
---
net/dsa/slave.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 04ffad3..0917123 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -112,7 +112,7 @@ static int dsa_slave_open(struct net_device *dev)
clear_promisc:
if (dev->flags & IFF_PROMISC)
- dev_set_promiscuity(master, 0);
+ dev_set_promiscuity(master, -1);
clear_allmulti:
if (dev->flags & IFF_ALLMULTI)
dev_set_allmulti(master, -1);
--
1.7.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-06-28 23:57 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-25 13:50 [PATCH net] dsa: fix promiscuity leak on slave dev open error giladb
2015-06-26 15:04 ` Andrew Lunn
2015-06-28 13:19 ` Gilad Ben-Yossef
2015-06-28 17:09 ` Andrew Lunn
2015-06-26 16:40 ` Florian Fainelli
2015-06-28 23:57 ` David Miller
-- strict thread matches above, loose matches on Subject: below --
2015-06-25 13:32 Gilad Ben-Yossef
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).