# 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/powerpc-linux/bin/powerpc-linux-gcc --version # < git log --format=%s --max-count=1 3c8ba0d61d04ced9f8d9ff93977995a9e4e96e91 # < make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_ppc6xx_defconfig_powerpc CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- ppc6xx_defconfig # make -s -j 48 ARCH=powerpc O=/kisskb/build/linus_ppc6xx_defconfig_powerpc CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- /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/kernel/cgroup/cgroup-v1.c: In function 'cgroup1_mount': /kisskb/src/kernel/cgroup/cgroup-v1.c:1268:20: warning: 'root' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/sound/ppc/awacs.c: In function 'snd_pmac_awacs_init': /kisskb/src/include/sound/control.h:220:2: warning: 'speaker_vol' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/sound/ppc/awacs.c:886:36: note: 'speaker_vol' was declared here /kisskb/src/drivers/base/regmap/regmap.c: In function 'regmap_raw_read': /kisskb/src/drivers/base/regmap/regmap.c:2497:6: warning: 'ret' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/dma-buf/reservation.c: In function 'reservation_object_add_shared_fence': /kisskb/src/drivers/dma-buf/reservation.c:225:6: warning: 'k' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/base/regmap/regmap.c: In function '_regmap_raw_write': /kisskb/src/drivers/base/regmap/regmap.c:1819:6: warning: 'ret' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/nfsd/nfs4xdr.c: In function 'nfsd4_encode_components_esc': /kisskb/src/fs/nfsd/nfs4xdr.c:2043:9: warning: 'str' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/bridge/br_netlink.c: In function 'br_afspec': /kisskb/src/net/bridge/br_netlink.c:635:7: warning: 'err' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/tty/serial/8250/8250_core.c: In function 'univ8250_release_irq': /kisskb/src/drivers/tty/serial/8250/8250_core.c:251:18: warning: 'i' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/tty/serial/8250/8250_core.c:231:19: note: 'i' was declared here /kisskb/src/net/mac80211/mlme.c: In function 'ieee80211_rx_mgmt_beacon': /kisskb/src/net/mac80211/mlme.c:1352:3: warning: 'pwr_level_cisco' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/mac80211/mlme.c:1309:6: note: 'pwr_level_cisco' was declared here /kisskb/src/drivers/net/tun.c: In function 'tun_get_user': /kisskb/src/drivers/net/tun.c:1820:30: warning: 'copylen' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/net/tun.c:1730:46: warning: 'linear' may be used uninitialized in this function [-Wuninitialized] WARNING: modpost: Found 1 section mismatch(es). To see full details build your kernel with: 'make CONFIG_DEBUG_SECTION_MISMATCH=y' arch/powerpc/boot/mpc832x_rdb.dtb: Warning (interrupts_property): interrupts size is (4), expected multiple of 8 in /qe@e0100000/mdio@3120/ethernet-phy@0 arch/powerpc/boot/mpc832x_rdb.dtb: Warning (interrupts_property): interrupts size is (4), expected multiple of 8 in /qe@e0100000/mdio@3120/ethernet-phy@4 INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa35528) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa24e04) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) INFO: Uncompressed kernel (size 0xa24e04) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xb00000) Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:28 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4831793 Bytes = 4718.55 kB = 4.61 MB Load Address: 00000000 Entry Point: 00000000 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:28 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4855166 Bytes = 4741.37 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b00230 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:28 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4855014 Bytes = 4741.22 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b00230 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:29 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4855136 Bytes = 4741.34 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b00230 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:29 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4856016 Bytes = 4742.20 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b00230 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:29 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4855072 Bytes = 4741.28 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b00230 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:29 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4855085 Bytes = 4741.29 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b00230 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:29 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4856263 Bytes = 4742.44 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b007a0 Image Name: Linux-4.16.0+ Created: Fri Apr 6 10:26:29 2018 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 4856093 Bytes = 4742.28 kB = 4.63 MB Load Address: 00b00000 Entry Point: 00b007a0 Completed OK # rm -rf /kisskb/build/linus_ppc6xx_defconfig_powerpc # Build took: 0:02:52.461016