From: ebiederm@xmission•com (Eric W. Biederman)
To: dingtianhong <dingtianhong@huawei•com>
Cc: "David S. Miller" <davem@davemloft•net>,
Sven Joachim <svenjoac@gmx•de>,
Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
<linux-kernel@vger•kernel.org>, <stable@vger•kernel.org>,
Eric Dumazet <edumazet@google•com>,
Andy Lutomirski <luto@amacapital•net>,
Karel Srot <ksrot@redhat•com>, <netdev@vger•kernel.org>,
Eric Dumazet <eric.dumazet@gmail•com>
Subject: Re: [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages
Date: Thu, 04 Apr 2013 03:36:56 -0700 [thread overview]
Message-ID: <874nfmeg53.fsf@xmission.com> (raw)
In-Reply-To: <515D3235.7080608@huawei.com> (dingtianhong@huawei.com's message of "Thu, 4 Apr 2013 15:56:37 +0800")
dingtianhong <dingtianhong@huawei•com> writes:
> 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 <ksrot@redhat•com>
>> Reported-by: Ding Tianhong <dingtianhong@huawei•com>
>> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission•com>
>> ---
>> 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;
> }
> }
It is a smidge clearer in intent, but there is no functional
difference. The lines get really long.
Shrug.
Patches are always welcome.
Beyond getting something correct for the right reasons I don't care.
Eric
next prev parent reply other threads:[~2013-04-04 10:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20130402221104.163133110@linuxfoundation.org>
[not found] ` <20130402221116.307254752@linuxfoundation.org>
[not found] ` <87vc833kpf.fsf@turtle.gmx.de>
[not found] ` <87k3ojnosa.fsf@xmission.com>
[not found] ` <1365034777.13853.46.camel@edumazet-glaptop>
[not found] ` <1365035424.13853.48.camel@edumazet-glaptop>
[not found] ` <878v4zjei0.fsf@xmission.com>
2013-04-04 2:13 ` [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" Eric W. Biederman
2013-04-04 2:14 ` [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages Eric W. Biederman
2013-04-04 3:28 ` [PATCH 3/2] scm: Stop passing struct cred Eric W. Biederman
2013-04-05 4:47 ` David Miller
2013-04-04 7:56 ` [PATCH 2/2] af_unix: If we don't care about credentials coallesce all messages dingtianhong
2013-04-04 10:36 ` Eric W. Biederman [this message]
2013-04-05 4:47 ` David Miller
2013-04-04 7:51 ` [PATCH 1/2] Revert "af_unix: dont send SCM_CREDENTIAL when dest socket is NULL" dingtianhong
2013-04-04 10:22 ` Eric W. Biederman
2013-04-05 4:47 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874nfmeg53.fsf@xmission.com \
--to=ebiederm@xmission$(echo .)com \
--cc=davem@davemloft$(echo .)net \
--cc=dingtianhong@huawei$(echo .)com \
--cc=edumazet@google$(echo .)com \
--cc=eric.dumazet@gmail$(echo .)com \
--cc=gregkh@linuxfoundation$(echo .)org \
--cc=ksrot@redhat$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=luto@amacapital$(echo .)net \
--cc=netdev@vger$(echo .)kernel.org \
--cc=stable@vger$(echo .)kernel.org \
--cc=svenjoac@gmx$(echo .)de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox