diff mbox

[3.8.y.z,extended,stable] Patch "net: unix: allow bind to fail on mutex lock" has been added to staging queue

Message ID 1389822583-3827-1-git-send-email-kamal@canonical.com
State New
Headers show

Commit Message

Kamal Mostafa Jan. 15, 2014, 9:49 p.m. UTC
This is a note to let you know that I have just added a patch titled

    net: unix: allow bind to fail on mutex lock

to the linux-3.8.y-queue branch of the 3.8.y.z extended stable tree 
which can be found at:

 http://kernel.ubuntu.com/git?p=ubuntu/linux.git;a=shortlog;h=refs/heads/linux-3.8.y-queue

This patch is scheduled to be released in version 3.8.13.16.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.8.y.z tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

From 5d9778c6386c8ccb506582a2b110c2798aac7ce9 Mon Sep 17 00:00:00 2001
From: Sasha Levin <sasha.levin@oracle.com>
Date: Fri, 13 Dec 2013 10:54:22 -0500
Subject: net: unix: allow bind to fail on mutex lock

[ Upstream commit 37ab4fa7844a044dc21fde45e2a0fc2f3c3b6490 ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 net/unix/af_unix.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

--
1.8.3.2
diff mbox

Patch

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 499efb7..fdf0900 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -719,7 +719,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)
@@ -878,7 +880,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)