lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202502040737.93314491DA@keescook>
Date: Tue, 4 Feb 2025 07:42:06 -0800
From: Kees Cook <kees@...nel.org>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
Cc: Masahiro Yamada <masahiroy@...nel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Jakub Jelinek <jakub@...hat.com>,
	Nathan Chancellor <nathan@...nel.org>,
	Nicolas Schier <nicolas@...sle.eu>,
	Nick Desaulniers <ndesaulniers@...gle.com>,
	Bill Wendling <morbo@...gle.com>,
	Justin Stitt <justinstitt@...gle.com>, linux-kernel@...r.kernel.org,
	linux-kbuild@...r.kernel.org, llvm@...ts.linux.dev,
	linux-hardening@...r.kernel.org
Subject: Re: [PATCH v2 2/3] stackinit: Add union initialization to selftests

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@...nel.org> 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@...nel.org>
> 
> 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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ