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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150923101109.GA1107@sonymobile.com>
Date:	Wed, 23 Sep 2015 12:11:09 +0200
From:	Lars Svensson <Lars1.Svensson@...ymobile.com>
To:	Larry Finger <Larry.Finger@...inger.net>
CC:	"Jes.Sorensen@...hat.com" <Jes.Sorensen@...hat.com>,
	"gregkh@...uxfoundation.org" <gregkh@...uxfoundation.org>,
	"m.v.b@...box.com" <m.v.b@...box.com>,
	"gdonald@...il.com" <gdonald@...il.com>,
	"joe@...ches.com" <joe@...ches.com>,
	"ruchandani.tina@...il.com" <ruchandani.tina@...il.com>,
	"linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
	"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] staging: rtl8723au: Mark type casts to __le32 as
 intentional

On Tue, Sep 22, 2015 at 11:30:54PM +0200, Larry Finger wrote:
> 
> You may have silenced the Sparse warnings, but the code was not wrong. Your 
> version is also correct; however, you end up with some really ugly casts.
> 
> Here is my analysis of these two, identical sections:
> 
> The output of getcrc32() is an unsigned, 4-byte quantity that has the endianess 
> of the cpu. Therefore, the le32_to_cpu() conversion is suspect for a big-endian 
> machine. Those statements should be be a simple "actual_crc = getcrc32(....).
> 
> The expected crc comes from a byte string that is in little-endian order. For 
> that reason, it needs to be converted on big-endian machines, which is exactly 
> what get_unaligned_le32() does. Thus, the second statement in each block becomes 
> "expected_crc = get_unaligned_le32(....)".
> 
> Both the original code and your patch byte swap both quantities, thus they get 
> the correct result. at least if all you are doing is to compare the two results.

I agree, it seems obvious when You spell it out like this. I was more
focused on producing an identical result while removing the sparse warnings. Your
suggestion is much nicer, I will change the patch accordingly.

> 
> The above compiles with no Sparse warnings, and I think it would work on both LE 
> and BE architectures; however, it has only been compile tested.

I have no big endian machine to try it on, but it seems reasonable to assume
that at least the compare will work. The printk in case of a mismatch im not
sure about, though. Assuming the analysis is correct, I think the printed values
would be wrong on a BE machine before this change?

Thanks,
//Lars
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ