netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@linux-foundation.org>
To: "Alon Bar-Lev" <alon.barlev@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: iproute2 (addr flush) infinite loop when unprivileged users
Date: Fri, 25 Jan 2008 16:12:59 -0800	[thread overview]
Message-ID: <20080125161259.0356c990@deepthought> (raw)
In-Reply-To: <9e0cf0bf0801251500u388b9a5dxda92d6d1e3d86233@mail.gmail.com>

On Sat, 26 Jan 2008 01:00:34 +0200
"Alon Bar-Lev" <alon.barlev@gmail.com> wrote:

> Hello,
> 
> When executing the following command using unprivileged users there is
> an infinite loop...
> /sbin/ip route flush dev eth1
> 
> Execution with -s produces:
> *** Round 28153, deleting 2 entries ***
> 
> *** Round 28154, deleting 2 entries ***
> 
> *** Round 28155, deleting 2 entries ***
> 
> *** Round 28156, deleting 2 entries ***
> 
> *** Round 28157, deleting 2 entries ***
> 
> *** Round 28158, deleting 2 entries ***
> 
> *** Round 28159, deleting 2 entries ***
> 
> I do not fully understand the sequence, but it may be kernel fault, as
> it should have returned EPERM for this request stopping the netlink
> request.
> 
> Anyway... A simple solution is to store the filter.flushed and fail if
> it keeps its value during loop iteration at
> ip/ipaddress.c::ipaddr_list_or_flush(), but this is only a
> workaround...
> 
> Please CC as I am not in netdev list.
> Thanks!
> Alon.

The issue is that iproute is just blindly sending the deletes and
not asking for acknowledgment status. Here is a trivial patch to iproute
to fix that, but the problem is that it means it will slow down bulk removal.

Maybe it should just check the first, or last delete to see if there are
errors?

diff --git a/ip/iproute.c b/ip/iproute.c
index 7a885b0..b2ae879 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -112,11 +112,27 @@ static struct
 
 static int flush_update(void)
 {
+	unsigned long i;
+	struct nlmsghdr *fn;
+
+#ifdef nochecking
 	if (rtnl_send(&rth, filter.flushb, filter.flushp) < 0) {
 		perror("Failed to send flush request\n");
 		return -1;
 	}
+#else
+	for (i = 0; i < filter.flushp; ) {
+		fn = (struct nlmsghdr *)(filter.flushb + NLMSG_ALIGN(i));
+		fn->nlmsg_flags |= NLM_F_ACK;
+		
+		if (rtnl_talk(&rth, fn, 0, 0, NULL, NULL, NULL) < 0)
+			return -1;
+
+		i = (((char*)fn) + fn->nlmsg_len) - filter.flushb;
+	}
+#endif
 	filter.flushp = 0;
+
 	return 0;
 }
 




-- 
Stephen Hemminger <stephen.hemminger@vyatta.com>

  parent reply	other threads:[~2008-01-26  0:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-25 23:00 iproute2 (addr flush) infinite loop when unprivileged users Alon Bar-Lev
2008-01-25 23:02 ` Stephen Hemminger
2008-01-25 23:06   ` Alon Bar-Lev
2008-01-26  0:12 ` Stephen Hemminger [this message]
2008-01-26  0:22   ` Alon Bar-Lev
2008-01-26  8:58     ` Alon Bar-Lev
2008-01-26 19:11       ` Stephen Hemminger
2008-01-26 19:14       ` Stephen Hemminger
2008-01-26 19:19       ` Stephen Hemminger
2008-01-26 21:48         ` Alon Bar-Lev

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=20080125161259.0356c990@deepthought \
    --to=shemminger@linux-foundation.org \
    --cc=alon.barlev@gmail.com \
    --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).