On Mon, Feb 03, 2025 at 03:44:38PM +0100, Geert Uytterhoeven wrote: > Hi Kees, > > On Mon, 27 Jan 2025 at 20:11, Kees Cook <kees@xxxxxxxxxx> wrote: > > The stack initialization selftests were checking scalars, strings, > > and structs, but not unions. Add union tests (which are mostly identical > > setup to structs). This catches the recent union initialization behavioral > > changes seen in GCC 15. Before GCC 15, this new test passes: > > > > ok 18 test_small_start_old_zero > > > > With GCC 15, it fails: > > > > not ok 18 test_small_start_old_zero > > > > Specifically, a union with a larger member where a smaller member is > > initialized with the older "= { 0 }" syntax: > > > > union test_small_start { > > char one:1; > > char two; > > short three; > > unsigned long four; > > struct big_struct { > > unsigned long array[8]; > > } big; > > }; > > > > This is a regression in compiler behavior that Linux has depended on. > > GCC does not seem likely to fix it, instead suggesting that affected > > projects start using -fzero-init-padding-bits=unions: > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118403 > > > > Signed-off-by: Kees Cook <kees@xxxxxxxxxx> > > I ran stackinit_kunit from v6.14-rc1 on m68k under ARAnyM. > All small_start tests failed: > > KTAP version 1 > 1..1 > KTAP version 1 > # Subtest: stackinit > # module: stackinit_kunit > 1..108 > ok 1 test_u8_zero > ok 2 test_u16_zero > ok 3 test_u32_zero > ok 4 test_u64_zero > ok 5 test_char_array_zero > ok 6 test_small_hole_zero > ok 7 test_big_hole_zero > ok 8 test_trailing_hole_zero > ok 9 test_packed_zero > ok 10 test_small_hole_old_zero > ok 11 test_big_hole_old_zero > ok 12 test_trailing_hole_old_zero > ok 13 test_packed_old_zero > ok 14 test_same_sizes_zero > # test_small_start_zero: ASSERTION FAILED at lib/stackinit_kunit.c:428 > Expected stackinit_range_contains(fill_start, fill_size, > target_start, target_size) to be true, but is false > > stackframe was not the same between calls!? (fill 32 wide, target offset by -12) > [...] > m68k-linux-gnu-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0, GNU ld (GNU Binutils for Ubuntu) 2.42 Hm, I must have some kind of misunderstanding of m68k's stack layout (but only exposed for unions O_o). I will try to get this running in an emulator to investigate. -Kees -- Kees Cook