diff options
author | Sasha Levin <sasha.levin@oracle.com> | 2013-12-07 17:26:27 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-01-15 18:28:47 -0500 |
commit | d90d9ff6cac64e701f27291ecef12fdc48606bb6 (patch) | |
tree | bc1c113caa56f26749ee1b226ca24117672c411e /net/unix/af_unix.c | |
parent | 90af0bf9303883865a8626f23b4b0ed60d4d10dc (diff) |
net: unix: allow set_peek_off to fail
[ Upstream commit 12663bfc97c8b3fdb292428105dd92d563164050 ]
unix_dgram_recvmsg() will hold the readlock of the socket until recv
is complete.
In the same time, we may try to setsockopt(SO_PEEK_OFF) which will hang until
unix_dgram_recvmsg() will complete (which can take a while) without allowing
us to break out of it, triggering a hung task spew.
Instead, allow set_peek_off to fail, this way userspace will not hang.
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Acked-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/unix/af_unix.c')
-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 8664ad0d5797..2ee993c7732a 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c | |||
@@ -529,13 +529,17 @@ static int unix_seqpacket_sendmsg(struct kiocb *, struct socket *, | |||
529 | static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *, | 529 | static int unix_seqpacket_recvmsg(struct kiocb *, struct socket *, |
530 | struct msghdr *, size_t, int); | 530 | struct msghdr *, size_t, int); |
531 | 531 | ||
532 | static void unix_set_peek_off(struct sock *sk, int val) | 532 | static int unix_set_peek_off(struct sock *sk, int val) |
533 | { | 533 | { |
534 | struct unix_sock *u = unix_sk(sk); | 534 | struct unix_sock *u = unix_sk(sk); |
535 | 535 | ||
536 | mutex_lock(&u->readlock); | 536 | if (mutex_lock_interruptible(&u->readlock)) |
537 | return -EINTR; | ||
538 | |||
537 | sk->sk_peek_off = val; | 539 | sk->sk_peek_off = val; |
538 | mutex_unlock(&u->readlock); | 540 | mutex_unlock(&u->readlock); |
541 | |||
542 | return 0; | ||
539 | } | 543 | } |
540 | 544 | ||
541 | 545 | ||