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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Jun 2022 21:05:36 +0200
From:   Greg KH <gregkh@...uxfoundation.org>
To:     Kees Cook <keescook@...omium.org>
Cc:     Coccinelle <cocci@...teme.lip6.fr>,
        linux-hardening@...r.kernel.org,
        Julia Lawall <Julia.Lawall@...ia.fr>
Subject: Re: replacing memcpy() calls with direct assignment

On Tue, Jun 21, 2022 at 11:37:10AM -0700, Kees Cook wrote:
> Hello Coccinelle gurus! :)
> 
> I recently spent way too long looking at a weird bug in Clang that I
> eventually worked around by just replacing a memcpy() with a direct
> assignment. It really was very mechanical, and seems like it might be a
> common code pattern in the kernel. Swapping these would make the code
> much more readable, I think. Here's the example:
> 
> 
> https://lore.kernel.org/linux-hardening/20220616052312.292861-1-keescook@chromium.org/
> 
> -		memcpy(&host_image->image_section_info[i],
> -		       &fw_image->fw_section_info[i],
> -		       sizeof(struct fw_section_info_st));
> +		host_image->image_section_info[i] = fw_image->fw_section_info[i];

Ick, that hids the fact that you are doing a potentially huge memory
copy here.

And would it also prevent the compiler from using our optimized memcpy()
function and replacing it with whatever it wanted to use instead?

What clang bug does this fix such that it warrants us hiding this
information away from the developers?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ