Re: [PATCH] crypto: caam - Prevent fortify error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Dec 23, 2022 at 02:29:52PM +0800, Herbert Xu wrote:
> On Thu, Dec 22, 2022 at 05:25:13PM +0100, Uwe Kleine-König wrote:
> > When compiling arm64 allmodconfig  with gcc 10.2.1 I get
> > 
> > 	drivers/crypto/caam/desc_constr.h: In function ‘append_data.constprop’:
> > 	include/linux/fortify-string.h:57:29: error: argument 2 null where non-null expected [-Werror=nonnull]
> > 
> > Fix this by skipping the memcpy if data is NULL and add a BUG_ON instead
> > that triggers on a problematic call that is now prevented to trigger.
> > After data == NULL && len != 0 is known to be false, logically
> > 
> > 	if (len)
> > 		memcpy(...)
> > 
> > could be enough to know that memcpy is not called with dest=NULL, but
> > gcc doesn't seem smart enough for that conclusion. gcc 12 doesn't have a
> > problem with the original code.
> > 
> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@xxxxxxxxxxxxxx>
> > ---
> >  drivers/crypto/caam/desc_constr.h | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> Does this patch fix your problem?
> 
> https://lore.kernel.org/all/Y4mHjKXnF%2F4Pfw5I@xxxxxxxxxxxxxxxxxxx/

Using

	if (data && len)

fixes it (that's the patch that b4 picks for the above message id :-\),

	if (!IS_ENABLED(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG) && len)

makes the problem go away, too. But I wonder if the latter is correct.
Shouldn't the memcpy happen even with that debugging symbol enabled?

> If not please send me your kconfig file.

(It's a plain arm64 allmodconfig)

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]
  Powered by Linux