# git rev-parse -q --verify 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91^{commit} 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 already have revision, skipping fetch # git checkout -q -f -B kisskb 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 # git clean -qxdf # < git log -1 # commit 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 # Author: Kees Cook # Date: Fri Mar 30 18:52:36 2018 -0700 # # kernel.h: Retain constant expression output for max()/min() # # In the effort to remove all VLAs from the kernel[1], it is desirable to # build with -Wvla. However, this warning is overly pessimistic, in that # it is only happy with stack array sizes that are declared as constant # expressions, and not constant values. One case of this is the # evaluation of the max() macro which, due to its construction, ends up # converting constant expression arguments into a constant value result. # # All attempts to rewrite this macro with __builtin_constant_p() failed # with older compilers (e.g. gcc 4.4)[2]. However, Martin Uecker, # constructed[3] a mind-shattering solution that works everywhere. # Cthulhu fhtagn! # # This patch updates the min()/max() macros to evaluate to a constant # expression when called on constant expression arguments. This removes # several false-positive stack VLA warnings from an x86 allmodconfig build # when -Wvla is added: # # $ diff -u before.txt after.txt | grep ^- # -drivers/input/touchscreen/cyttsp4_core.c:871:2: warning: ISO C90 forbids variable length array ‘ids’ [-Wvla] # -fs/btrfs/tree-checker.c:344:4: warning: ISO C90 forbids variable length array ‘namebuf’ [-Wvla] # -lib/vsprintf.c:747:2: warning: ISO C90 forbids variable length array ‘sym’ [-Wvla] # -net/ipv4/proc.c:403:2: warning: ISO C90 forbids variable length array ‘buff’ [-Wvla] # -net/ipv6/proc.c:198:2: warning: ISO C90 forbids variable length array ‘buff’ [-Wvla] # -net/ipv6/proc.c:218:2: warning: ISO C90 forbids variable length array ‘buff64’ [-Wvla] # # This also updates two cases where different enums were being compared # and explicitly casts them to int (which matches the old side-effect of # the single-evaluation code): one in tpm/tpm_tis_core.h, and one in # drm/drm_color_mgmt.c. # # [1] https://lkml.org/lkml/2018/3/7/621 # [2] https://lkml.org/lkml/2018/3/10/170 # [3] https://lkml.org/lkml/2018/3/20/845 # # Co-Developed-by: Linus Torvalds # Co-Developed-by: Martin Uecker # Signed-off-by: Kees Cook # Acked-by: Ingo Molnar # Acked-by: Miguel Ojeda # Signed-off-by: Linus Torvalds # < /opt/cross/kisskb/gcc-5.2.0-nolibc/powerpc64le-linux/bin/powerpc64le-linux-gcc --version # < git log --format=%s --max-count=1 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 # < make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_allmodconfig+ppc64le_ppc64le CROSS_COMPILE=/opt/cross/kisskb/gcc-5.2.0-nolibc/powerpc64le-linux/bin/powerpc64le-linux- allmodconfig # Added to kconfig CONFIG_CPU_LITTLE_ENDIAN=y # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_SAMPLES=n # yes \n | make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_allmodconfig+ppc64le_ppc64le CROSS_COMPILE=/opt/cross/kisskb/gcc-5.2.0-nolibc/powerpc64le-linux/bin/powerpc64le-linux- oldconfig yes: standard output: Broken pipe yes: write error # make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_allmodconfig+ppc64le_ppc64le CROSS_COMPILE=/opt/cross/kisskb/gcc-5.2.0-nolibc/powerpc64le-linux/bin/powerpc64le-linux- In file included from /kisskb/src/include/linux/io.h:25:0, from /kisskb/src/include/linux/of_address.h:7, from /kisskb/src/drivers/ata/ahci_qoriq.c:18: /kisskb/src/drivers/ata/ahci_qoriq.c: In function 'ahci_qoriq_hardreset': /kisskb/src/arch/powerpc/include/asm/io.h:162:2: warning: 'px_is' may be used uninitialized in this function [-Wmaybe-uninitialized] __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \ ^ /kisskb/src/drivers/ata/ahci_qoriq.c:86:14: note: 'px_is' was declared here u32 px_cmd, px_is, px_val; ^ In file included from /kisskb/src/include/linux/io.h:25:0, from /kisskb/src/include/linux/of_address.h:7, from /kisskb/src/drivers/ata/ahci_qoriq.c:18: /kisskb/src/arch/powerpc/include/asm/io.h:162:2: warning: 'px_cmd' may be used uninitialized in this function [-Wmaybe-uninitialized] __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \ ^ /kisskb/src/drivers/ata/ahci_qoriq.c:86:6: note: 'px_cmd' was declared here u32 px_cmd, px_is, px_val; ^ WARNING: vmlinux.o(.text+0x35f0): Section mismatch in reference from the variable __boot_from_prom to the function .init.text:prom_init() The function __boot_from_prom() references the function __init prom_init(). This is often because __boot_from_prom lacks a __init annotation or the annotation of prom_init is wrong. WARNING: vmlinux.o(.text+0x3844): Section mismatch in reference from the variable start_here_multiplatform to the function .init.text:early_setup() The function start_here_multiplatform() references the function __init early_setup(). This is often because start_here_multiplatform lacks a __init annotation or the annotation of early_setup is wrong. WARNING: vmlinux.o(.text+0x3878): Section mismatch in reference from the variable start_here_common to the function .init.text:start_kernel() The function start_here_common() references the function __init start_kernel(). This is often because start_here_common lacks a __init annotation or the annotation of start_kernel is wrong. WARNING: vmlinux.o(.text+0x7a550): Section mismatch in reference from the function stop_machine_change_mapping() to the function .meminit.text:create_physical_mapping() The function stop_machine_change_mapping() references the function __meminit create_physical_mapping(). This is often because stop_machine_change_mapping lacks a __meminit annotation or the annotation of create_physical_mapping is wrong. WARNING: vmlinux.o(.text+0x7a55c): Section mismatch in reference from the function stop_machine_change_mapping() to the function .meminit.text:create_physical_mapping() The function stop_machine_change_mapping() references the function __meminit create_physical_mapping(). This is often because stop_machine_change_mapping lacks a __meminit annotation or the annotation of create_physical_mapping is wrong. Completed OK # rm -rf /kisskb/build/linus_allmodconfig+ppc64le_ppc64le # Build took: 0:12:55.015115