lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 29 Nov 2007 23:20:48 +1100
From:	Herbert Xu <herbert@...dor.apana.org.au>
To:	Florian Zumbiehl <florz@...rz.de>
Cc:	netdev@...r.kernel.org
Subject: Re: [PATCH][UNIX] EOF on non-blocking SOCK_SEQPACKET

On Tue, Nov 27, 2007 at 09:33:23AM +0000, Florian Zumbiehl wrote:
> 
> I am not absolutely sure whether this actually is a bug (as in: I've got
> no clue what the standards say or what other implementations do), but at
> least I was pretty surprised when I noticed that a recv() on a
> non-blocking unix domain socket of type SOCK_SEQPACKET (which is connection
> oriented, after all) where the remote end has closed the connection
> returned -1 (EAGAIN) rather than 0 to indicate end of file.

I agree with your expectation.  In fact, that's what POSIX says too.
Since the risk of this breaking an existing application seems to be
minimal, I've applied your patch to net-2.6.

However, I had to reformat it so that it fits with the Linux coding
style.  Please take this into account for future patches.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index e835da8..060bba4 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1637,8 +1637,15 @@ static int unix_dgram_recvmsg(struct kiocb *iocb, struct socket *sock,
 	mutex_lock(&u->readlock);
 
 	skb = skb_recv_datagram(sk, flags, noblock, &err);
-	if (!skb)
+	if (!skb) {
+		unix_state_lock(sk);
+		/* Signal EOF on disconnected non-blocking SEQPACKET socket. */
+		if (sk->sk_type == SOCK_SEQPACKET && err == -EAGAIN &&
+		    (sk->sk_shutdown & RCV_SHUTDOWN))
+			err = 0;
+		unix_state_unlock(sk);
 		goto out_unlock;
+	}
 
 	wake_up_interruptible_sync(&u->peer_wait);
 
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ