# git rev-parse -q --verify b86f6789c355a86ff6c3a8d5ab24774fd66a5a51^{commit} b86f6789c355a86ff6c3a8d5ab24774fd66a5a51 already have revision, skipping fetch # git checkout -q -f -B kisskb b86f6789c355a86ff6c3a8d5ab24774fd66a5a51 # git clean -qxdf # < git log -1 # commit b86f6789c355a86ff6c3a8d5ab24774fd66a5a51 # Author: Michael Ellerman # Date: Mon Mar 16 23:44:21 2020 +1100 # # powerpc/64: Prevent stack protection in early boot # # The previous commit reduced the amount of code that is run before we # setup a paca. However there are still a few remaining functions that # run with no paca, or worse, with an arbitrary value in r13 that will # be used as a paca pointer. # # In particular the stack protector canary is stored in the paca, so if # stack protector is activated for any of these functions we will read # the stack canary from wherever r13 points. If r13 happens to point # outside of memory we will get a machine check / checkstop. # # For example if we modify initialise_paca() to trigger stack # protection, and then boot in the mambo simulator with r13 poisoned in # skiboot before calling the kernel: # # DEBUG: 19952232: (19952232): INSTRUCTION: PC=0xC0000000191FC1E8: [0x3C4C006D]: addis r2,r12,0x6D [fetch] # DEBUG: 19952236: (19952236): INSTRUCTION: PC=0xC00000001807EAD8: [0x7D8802A6]: mflr r12 [fetch] # FATAL ERROR: 19952276: (19952276): Check Stop for 0:0: Machine Check with ME bit of MSR off # DEBUG: 19952276: (19952276): INSTRUCTION: PC=0xC0000000191FCA7C: [0xE90D0CF8]: ld r8,0xCF8(r13) [Instruction Failed] # INFO: 19952276: (19952277): ** Execution stopped: Mambo Error, Machine Check Stop, ** # systemsim % bt # pc: 0xC0000000191FCA7C initialise_paca+0x54 # lr: 0xC0000000191FC22C early_setup+0x44 # stack:0x00000000198CBED0 0x0 +0x0 # stack:0x00000000198CBF00 0xC0000000191FC22C early_setup+0x44 # stack:0x00000000198CBF90 0x1801C968 +0x1801C968 # # So annotate the relevant functions to ensure stack protection is never # enabled for them. # # Fixes: 06ec27aea9fc ("powerpc/64: add stack protector support") # Cc: stable@vger.kernel.org # v4.20+ # Signed-off-by: Michael Ellerman # Link: https://lore.kernel.org/r/20200316124421.99211-2-mpe@ellerman.id.au # < /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-gcc --version # < /opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux-ld --version # < git log --format=%s --max-count=1 b86f6789c355a86ff6c3a8d5ab24774fd66a5a51 # < make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- randconfig KCONFIG_SEED=0xA7461328 # Added to kconfig CONFIG_STANDALONE=y # Added to kconfig CONFIG_BUILD_DOCSRC=n # Added to kconfig CONFIG_MODULE_SIG=n # Added to kconfig CONFIG_CPU_BIG_ENDIAN=y # Added to kconfig CONFIG_PPC64=y # Added to kconfig CONFIG_PPC_DISABLE_WERROR=y # Added to kconfig CONFIG_SECTION_MISMATCH_WARN_ONLY=y # Added to kconfig CONFIG_PREVENT_FIRMWARE_BUILD=y # Added to kconfig CONFIG_CC_STACKPROTECTOR_STRONG=n # Added to kconfig CONFIG_GCC_PLUGINS=n # Added to kconfig CONFIG_LD_HEAD_STUB_CATCH=y # Added to kconfig CONFIG_TRIM_UNUSED_KSYMS=n # Added to kconfig CONFIG_UBSAN=n # < make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- help # make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- olddefconfig .config:4301:warning: override: reassigning to symbol PREVENT_FIRMWARE_BUILD .config:4304:warning: override: reassigning to symbol LD_HEAD_STUB_CATCH # make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- /kisskb/src/arch/powerpc/kexec/elf_64.c: In function 'elf64_load': /kisskb/src/arch/powerpc/kexec/elf_64.c:119:2: warning: 'fdt' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/arch/powerpc/platforms/cell/spufs/sched.c:1061:12: warning: 'show_spu_loadavg' defined but not used [-Wunused-function] /kisskb/src/ipc/shm.c: In function 'ksys_shmdt': /kisskb/src/ipc/shm.c:1712:59: warning: 'file' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/security/smack/smack_lsm.c: In function 'smack_socket_connect': /kisskb/src/security/smack/smack_lsm.c:2838:24: warning: unused variable 'sip' [-Wunused-variable] /kisskb/src/kernel/printk/printk.c: In function 'devkmsg_sysctl_set_loglvl': /kisskb/src/kernel/printk/printk.c:204:16: warning: 'old' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/arch/powerpc/kernel/eeh.c:1773:12: warning: 'proc_eeh_show' defined but not used [-Wunused-function] /kisskb/src/fs/splice.c: In function '__do_compat_sys_vmsplice': /kisskb/src/fs/splice.c:1416:8: warning: 'type' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/fs/splice.c: In function '__do_sys_vmsplice': /kisskb/src/fs/splice.c:1390:8: warning: 'type' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/video/backlight/adp8860_bl.c: In function 'adp8860_bl_ambient_light_level_show': /kisskb/src/drivers/video/backlight/adp8860_bl.c:578:10: warning: 'ret_val' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/mm/ksm.c: In function 'stable_node_dup': /kisskb/src/mm/ksm.c:1391:15: warning: 'found_rmap_hlist_len' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/core/gen_stats.c: In function '__gnet_stats_copy_basic': /kisskb/src/net/core/gen_stats.c:156:19: warning: 'seq' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/mpi/mpicoder.c: In function 'mpi_read_raw_from_sgl': /kisskb/src/lib/mpi/mpicoder.c:352:8: warning: 'buff' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/rhashtable.c: In function 'rhashtable_rehash_one': /kisskb/src/include/linux/rhashtable.h:110:10: warning: 'next' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/lib/rhashtable.c:222:28: note: 'next' was declared here /kisskb/src/net/core/dev.c: In function 'validate_xmit_skb_list': /kisskb/src/net/core/dev.c:3597:15: warning: 'tail' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/netfilter/ipvs/ip_vs_app.c: In function 'register_ip_vs_app': /kisskb/src/net/netfilter/ipvs/ip_vs_app.c:223:2: warning: 'a' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/mtd/ubi/eba.c: In function 'try_write_vid_and_data': /kisskb/src/drivers/mtd/ubi/eba.c:988:7: warning: 'opnum' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/sctp/output.c: In function 'sctp_packet_config': /kisskb/src/include/linux/compiler.h:199:2: warning: 'sk' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/sctp/output.c:79:15: note: 'sk' was declared here /kisskb/src/drivers/i2c/busses/i2c-piix4.c: In function 'piix4_add_adapters_sb800': /kisskb/src/drivers/i2c/busses/i2c-piix4.c:875:6: warning: 'retval' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/drivers/bcma/sprom.c: In function 'bcma_sprom_get': /kisskb/src/drivers/bcma/sprom.c:644:8: warning: 'sprom' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/mac80211/tx.c: In function 'ieee80211_build_hdr': /kisskb/src/net/mac80211/tx.c:2551:27: warning: 'chanctx_conf' may be used uninitialized in this function [-Wuninitialized] /kisskb/src/net/mac80211/mlme.c: In function 'ieee80211_handle_pwr_constr.isra.23': /kisskb/src/net/mac80211/mlme.c:1576:3: warning: 'pwr_level_cisco' may be used uninitialized in this function [-Wuninitialized] WARNING: vmlinux.o(.text.unlikely+0x104): Section mismatch in reference from the function .setup_secure_guest() to the function .init.text:.prom_printf() The function .setup_secure_guest() references the function __init .prom_printf(). This is often because .setup_secure_guest lacks a __init annotation or the annotation of .prom_printf is wrong. WARNING: vmlinux.o(.text.unlikely+0x150): Section mismatch in reference from the function .setup_secure_guest() to the function .init.text:.prom_printf() The function .setup_secure_guest() references the function __init .prom_printf(). This is often because .setup_secure_guest lacks a __init annotation or the annotation of .prom_printf is wrong. WARNING: vmlinux.o(.text.unlikely+0x170): Section mismatch in reference from the function .setup_secure_guest() to the function .init.text:.call_prom() The function .setup_secure_guest() references the function __init .call_prom(). This is often because .setup_secure_guest lacks a __init annotation or the annotation of .call_prom is wrong. WARNING: vmlinux.o(.text.unlikely+0x1a0): Section mismatch in reference from the function .setup_secure_guest() to the function .init.text:.prom_getprop() The function .setup_secure_guest() references the function __init .prom_getprop(). This is often because .setup_secure_guest lacks a __init annotation or the annotation of .prom_getprop is wrong. WARNING: vmlinux.o(.text.unlikely+0x1b8): Section mismatch in reference from the function .setup_secure_guest() to the function .init.text:.prom_panic() The function .setup_secure_guest() references the function __init .prom_panic(). This is often because .setup_secure_guest lacks a __init annotation or the annotation of .prom_panic is wrong. WARNING: vmlinux.o(.text.unlikely+0x2028): Section mismatch in reference from the function .xive_spapr_disabled() to the function .init.text:.of_get_flat_dt_root() The function .xive_spapr_disabled() references the function __init .of_get_flat_dt_root(). This is often because .xive_spapr_disabled lacks a __init annotation or the annotation of .of_get_flat_dt_root is wrong. WARNING: vmlinux.o(.text.unlikely+0x2038): Section mismatch in reference from the function .xive_spapr_disabled() to the function .init.text:.of_get_flat_dt_subnode_by_name() The function .xive_spapr_disabled() references the function __init .of_get_flat_dt_subnode_by_name(). This is often because .xive_spapr_disabled lacks a __init annotation or the annotation of .of_get_flat_dt_subnode_by_name is wrong. WARNING: vmlinux.o(.text.unlikely+0x2054): Section mismatch in reference from the function .xive_spapr_disabled() to the function .init.text:.of_get_flat_dt_prop() The function .xive_spapr_disabled() references the function __init .of_get_flat_dt_prop(). This is often because .xive_spapr_disabled lacks a __init annotation or the annotation of .of_get_flat_dt_prop is wrong. arch/powerpc/platforms/pseries/lpar.o:(.toc+0x0): undefined reference to `mmu_pid_bits' make[1]: *** [/kisskb/src/Makefile:1077: vmlinux] Error 1 make: *** [Makefile:179: sub-make] Error 2 Command 'make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 CROSS_COMPILE=/opt/cross/kisskb/gcc-4.6.3-nolibc/powerpc-linux/bin/powerpc-linux- ' returned non-zero exit status 2 # rm -rf /kisskb/build/powerpc-next-rand_powerpc-randconfig_powerpc-gcc4.6 # Build took: 0:01:56.629424