netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Petr Písař" <ppisar@redhat.com>
To: <netdev@vger.kernel.org>
Cc: "Stephen Hemminger" <stephen@networkplumber.org>,
	"Petr Písař" <ppisar@redhat.com>
Subject: [PATCH] Do not listen if rtnl_send() fails in ip link iplink_have_newlink() test
Date: Wed, 11 Dec 2013 14:01:29 +0100	[thread overview]
Message-ID: <1386766889-19062-1-git-send-email-ppisar@redhat.com> (raw)

If rtnl_send() fails in iplink_have_newlink() test, listening for
response will result in indefinite hang. This can be demonstrated by
"ip link show" while SELinux preventing from sending the RTM_NEWLINK
over netlink.

This patch checks for the return value as is done at all other
rtnl_send() calls.

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 ip/iplink.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/iplink.c b/ip/iplink.c
index 58b6c20..f7d9e17 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -178,8 +178,8 @@ static int iplink_have_newlink(void)
 		req.n.nlmsg_type = RTM_NEWLINK;
 		req.i.ifi_family = AF_UNSPEC;
 
-		rtnl_send(&rth, &req.n, req.n.nlmsg_len);
-		rtnl_listen(&rth, accept_msg, NULL);
+		if (rtnl_send(&rth, &req.n, req.n.nlmsg_len) >= 0)
+			rtnl_listen(&rth, accept_msg, NULL);
 	}
 	return have_rtnl_newlink;
 }
-- 
1.8.3.1

             reply	other threads:[~2013-12-11 13:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 13:01 Petr Písař [this message]
2013-12-11 18:57 ` [PATCH] Do not listen if rtnl_send() fails in ip link iplink_have_newlink() test Stephen Hemminger
2013-12-12  7:18   ` Petr Písař
2013-12-20 16:21     ` Stephen Hemminger
2014-01-02  7:42       ` Petr Pisar
2014-01-03 20:36         ` Stephen Hemminger

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=1386766889-19062-1-git-send-email-ppisar@redhat.com \
    --to=ppisar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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).