Re: Promiscuity counter underflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


(追記) (追記ここまで)



Hi Stephen,
On Wed, 2010年05月12日 at 09:53 -0700, Stephen Hemminger wrote:
> Don't over do this. I think a simple test for:
> WARN_ON((int)dev->promiscuity + inc < 0);
> 	dev->promiscuity += inc;
>
> is sufficient since:
> * can only be triggered by buggy usage from kernel code
> * WARN gives backtrace of why this occured
> * is non fatal to system (so WARN not BUG)
I agree that the user should only be warned once about this to tell him
that incorrect behavior is expected.
Then it should be also done when the promiscuity value is about to
overflow.
I suggest the following changes:
Signed-off-by: Emmanuel Roullit <emmanuel@xxxxxxxxxxxxxxx>
Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxxxx>
diff --git a/net/core/dev.c b/net/core/dev.c
index 264137f..30a10e4 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3590,6 +3590,10 @@ static int __dev_set_promiscuity(struct
net_device *dev, 
 
 ASSERT_RTNL();
 
+ /* Check for overflow and underflow */
+ WARN_ON(inc > 0 && dev->promiscuity + inc < dev->promiscuity);
+ WARN_ON(inc < 0 && dev->promiscuity + inc > dev->promiscuity);
+
 dev->flags |= IFF_PROMISC;
 dev->promiscuity += inc;
 if (dev->promiscuity == 0) {
Cheers,
Emmanuel Roullit
--
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html

[Index of Archives] [Netdev] [Ethernet Bridging] [Linux 802.1Q VLAN] [Linux Wireless] [Kernel Newbies] [Security] [Linux for Hams] [Netfilter] [Git] [Bugtraq] [Yosemite News and Information] [MIPS Linux] [ARM Linux] [Linux RAID] [Linux PCI] [Linux Admin] [Samba]

(追記) (追記ここまで)
Powered by Linux

AltStyle によって変換されたページ (->オリジナル) /