netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: ebiederm@xmission.com (Eric W. Biederman)
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Stephen Hemminger <shemminger@vyatta.com>,
	Ben Greear <greearb@candelatech.com>,
	Patrick McHardy <kaber@trash.net>
Subject: [PATCH 2/7] net-sysfs: Use rtnl_trylock in sysfs methods.
Date: Wed, 13 May 2009 19:57:25 -0700	[thread overview]
Message-ID: <m1skj8qtm2.fsf@fess.ebiederm.org> (raw)
In-Reply-To: <m13ab8s8cr.fsf@fess.ebiederm.org> (Eric W. Biederman's message of "Wed\, 13 May 2009 19\:53\:40 -0700")


The earlier patch to fix the deadlock between a network device going
away and writing to sysfs attributes was incomplete.
- It did not set signal_pending so we would leak ERSTARTSYS to user space.
- It used ERESTARTSYS which only restarts if sigaction configures it to.
- It did not cover store and show for ifalias.

So fix all of these up and use the new helper restart_syscall so we get
the details correct on what it takes.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
 net/core/net-sysfs.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
index 2da59a0..b9641e8 100644
--- a/net/core/net-sysfs.c
+++ b/net/core/net-sysfs.c
@@ -78,7 +78,7 @@ static ssize_t netdev_store(struct device *dev, struct device_attribute *attr,
 		goto err;
 
 	if (!rtnl_trylock())
-		return -ERESTARTSYS;
+		return restart_syscall();
 
 	if (dev_isalive(net)) {
 		if ((ret = (*set)(net, new)) == 0)
@@ -225,7 +225,8 @@ static ssize_t store_ifalias(struct device *dev, struct device_attribute *attr,
 	if (len >  0 && buf[len - 1] == '\n')
 		--count;
 
-	rtnl_lock();
+	if (!rtnl_trylock())
+		return restart_syscall();
 	ret = dev_set_alias(netdev, buf, count);
 	rtnl_unlock();
 
@@ -238,7 +239,8 @@ static ssize_t show_ifalias(struct device *dev,
 	const struct net_device *netdev = to_net_dev(dev);
 	ssize_t ret = 0;
 
-	rtnl_lock();
+	if (!rtnl_trylock())
+		return restart_syscall();
 	if (netdev->ifalias)
 		ret = sprintf(buf, "%s\n", netdev->ifalias);
 	rtnl_unlock();
-- 
1.6.0.6


  parent reply	other threads:[~2009-05-14  2:57 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-14  2:53 [PATCH 0/7] IPv4/IPv6 unregistration deadlock fixes Eric W. Biederman
2009-05-14  2:55 ` [PATCH] syscall: Implement a convinience function restart_syscall Eric W. Biederman
2009-05-14  2:57 ` Eric W. Biederman [this message]
2009-05-14  2:58   ` [PATCH 3/7] net: FIX ipv6_forward sysctl restart Eric W. Biederman
2009-05-14  2:59 ` [PATCH 4/7] net: Fix devinet_sysctl_forward Eric W. Biederman
2009-05-14  3:00 ` [PATCH 5/7] net: Fix bridgeing sysfs handling of rtnl_lock Eric W. Biederman
2009-05-14  3:01 ` [PATCH 6/7] net: Fix ipoib rtnl_lock sysfs deadlock Eric W. Biederman
2009-05-14  3:02 ` [PATCH 7/7] net: FIX bonding sysfs rtnl_lock deadlock Eric W. Biederman
2009-05-14  3:40 ` [PATCH 0/7] IPv4/IPv6 unregistration deadlock fixes David Miller
2009-05-14  6:44 ` [PATCH 1/7] syscall: Implement a convinience function restart_syscall Eric W. Biederman
2009-05-19  5:16 ` [PATCH 0/7] IPv4/IPv6 unregistration deadlock fixes David Miller
2009-05-19  8:07   ` Eric W. Biederman

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=m1skj8qtm2.fsf@fess.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=davem@davemloft.net \
    --cc=greearb@candelatech.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=shemminger@vyatta.com \
    /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).