aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasha Levin <sasha.levin@oracle.com>2013-12-13 10:54:22 -0500
committerStefan Bader <stefan.bader@canonical.com>2014-05-20 16:35:06 +0200
commita57cf07273bd2311c0ab0e3a72409bd877366a06 (patch)
treec61bc18e3bd2f7df2481aecc39b91c75c8bfd074
parente554595af87eeb576e6818f467114b7f9761e0a1 (diff)
downloadlinux-2.6.32.y-drm33.z-a57cf07273bd2311c0ab0e3a72409bd877366a06.tar.gz
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: Willy Tarreau <w@1wt.eu> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
-rw-r--r--net/unix/af_unix.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index bb0b0082ee023a..79c1dcec66e944 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -674,7 +674,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)
@@ -806,7 +808,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)