History

af_unix: If we don't care about credentials coallesce all messages

It was reported that the following LSB test case failed https://lsbbugs.linuxfoundation.org/attachment.cgi?id=2144 because we were not coallescing unix stream messages when the application was expecting us to. The problem was that the first send was before the socket was accepted and thus sock->sk_socket was NULL in maybe_add_creds, and the second send after the socket was accepted had a non-NULL value for sk->socket and thus we could tell the credentials were not needed so we did not bother. The unnecessary credentials on the first message cause unix_stream_recvmsg to start verifying that all messages had the same credentials before coallescing and then the coallescing failed because the second message had no credentials. Ignoring credentials when we don't care in unix_stream_recvmsg fixes a long standing pessimization which would fail to coallesce messages when reading from a unix stream socket if the senders were different even if we did not care about their credentials. I have tested this and verified that the in the LSB test case mentioned above that the messages do coallesce now, while the were failing to coallesce without this change.

Eric W. Biederman committed 13 years ago

Commit 0e82e7f1 parent 25da0e31 file · +1 −1Browse files

Unified · Split

net/unix/af_unix.c+1−1
@@ -1993,7 +1993,7 @@ again: · 1992 unmodified lines
19931993 if ((UNIXCB(skb).pid != siocb->scm->pid) ||
19941994 (UNIXCB(skb).cred != siocb->scm->cred))
19951995 break;
1996− } else {
1996+ } else if (test_bit(SOCK_PASSCRED, &sock->flags)) {
19971997 /* Copy credentials */
19981998 scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred);
19991999 check_creds = 1;