Re: [PATCH] af_unix: Don't set err in unix_stream_read_generic unless there was an error
From: Rainer Weikusat
Date: Fri Feb 12 2016 - 08:32:58 EST
Joseph Salisbury <joseph.salisbury@xxxxxxxxxxxxx> writes:
> On 02/05/2016 05:30 PM, Rainer Weikusat wrote:
>> The present unix_stream_read_generic contains various code sequences of
>> the form
>>
>> err = -EDISASTER;
>> if (<test>)
>> goto out;
[...]
>> Change it such that err is only set if an error condition was detected.
[...]
> I tested your patch, Rainer. I can confirm that it fixes the reported
> bug[0].
This is only a partial fix: The launchpad test case will no longer fail
with EOPNOTSUPP and it will actually receive the credentials because the
message they're attached to was available by the time of the
recvmsg. But if this isn't the case, ie, if the receiver has to wait for
a message, the continue in the do { } while (size) loop will cause the
loop to be terminated without copying the credential information as the
continue will cause the size (of the remaining 'receive area' which is
zero for this case) to be checked before any of the other loop code is
executed again.
I posted a test case for this and a patch addressing that elsewhere in
this thread.