# git rev-parse -q --verify 478036c4cd1a16e613a2f883d79c03cf187faacb^{commit} 478036c4cd1a16e613a2f883d79c03cf187faacb already have revision, skipping fetch # git checkout -q -f -B kisskb 478036c4cd1a16e613a2f883d79c03cf187faacb # git clean -qxdf # < git log -1 # commit 478036c4cd1a16e613a2f883d79c03cf187faacb # Author: Michael Ellerman # Date: Mon Jun 14 23:14:40 2021 +1000 # # powerpc: Fix initrd corruption with relative jump labels # # Commit b0b3b2c78ec0 ("powerpc: Switch to relative jump labels") switched # us to using relative jump labels. That involves changing the code, # target and key members in struct jump_entry to be relative to the # address of the jump_entry, rather than absolute addresses. # # We have two static inlines that create a struct jump_entry, # arch_static_branch() and arch_static_branch_jump(), as well as an asm # macro ARCH_STATIC_BRANCH, which is used by the pseries-only hypervisor # tracing code. # # Unfortunately we missed updating the key to be a relative reference in # ARCH_STATIC_BRANCH. # # That causes a pseries kernel to have a handful of jump_entry structs # with bad key values. Instead of being a relative reference they instead # hold the full address of the key. # # However the code doesn't expect that, it still adds the key value to the # address of the jump_entry (see jump_entry_key()) expecting to get a # pointer to a key somewhere in kernel data. # # The table of jump_entry structs sits in rodata, which comes after the # kernel text. In a typical build this will be somewhere around 15MB. The # address of the key will be somewhere in data, typically around 20MB. # Adding the two values together gets us a pointer somewhere around 45MB. # # We then call static_key_set_entries() with that bad pointer and modify # some members of the struct static_key we think we are pointing at. # # A pseries kernel is typically ~30MB in size, so writing to ~45MB won't # corrupt the kernel itself. However if we're booting with an initrd, # depending on the size and exact location of the initrd, we can corrupt # the initrd. Depending on how exactly we corrupt the initrd it can either # cause the system to not boot, or just corrupt one of the files in the # initrd. # # The fix is simply to make the key value relative to the jump_entry # struct in the ARCH_STATIC_BRANCH macro. # # Fixes: b0b3b2c78ec0 ("powerpc: Switch to relative jump labels") # Reported-by: Anastasia Kovaleva # Reported-by: Roman Bolshakov # Reported-by: Greg Kurz # Reported-by: Daniel Axtens # Signed-off-by: Michael Ellerman # Tested-by: Daniel Axtens # Tested-by: Greg Kurz # Signed-off-by: Michael Ellerman # Link: https://lore.kernel.org/r/20210614131440.312360-1-mpe@ellerman.id.au # < /opt/cross/kisskb/korg/gcc-4.9.4-nolibc/mips-linux/bin/mips-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-4.9.4-nolibc/mips-linux/bin/mips-linux-ld --version # < git log --format=%s --max-count=1 478036c4cd1a16e613a2f883d79c03cf187faacb # < make -s -j 32 ARCH=mips O=/kisskb/build/powerpc-fixes_mips-defconfig_mips-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/mips-linux/bin/mips-linux- defconfig # < make -s -j 32 ARCH=mips O=/kisskb/build/powerpc-fixes_mips-defconfig_mips-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/mips-linux/bin/mips-linux- help # make -s -j 32 ARCH=mips O=/kisskb/build/powerpc-fixes_mips-defconfig_mips-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/mips-linux/bin/mips-linux- olddefconfig # make -s -j 32 ARCH=mips O=/kisskb/build/powerpc-fixes_mips-defconfig_mips-gcc4.9 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-4.9.4-nolibc/mips-linux/bin/mips-linux- /kisskb/src/net/sched/sch_frag.c: In function 'sch_fragment': /kisskb/src/net/sched/sch_frag.c:93:10: warning: missing braces around initializer [-Wmissing-braces] struct rtable sch_frag_rt = { 0 }; ^ /kisskb/src/net/sched/sch_frag.c:93:10: warning: (near initialization for 'sch_frag_rt.dst') [-Wmissing-braces] /kisskb/src/drivers/net/ethernet/mscc/ocelot_vcap.c: In function 'is1_entry_set': /kisskb/src/drivers/net/ethernet/mscc/ocelot_vcap.c:755:11: warning: missing braces around initializer [-Wmissing-braces] struct ocelot_vcap_u16 etype = {0}; ^ /kisskb/src/drivers/net/ethernet/mscc/ocelot_vcap.c:755:11: warning: (near initialization for 'etype.value') [-Wmissing-braces] FIT description: Linux 5.13.0-rc2-g478036c4cd1a Created: Thu Jun 17 02:57:11 2021 Image 0 (kernel) Description: Linux 5.13.0-rc2-g478036c4cd1a Created: Thu Jun 17 02:57:11 2021 Type: Kernel Image Compression: gzip compressed Data Size: 5356446 Bytes = 5230.90 KiB = 5.11 MiB Architecture: MIPS OS: Linux Load Address: 0x80100000 Entry Point: 0x809ca170 Hash algo: sha1 Hash value: c20fee6d1567f9827dcf88b47c96c74ccc130fb7 Image 1 (fdt-boston) Description: img,boston Device Tree Created: Thu Jun 17 02:57:11 2021 Type: Flat Device Tree Compression: uncompressed Data Size: 3793 Bytes = 3.70 KiB = 0.00 MiB Architecture: MIPS Hash algo: sha1 Hash value: 4799f50d688573234da6e9d7701234d394759ef4 Image 2 (fdt-ni169445) Description: NI 169445 device tree Created: Thu Jun 17 02:57:11 2021 Type: Flat Device Tree Compression: uncompressed Data Size: 1871 Bytes = 1.83 KiB = 0.00 MiB Architecture: MIPS Hash algo: sha1 Hash value: 51b89b31605ee62038c8468c429af091dfc75ec7 Image 3 (fdt-ocelot_pcb123) Description: MSCC Ocelot PCB123 Device Tree Created: Thu Jun 17 02:57:11 2021 Type: Flat Device Tree Compression: uncompressed Data Size: 4659 Bytes = 4.55 KiB = 0.00 MiB Architecture: MIPS Hash algo: sha1 Hash value: 5bcb6e4f21e8e5372544aa130b3bd097355a9050 Image 4 (fdt-ocelot_pcb120) Description: MSCC Ocelot PCB120 Device Tree Created: Thu Jun 17 02:57:11 2021 Type: Flat Device Tree Compression: uncompressed Data Size: 5418 Bytes = 5.29 KiB = 0.01 MiB Architecture: MIPS Hash algo: sha1 Hash value: 93d882f2009a217e0fa9dab94788535ed2be8476 Image 5 (fdt-xilfpga) Description: MIPSfpga (xilfpga) Device Tree Created: Thu Jun 17 02:57:11 2021 Type: Flat Device Tree Compression: uncompressed Data Size: 2708 Bytes = 2.64 KiB = 0.00 MiB Architecture: MIPS Hash algo: sha1 Hash value: 63d058b780f65e22da30f0a183433765f1807f1d Default Configuration: 'conf-default' Configuration 0 (conf-default) Description: Generic Linux kernel Kernel: kernel Configuration 1 (conf-boston) Description: Boston Linux kernel Kernel: kernel FDT: fdt-boston Configuration 2 (conf-ni169445) Description: NI 169445 Linux Kernel Kernel: kernel FDT: fdt-ni169445 Configuration 3 (conf-ocelot_pcb123) Description: Ocelot Linux kernel Kernel: kernel FDT: fdt-ocelot_pcb123 Configuration 4 (conf-ocelot_pcb120) Description: Ocelot Linux kernel Kernel: kernel FDT: fdt-ocelot_pcb120 Configuration 5 (conf-xilfpga) Description: MIPSfpga Linux kernel Kernel: kernel FDT: fdt-xilfpga Completed OK # rm -rf /kisskb/build/powerpc-fixes_mips-defconfig_mips-gcc4.9 # Build took: 0:01:46.959786