Re: [PATCH v2] crypto/caam: Avoid GCC constprop bug warning
From: Eric Biggers
Date: Thu Dec 01 2022 - 22:18:24 EST
On Thu, Dec 01, 2022 at 05:04:14PM -0800, Kees Cook wrote:
> GCC 12 appears to perform constant propagation incompletely(?) and can
> no longer notice that "len" is always 0 when "data" is NULL. Expand the
> check to avoid warnings about memcpy() having a NULL argument:
Is there a gcc option to turn off the "memcpy with NULL and len=0 is undefined
behavior" thing? It's basically a bug in the C standard.
Note that the kernel already uses options that make other types of undefined
behavior defined: -fno-strict-overflow, -fno-strict-aliasing, and
-fno-delete-null-pointer-checks.
- Eric