Build error in crypto/marvell/cesa/cipher.c
From: Linus Torvalds
Date: Wed Jun 28 2023 - 23:14:15 EST
So I don't see anything that has changed, and I suspect the only
change is that my compiler version changed, but my arm64 build fails
right now with FORTIFY_STRING enabled.
On arm64 I now get this warning:
In function 'fortify_memcpy_chk',
inlined from 'mv_cesa_des3_ede_setkey' and
drivers/crypto/marvell/cesa/cipher.c:307:2:
./include/linux/fortify-string.h:583:25: error: call to
'__write_overflow_field' declared with attribute warning: detected
write beyond size of field (1st parameter); maybe use struct_group()?
[-Werror=attribute-warning[
but I haven't been compiling regularly enough to know when this
warning suddenly started showing up.
I enabled the cesa driver on x86-64 (by also letting it build with
COMPILE_TEST), and I do *not* see this warning on x86-64, which makes
me think it's the compiler version that matters here.
On my arm64 setup, I have gcc-13.1.1, while my x86-64 build is still 12.3.1.
But I think the warning is correct. The problem is that the 'ctx'
pointer is wrongly typed, and it's using "struct mv_cesa_des_ctx"
(which has a "key[]" size of DES_KEY_SIZE).
And it *should* use "struct mv_cesa_des3_ctx" which has otherwise the
same layout, but the right key size (DES3_EDE_KEY_SIZE).
Fixing that type fixes the warning.
I'm actually surprised that gcc-12 doesn't seem to warn about this.
Kees? This looks like a rather obvious overflow, which makes me think
I'm missing something.
I get a similar error in 'irdma_clr_wqes()' at
drivers/infiniband/hw/irdma/uk.c:103 (and same thing on line 105). I
don't see what the right solution there is, but it looks like we have
IRDMA_CQP_WQE_SIZE = 8
__le64 elem[IRDMA_CQP_WQE_SIZE];
and it's doing a 4kB memset to that element. The mistake is not as
obvious as in the cesa driver.
Kees, any idea why I'm seeing it now? Is it the new
-fstrict-flex-arrays=3? And if so, why? None of this is about flex
arrays...
Anyway, please forward me fixes so that I can have a working arm64
test build again....
Linus