netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: David Stevens <dlstevens@us.ibm.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>,
	alan@lxorguk.ukuu.org.uk, davem@davemloft.net,
	netdev@vger.kernel.org, netdev-owner@vger.kernel.org,
	Eric Sesterhenn <snakebyte@gmx.de>
Subject: Re: [PATCH] net: fix /proc/net/snmp as memory corruptor
Date: Sat, 08 Nov 2008 21:46:36 +0100	[thread overview]
Message-ID: <4915FAAC.1010905@cosmosbay.com> (raw)
In-Reply-To: <OF6C282093.F9856B9A-ON882574FB.006C580F-882574FB.006D3BF5@us.ibm.com>

David Stevens a écrit :
> Oh, that was me! Thank you, Alexey!
> 
>> This should be fixed as well, or multiple threads reading /proc/net/snmp
>> could get mixed results without proper locking.
> 
> I don't believe locking is an issue here. If the values
> change between the first and second tests, being counters,
> they are still nonzero. If they are different in different
> threads, it reflects an actual change in the counter. So
> I'm not sure what you're talking about here.

If you are not sure what I am talking about, then you should probably
not use static variables at all. I found this fix quite obvious...

> 
> I don't think they should be on the stack (obviously, or
> I wouldn't have written it this way). So, FWIW, I like
> Alexey's fix, which is what the code should've been.

You apparently missed the fact that with your new code, we can have more than
16 different ICMP counters > 0.

thread 1 on CPU 1
-----------------

- fills 16 indexes in static table
- print them. good.

- fills *next* 16 indexes in static table
... preempted by some IRQ or something....

thread 2 on CPU 2
------------------

fills 16 indexes in static table, overwriting
the values that thread 1 was trying to put.
...

thread 1:

print the values of thread 2.
(it will probably prints a copy of its first line)

bang : User application missed some critical information.


> 
> For Alexey's patch:
> 
> Acked-by: David L Stevens <dlstevens@us.ibm.com>


  reply	other threads:[~2008-11-08 20:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-08  0:22 seq_read bugs with ipmr Eric Sesterhenn
2008-11-08  1:02 ` Alexey Dobriyan
2008-11-08  2:52   ` Alexey Dobriyan
2008-11-08  3:36     ` [PATCH] net: fix /proc/net/snmp as memory corruptor Alexey Dobriyan
2008-11-08  5:53       ` Eric Dumazet
2008-11-08  6:22         ` Alexey Dobriyan
2008-11-08  6:42         ` Alexey Dobriyan
2008-11-08  9:48           ` Eric Sesterhenn
2008-11-08 19:53         ` David Stevens
2008-11-08 20:46           ` Eric Dumazet [this message]
2008-11-08 21:05             ` David Stevens
2008-11-09  8:25               ` Eric Dumazet
2008-11-11  5:43         ` 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=4915FAAC.1010905@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=adobriyan@gmail.com \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=davem@davemloft.net \
    --cc=dlstevens@us.ibm.com \
    --cc=netdev-owner@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=snakebyte@gmx.de \
    /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).