netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wang Chen <wangchen@cn.fujitsu.com>
To: Patrick McHardy <kaber@trash.net>
Cc: "David S. Miller" <davem@davemloft.net>, NETDEV <netdev@vger.kernel.org>
Subject: Re: RFC: [PATCH 2/3] netdevice: Fix promiscuity and allmulti overflow
Date: Mon, 16 Jun 2008 17:51:21 +0800	[thread overview]
Message-ID: <48563799.4080200@cn.fujitsu.com> (raw)
In-Reply-To: <4856349C.70201@trash.net>

Patrick McHardy said the following on 2008-6-16 17:38:
> Wang Chen wrote:
>> diff --git a/net/core/dev.c b/net/core/dev.c
>> index 5829630..a3c692d 100644
>> --- a/net/core/dev.c
>> +++ b/net/core/dev.c
>> @@ -2753,10 +2753,20 @@ static void __dev_set_promiscuity(struct
>> net_device *dev, int inc)
>>  
>>      ASSERT_RTNL();
>>  
>> +    dev->flags |= IFF_PROMISC;
>>      if ((dev->promiscuity += inc) == 0)
>> -        dev->flags &= ~IFF_PROMISC;
>> -    else
>> -        dev->flags |= IFF_PROMISC;
>> +        /*
>> +         * Avoid overflow.
>> +         * If inc causes overflow, ignore it and warn user.
>> +         */
>> +        if (inc < 0)
>> +            dev->flags &= ~IFF_PROMISC;
>> +        else {
>> +            dev->promiscuity -= inc;
>> +            printk(KERN_ERR "%s: promiscuity touches roof, "
>> +                "set promiscuity failed, promiscuity feature "
>> +                "of device will be broken.\n");
>> +        }
> 
> Additional parens around the inner block would make this more
> readable.
> 

Will fix.

> I question the need for this though, userspace can only trigger
> an increase/decrease by one no matter how often it enables
> the ALLMULTI/PROMISC flags, and I doubt any codepath in the
> kernel would lead to an overflow.
> 

How about mif6_add()?
Do we have a limit for mif6?

> If this can really happen it would be better to leave the
> counter untouched and return an error, we already have too
> many device operations that might fail more or less silently.
> 

This can be done.


  reply	other threads:[~2008-06-16  9:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-16  9:15 RFC: [PATCH 2/3] netdevice: Fix promiscuity and allmulti overflow Wang Chen
2008-06-16  9:38 ` Patrick McHardy
2008-06-16  9:51   ` Wang Chen [this message]
2008-06-16 10:04     ` Patrick McHardy
2008-06-16 15:05 ` v2: " Wang Chen
2008-06-17 12:59   ` Patrick McHardy
2008-06-18  1:51     ` Wang Chen
2008-06-18  4:54       ` David Miller
2008-06-18  8:44         ` Patrick McHardy
2008-06-18  8:49           ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48563799.4080200@cn.fujitsu.com \
    --to=wangchen@cn.fujitsu.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).