diff mbox

[SRU,Precise,linux-lts-t,Trusty,linux-lts-u,linux-lts-v,1/1] Revert "af_unix: Revert 'lock_interruptible' in stream receive code"

Message ID a7452bffcc21cbf509bad27429184a417cb88f93.1457119046.git.joseph.salisbury@canonical.com
State New
Headers show

Commit Message

Joseph Salisbury March 4, 2016, 7:33 p.m. UTC
BugLink: http://bugs.launchpad.net/bugs/1540731

This reverts commit d9ff970b0a5bde33ccdb6279001f9dcd95b68b95.
---
 net/unix/af_unix.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

Comments

Brad Figg March 14, 2016, 3:31 p.m. UTC | #1
Precise picked this up via stable upstream release. I applied it to the
appropriate master-next branch for Trusty, lts-utopic and Vivid.
diff mbox

Patch

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 31b88dc..9ce79ed 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -2088,7 +2088,14 @@  static int unix_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
 		memset(&tmp_scm, 0, sizeof(tmp_scm));
 	}
 
-	mutex_lock(&u->readlock);
+	err = mutex_lock_interruptible(&u->readlock);
+	if (unlikely(err)) {
+		/* recvmsg() in non blocking mode is supposed to return -EAGAIN
+		 * sk_rcvtimeo is not honored by mutex_lock_interruptible()
+		 */
+		err = noblock ? -EAGAIN : -ERESTARTSYS;
+		goto out;
+	}
 
 	if (flags & MSG_PEEK)
 		skip = sk_peek_offset(sk, flags);
@@ -2129,12 +2136,12 @@  again:
 
 			timeo = unix_stream_data_wait(sk, timeo, last);
 
-			if (signal_pending(current)) {
+			if (signal_pending(current)
+			    ||  mutex_lock_interruptible(&u->readlock)) {
 				err = sock_intr_errno(timeo);
 				goto out;
 			}
 
-			mutex_lock(&u->readlock);
 			continue;
  unlock:
 			unix_state_unlock(sk);