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  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 7 Jan 2021 09:22:00 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Arnd Bergmann <arnd@...nel.org>
Cc:     Arnd Bergmann <arnd@...db.de>,
        Nathan Chancellor <natechancellor@...il.com>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Marco Elver <elver@...gle.com>,
        George Popescu <georgepope@...roid.com>,
        Stephen Rothwell <sfr@...b.auug.org.au>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        clang-built-linux <clang-built-linux@...glegroups.com>
Subject: Re: [PATCH] ubsan: disable unsigned-integer-overflow sanitizer with
 clang

On Thu, Jan 07, 2021 at 05:09:59PM +0100, Arnd Bergmann wrote:
> On Wed, Jan 6, 2021 at 11:12 PM Arnd Bergmann <arnd@...nel.org> wrote:
> >
> > On Wed, Jan 6, 2021 at 10:57 PM Kees Cook <keescook@...omium.org> wrote:
> > > On Wed, Dec 30, 2020 at 04:47:35PM +0100, Arnd Bergmann wrote:
> > > > diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan
> > > > index 8b635fd75fe4..e23873282ba7 100644
> > > > --- a/lib/Kconfig.ubsan
> > > > +++ b/lib/Kconfig.ubsan
> > > > @@ -122,6 +122,8 @@ config UBSAN_SIGNED_OVERFLOW
> > > >
> > > >  config UBSAN_UNSIGNED_OVERFLOW
> > > >       bool "Perform checking for unsigned arithmetic overflow"
> > > > +     # clang hugely expands stack usage with -fsanitize=object-size
> > > > +     depends on !CC_IS_CLANG
> > > >       depends on $(cc-option,-fsanitize=unsigned-integer-overflow)
> > >
> > > Because of Clang implementation issues (see commit c637693b20da), this is
> > > already "default n" (and not supported under GCC at all). IIUC, setting
> > > this to "depends on !COMPILE_TEST" won't work for randconfigs, yes?
> >
> > Ah, I had not realized this is clang specific. Adding the !COMPILE_TEST
> > dependency would hide it for me, which may be good enough for me.
> >
> > > Is there some better way to mark this as "known to have issues, please
> > > don't include in randconfig?"
> > >
> > > I'd like to keep it around so people can continue to work out the
> > > problems with it, but not have unexpecting folks trip over it. ;)
> >
> > I've reverted that patch locally now and default-enabled for randconfigs.
> > Now that I have an otherwise clean build, this should provide me
> > with a full set of files that produce the warning. If the number is
> > small enough, I could try opening individual github issues.
> 
> A day's worth of randconfig builds with clang-11 or clang-12 shows these
> instances that exceeded the warning limit:
> 
> crypto/blake2b_generic.c:98:13: error: stack frame size of 9636 bytes
> in function 'blake2b_compress' [-Werror,-Wframe-larger-than=]
> crypto/sha512_generic.c:151:13: error: stack frame size of 1292 bytes
> in function 'sha512_generic_block_fn' [-Werror,-Wframe-larger-than=]
> lib/crypto/curve25519-fiat32.c:312:22: error: stack frame size of 2180
> bytes in function 'fe_mul_impl' [-Werror,-Wframe-larger-than=]
> lib/crypto/curve25519-fiat32.c:444:22: error: stack frame size of 1588
> bytes in function 'fe_sqr_impl' [-Werror,-Wframe-larger-than=]
> fs/btrfs/scrub.c:3028:31: error: stack frame size of 1132 bytes in
> function 'scrub_stripe' [-Werror,-Wframe-larger-than=]
> drivers/net/ethernet/intel/e1000/e1000_main.c:3590:6: warning: stack
> frame size of 1100 bytes in function 'e1000_update_stats'
> [-Wframe-larger-than=]
> drivers/net/ethernet/broadcom/tg3.c:11829:13: warning: stack frame
> size of 1188 bytes in function 'tg3_get_estats' [-Wframe-larger-than=]
> drivers/net/ethernet/intel/igb/igb_main.c:6551:6: warning: stack frame
> size of 1348 bytes in function 'igb_update_stats'
> [-Wframe-larger-than=]
> drivers/net/ethernet/intel/igc/igc_main.c:3608:6: warning: stack frame
> size of 1124 bytes in function 'igc_update_stats'
> [-Wframe-larger-than=]
> drivers/net/ethernet/qlogic/qed/qed_l2.c:1759:1: warning: stack frame
> size of 1300 bytes in function '__qed_get_vport_port_stats'
> [-Wframe-larger-than=]
> drivers/net/ethernet/intel/ixgbe/ixgbe_main.c:7022:6: warning: stack
> frame size of 1564 bytes in function 'ixgbe_update_stats'
> [-Wframe-larger-than=]
> drivers/net/ethernet/intel/ixgb/ixgb_main.c:1590:1: warning: stack
> frame size of 1140 bytes in function 'ixgb_update_stats'
> [-Wframe-larger-than=]
> drivers/net/ethernet/mellanox/mlx5/core/ipoib/ipoib.c:145:6: warning:
> stack frame size of 1068 bytes in function 'mlx5i_get_stats'
> [-Wframe-larger-than=]
> drivers/staging/media/atomisp/pci/atomisp_cmd.c:5600:5: warning: stack
> frame size of 1052 bytes in function 'atomisp_set_fmt'
> [-Wframe-larger-than=]
> 
> All of these *only* happen on 32-bit x86, and can be reproduced in a
> i386_defconfig, with the corresponding drivers (btrfs, sha512, blake2b,
> curve25519, and the ethernet ones) and UBSAN_UNSIGNED_OVERFLOW
> manually enabled. Given that few people still care about i386, maybe
> we could just make the option depend on !CONFIG_X86_32

I'm fine with that -- or maybe any 32-bit architecture, if the problem
is poor stack space optimization on 32-bit archs?

> 
> That config also runs into two more BUILD_BUG_ON() that I had not
> seen in randconfig tests:
> 
> (i386 defconfig plus ubsan)
> ld.lld: error: undefined symbol: __compiletime_assert_207
> >>> referenced by cpu_entry_area.c
> >>>               mm/cpu_entry_area.o:(setup_cpu_entry_area_ptes) in archive arch/x86/built-in.a

That one I don't think I've seen before.

> 
> (x86-64 defconfig plus ubsan)
> ld.lld: error: undefined symbol: __compiletime_assert_362
> >>> referenced by efi_64.c
> >>>               platform/efi/efi_64.o:(efi_sync_low_kernel_mappings) in archive arch/x86/built-in.a

I think this is:
https://github.com/ClangBuiltLinux/linux/issues/256
and that bug needs re-opening? Or maybe there's a new bug I can't find?

-- 
Kees Cook

Powered by blists - more mailing lists