diff mbox

net: unix: allow bind to fail on mutex lock

Message ID 1386950062-19020-1-git-send-email-sasha.levin@oracle.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Sasha Levin Dec. 13, 2013, 3:54 p.m. UTC
This is similar to the set_peek_off patch where calling bind while the
socket is stuck in unix_dgram_recvmsg() will block and cause a hung task
spew after a while.

This is also the last place that did a straightforward mutex_lock(), so
there shouldn't be any more of these patches.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
---
 net/unix/af_unix.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

David Miller Dec. 17, 2013, 8:04 p.m. UTC | #1
From: Sasha Levin <sasha.levin@oracle.com>
Date: Fri, 13 Dec 2013 10:54:22 -0500

> This is similar to the set_peek_off patch where calling bind while the
> socket is stuck in unix_dgram_recvmsg() will block and cause a hung task
> spew after a while.
> 
> This is also the last place that did a straightforward mutex_lock(), so
> there shouldn't be any more of these patches.
> 
> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 7edbcd9..800ca61 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -720,7 +720,9 @@  static int unix_autobind(struct socket *sock)
 	int err;
 	unsigned int retries = 0;
 
-	mutex_lock(&u->readlock);
+	err = mutex_lock_interruptible(&u->readlock);
+	if (err)
+		return err;
 
 	err = 0;
 	if (u->addr)
@@ -879,7 +881,9 @@  static int unix_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
 		goto out;
 	addr_len = err;
 
-	mutex_lock(&u->readlock);
+	err = mutex_lock_interruptible(&u->readlock);
+	if (err)
+		goto out;
 
 	err = -EINVAL;
 	if (u->addr)