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]
Message-ID: <CA+H6UkV+gorXdOWBL=RUuh_+gGoMRS1zThLzQRfFUCRB3=qpxg@mail.gmail.com>
Date:   Tue, 20 Mar 2018 15:50:14 +0000
From:   Justin Skists <j.skists@...il.com>
To:     NeilBrown <neilb@...e.com>
Cc:     devel@...verdev.osuosl.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        James Simmons <jsimmons@...radead.org>,
        Patrick Farrell <paf@...y.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] staging: lustre: Fix unneeded byte-ordering cast

On 20 March 2018 at 01:06, NeilBrown <neilb@...e.com> wrote:
> On Sat, Mar 17 2018, Justin Skists wrote:
>
>> Fix sparse warning:
>>
>>   CHECK   drivers/staging//lustre/lnet/lnet/acceptor.c
>> drivers/staging//lustre/lnet/lnet/acceptor.c:243:30: warning: cast to
>> restricted __le32
>>
>> LNET_PROTO_TCP_MAGIC, as a define, is already CPU byte-ordered when
>> compared to 'magic', so no need for a cast.
>>
>> Signed-off-by: Justin Skists <j.skists@...il.com>
>> ---
>>  drivers/staging/lustre/lnet/lnet/acceptor.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
>> index fb478e20e204..13e981781b9a 100644
>> --- a/drivers/staging/lustre/lnet/lnet/acceptor.c
>> +++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
>> @@ -240,7 +240,7 @@ lnet_accept(struct socket *sock, __u32 magic)
>>                       return -EPROTO;
>>               }
>>
>> -             if (magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC))
>> +             if (magic == LNET_PROTO_TCP_MAGIC)
>>                       str = "'old' socknal/tcpnal";
>>               else
>>                       str = "unrecognised";
>
> This code is almost completely irrelevant (it just choose which error
> message to use when failing), but we may as well get it right and I
> cannot see why your change is a fix.

I admit that the change is trivial, and, in hindsight, the word fix is
a little "strong".
The rationale was that the if-statement, as it was, probably wouldn't work as
intented on big-endian systems.

I chose this sparse warning to test the waters, as it was an isolated change,
before I thought about proposing a bigger change: There are quite a few
sparse warning in regards to struct lnet_hdr with regards to __u32 vs. __le32
(etc.) restricted castings.

> I suspect a more correct fix would be to use
>   lnet_accept_magic(magic, LNET_PROTO_TCP_MAGIC)
> as the condition of the if().  This is consistent with other code that
> tests magic, and it is consistent with the general understanding that
> "magic" should be in host-byte-order for the peer which sent the
> message.
>
> Could you resubmit with that change?

I agree that your suggestion is a much better fix.

As Greg has already accepted the patch in question into staging-next,
would the correct course of action be for me to submit a new patch with a
"fixes" tag based on staging-next? Or would Greg prefer to drop the
previous one for a fresh v2?

Regards,
Justin.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ