From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932769Ab3DDH4u (ORCPT ); Thu, 4 Apr 2013 03:56:50 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:23327 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932725Ab3DDH4s (ORCPT ); Thu, 4 Apr 2013 03:56:48 -0400 Message-ID: <515D3235.7080608@huawei.com> Date: Thu, 4 Apr 2013 15:56:37 +0800 From: dingtianhong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 MIME-Version: 1.0 To: "Eric W. Biederman" CC: "David S. Miller" , Sven Joachim , Greg Kroah-Hartman , , , Eric Dumazet , Andy Lutomirski , Karel Srot , , Eric Dumazet Subject: Re: [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages References: <20130402221104.163133110@linuxfoundation.org> <20130402221116.307254752@linuxfoundation.org> <87vc833kpf.fsf@turtle.gmx.de> <87k3ojnosa.fsf@xmission.com> <1365034777.13853.46.camel@edumazet-glaptop> <1365035424.13853.48.camel@edumazet-glaptop> <878v4zjei0.fsf@xmission.com> <87li8zhwkw.fsf_-_@xmission.com> <87d2ubhwiw.fsf_-_@xmission.com> In-Reply-To: <87d2ubhwiw.fsf_-_@xmission.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.135.72.199] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2013/4/4 10:14, Eric W. Biederman wrote: > > 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. > > Reported-by: Karel Srot > Reported-by: Ding Tianhong > Signed-off-by: "Eric W. Biederman" > --- > net/unix/af_unix.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c > index f153a8d..2db702d 100644 > --- a/net/unix/af_unix.c > +++ b/net/unix/af_unix.c > @@ -1993,7 +1993,7 @@ again: > if ((UNIXCB(skb).pid != siocb->scm->pid) || > (UNIXCB(skb).cred != siocb->scm->cred)) > break; > - } else { > + } else if (test_bit(SOCK_PASSCRED, &sock->flags)) { > /* Copy credentials */ > scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); > check_creds = 1; > As your opinion, I think the way is better: if (test_bit(SOCK_PASSCRED, &sock->flags)) { if (check_creds) { /* Never glue messages from different writers */ if ((UNIXCB(skb).pid != siocb->scm->pid) || (UNIXCB(skb).cred != siocb->scm->cred)) break; } else { /* Copy credentials */ scm_set_cred(siocb->scm, UNIXCB(skb).pid, UNIXCB(skb).cred); check_creds = 1; } } Ding