Skip to content

Commit 41e1992

Browse files
committed
s390: workaround invalid gcc-11 out of bounds read warning
GCC 11.1.0 and 11.2.0 generate a wrong warning when compiling the kernel e.g. with allmodconfig: arch/s390/kernel/setup.c: In function ‘setup_lowcore_dat_on’: ./include/linux/fortify-string.h:57:33: error: ‘__builtin_memcpy’ reading 128 bytes from a region of size 0 [-Werror=stringop-overread] ... arch/s390/kernel/setup.c:526:9: note: in expansion of macro ‘memcpy’ 526 | memcpy(abs_lc->cregs_save_area, S390_lowcore.cregs_save_area, | ^~~~~~ This could be addressed by using absolute_pointer() with the S390_lowcore macro, but this is not a good idea since this generates worse code for performance critical paths. Therefore simply use a for loop to copy the array in question and get rid of the warning. Reported-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 1ecf7bd commit 41e1992

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

arch/s390/kernel/setup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ static void __init setup_lowcore_dat_on(void)
508508
{
509509
struct lowcore *abs_lc;
510510
unsigned long flags;
511+
int i;
511512

512513
__ctl_clear_bit(0, 28);
513514
S390_lowcore.external_new_psw.mask |= PSW_MASK_DAT;
@@ -523,8 +524,8 @@ static void __init setup_lowcore_dat_on(void)
523524
abs_lc = get_abs_lowcore(&flags);
524525
abs_lc->restart_flags = RESTART_FLAG_CTLREGS;
525526
abs_lc->program_new_psw = S390_lowcore.program_new_psw;
526-
memcpy(abs_lc->cregs_save_area, S390_lowcore.cregs_save_area,
527-
sizeof(abs_lc->cregs_save_area));
527+
for (i = 0; i < 16; i++)
528+
abs_lc->cregs_save_area[i] = S390_lowcore.cregs_save_area[i];
528529
put_abs_lowcore(abs_lc, flags);
529530
}
530531

0 commit comments

Comments
 (0)