# 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-4.6.3-nolibc/sh4-linux/bin/sh4-linux-gcc --version # < git log --format=%s --max-count=1 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 # < make -s -j 48 ARCH=sh O=/kisskb/build/linus_dreamcast_defconfig_sh4 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/sh4-linux/bin/sh4-linux- dreamcast_defconfig # make -s -j 48 ARCH=sh O=/kisskb/build/linus_dreamcast_defconfig_sh4 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/sh4-linux/bin/sh4-linux- Generating include/generated/machtypes.h :1317:2: warning: #warning syscall pkey_mprotect not implemented [-Wcpp] :1320:2: warning: #warning syscall pkey_alloc not implemented [-Wcpp] :1323:2: warning: #warning syscall pkey_free not implemented [-Wcpp] :1326:2: warning: #warning syscall statx not implemented [-Wcpp] /kisskb/src/arch/sh/kernel/cpu/sh4/../sh3/../../entry-common.S: Assembler messages: /kisskb/src/arch/sh/kernel/cpu/sh4/../sh3/../../entry-common.S:389: Warning: overflow in branch to syscall_exit_work; converted into longer instruction sequence /kisskb/src/arch/sh/kernel/cpu/sh4/../sh3/../../entry-common.S:392: Warning: overflow in branch to syscall_exit_work; converted into longer instruction sequence /kisskb/src/arch/sh/kernel/cpu/clock-cpg.c: In function 'cpg_clk_init': /kisskb/src/arch/sh/kernel/cpu/clock-cpg.c:53:3: warning: 'arch_init_clk_ops' is deprecated (declared at /kisskb/src/arch/sh/include/asm/clock.h:8) [-Wdeprecated-declarations] /kisskb/src/arch/sh/kernel/cpu/clock-cpg.c: In function 'arch_clk_init': /kisskb/src/arch/sh/kernel/cpu/clock-cpg.c:77:2: warning: 'cpg_clk_init' is deprecated (declared at /kisskb/src/arch/sh/kernel/cpu/clock-cpg.c:47) [-Wdeprecated-declarations] /kisskb/src/kernel/rcu/srcutree.c: In function 'init_srcu_struct_fields': /kisskb/src/kernel/rcu/srcutree.c:127:33: warning: 'levelspread[]' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/kernel/rcu/srcutree.c:94:6: note: 'levelspread[]' was declared here /kisskb/src/kernel/printk/printk.c: In function 'devkmsg_sysctl_set_loglvl': /kisskb/src/kernel/printk/printk.c:183:16: warning: 'old' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/hugetlb.c: In function 'alloc_pool_huge_page': /kisskb/src/mm/hugetlb.c:1440:5: warning: 'page' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/sh/clk/cpg.c: In function 'r8': /kisskb/src/drivers/sh/clk/cpg.c:41:2: warning: passing argument 1 of 'ioread8' discards 'const' qualifier from pointer target type [enabled by default] /kisskb/src/include/asm-generic/iomap.h:29:21: note: expected 'void *' but argument is of type 'const void *' /kisskb/src/drivers/sh/clk/cpg.c: In function 'r16': /kisskb/src/drivers/sh/clk/cpg.c:46:2: warning: passing argument 1 of 'ioread16' discards 'const' qualifier from pointer target type [enabled by default] /kisskb/src/include/asm-generic/iomap.h:30:21: note: expected 'void *' but argument is of type 'const void *' /kisskb/src/drivers/sh/clk/cpg.c: In function 'r32': /kisskb/src/drivers/sh/clk/cpg.c:51:2: warning: passing argument 1 of 'ioread32' discards 'const' qualifier from pointer target type [enabled by default] /kisskb/src/include/asm-generic/iomap.h:32:21: note: expected 'void *' but argument is of type 'const void *' Kernel: arch/sh/boot/zImage is ready Completed OK # rm -rf /kisskb/build/linus_dreamcast_defconfig_sh4 # Build took: 0:00:29.158657