diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2013-12-13 10:54:22 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-15 15:27:11 -0800 |
commit | c0be5de16bf9b4350802e28c3dd243ca2367c5ef (patch) | |
tree | acb1f05240317769f40b0d55c5889d2aa6838d8c | |
parent | 0248d4b4d5bed909c52877e16db569361648c952 (diff) | |
download | lwn-c0be5de16bf9b4350802e28c3dd243ca2367c5ef.tar.gz lwn-c0be5de16bf9b4350802e28c3dd243ca2367c5ef.zip |
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/unix/af_unix.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 8519968f487f..c0a81a50bd4e 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -712,7 +712,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) @@ -845,7 +847,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) |