All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernard Pidoux <bpidoux@free.fr>
To: netdev@vger.kernel.org, davem@davemloft.net
Cc: bpidoux@free.fr
Subject: [PATCH] negative dev use in /proc/net/rose_neigh
Date: Sun, 28 Sep 2008 21:56:38 +0200	[thread overview]
Message-ID: <200809282156.39466.bpidoux@free.fr> (raw)

[-- Attachment #1: Type: text/plain, Size: 1 bytes --]



[-- Attachment #2: [PATCH] negative dev use in /proc/net/rose_neigh --]
[-- Type: text/plain, Size: 1660 bytes --]

When running rose network applications, rose_neigh use counter can become negative as shown below.
Number 65535 actually represents a short integer underflow, meaning that use counter has been
decremented while equal to zero.
Then use counter continues to decrease by one each time the function is called.

proc/net/rose_neigh
addr  callsign  dev  count use mode restart  t0  tf digipeaters
00005 F5KCK-11  ax1      4   1  DTE     yes   0   0
00004 F6BVP-5   ax4      6   0  DTE      no   0   0
00003 F6BVP-7   ax4      6   0  DCE     yes   0   0
00002 F6BVP-11  ax4      6 65535  DCE     yes   0   0
00001 RSLOOP-0  ???      1   4  DCE     yes   0   0

After investigations I found that use counter value was going negative when
rose_kill_by_neigh() (in af_rose.c) was called and sk_for_each() macro loop activated
rose->neighbour->use-- more than once.

I propose the following patch to avoid use counter underflow.
However a KERN_WARNING message could be better instead of KERN_ERR.
 
Signed-off-by: Bernard Pidoux <f6bvp@amsat.org>
---
 net/rose/af_rose.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index a7f1ce1..8a54cff 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -175,7 +175,10 @@ void rose_kill_by_neigh(struct rose_neigh *neigh)
 
 		if (rose->neighbour == neigh) {
 			rose_disconnect(s, ENETUNREACH, ROSE_OUT_OF_ORDER, 0);
-			rose->neighbour->use--;
+			if (rose->neighbour->use > 0 ) 
+				rose->neighbour->use--;
+			else
+				printk(KERN_ERR "ROSE: rose_kill_by_neigh() - neighbour->use-- could be < 0\n");
 			rose->neighbour = NULL;
 		}
 	}
-- 
1.5.5


             reply	other threads:[~2008-09-28 19:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-28 19:56 Bernard Pidoux [this message]
2008-09-30 14:32 ` [PATCH] negative dev use in /proc/net/rose_neigh David Miller
2008-09-30 21:44   ` Bernard Pidoux
2008-10-13  7:30     ` David Miller
2008-10-21 14:14       ` pidoux

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=200809282156.39466.bpidoux@free.fr \
    --to=bpidoux@free.fr \
    --cc=davem@davemloft.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 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.