# git rev-parse -q --verify 8cb55a3daebd4b38330b706117e1c8203ffaf3f5^{commit} 8cb55a3daebd4b38330b706117e1c8203ffaf3f5 already have revision, skipping fetch # git checkout -q -f -B kisskb 8cb55a3daebd4b38330b706117e1c8203ffaf3f5 # git clean -qxdf # < git log -1 # commit 8cb55a3daebd4b38330b706117e1c8203ffaf3f5 # Author: Michael Ellerman # Date: Fri Feb 7 22:15:46 2020 +1100 # # powerpc/futex: Fix incorrect user access blocking # # The early versions of our kernel user access prevention (KUAP) were # written by Russell and Christophe, and didn't have separate # read/write access. # # At some point I picked up the series and added the read/write access, # but I failed to update the usages in futex.h to correctly allow read # and write. # # However we didn't notice because of another bug which was causing the # low-level code to always enable read and write. That bug was fixed # recently in commit 1d8f739b07bd ("powerpc/kuap: Fix set direction in # allow/prevent_user_access()"). # # futex_atomic_cmpxchg_inatomic() is passed the user address as %3 and # does: # # 1: lwarx %1, 0, %3 # cmpw 0, %1, %4 # bne- 3f # 2: stwcx. %5, 0, %3 # # Which clearly loads and stores from/to %3. The logic in # arch_futex_atomic_op_inuser() is similar, so fix both of them to use # allow_read_write_user(). # # Without this fix, and with PPC_KUAP_DEBUG=y, we see eg: # # Bug: Read fault blocked by AMR! # WARNING: CPU: 94 PID: 149215 at arch/powerpc/include/asm/book3s/64/kup-radix.h:126 __do_page_fault+0x600/0xf30 # CPU: 94 PID: 149215 Comm: futex_requeue_p Tainted: G W 5.5.0-rc7-gcc9x-g4c25df5640ae #1 # ... # NIP [c000000000070680] __do_page_fault+0x600/0xf30 # LR [c00000000007067c] __do_page_fault+0x5fc/0xf30 # Call Trace: # [c00020138e5637e0] [c00000000007067c] __do_page_fault+0x5fc/0xf30 (unreliable) # [c00020138e5638c0] [c00000000000ada8] handle_page_fault+0x10/0x30 # --- interrupt: 301 at cmpxchg_futex_value_locked+0x68/0xd0 # LR = futex_lock_pi_atomic+0xe0/0x1f0 # [c00020138e563bc0] [c000000000217b50] futex_lock_pi_atomic+0x80/0x1f0 (unreliable) # [c00020138e563c30] [c00000000021b668] futex_requeue+0x438/0xb60 # [c00020138e563d60] [c00000000021c6cc] do_futex+0x1ec/0x2b0 # [c00020138e563d90] [c00000000021c8b8] sys_futex+0x128/0x200 # [c00020138e563e20] [c00000000000b7ac] system_call+0x5c/0x68 # # Fixes: de78a9c42a79 ("powerpc: Add a framework for Kernel Userspace Access Protection") # Cc: stable@vger.kernel.org # v5.2+ # Signed-off-by: Michael Ellerman # Link: https://lore.kernel.org/r/20200207122145.11928-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 8cb55a3daebd4b38330b706117e1c8203ffaf3f5 # < 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- FIT description: Linux 5.5.0-g8cb55a3daebd Created: Sat Feb 8 01:48:51 2020 Image 0 (kernel@0) Description: Linux 5.5.0-g8cb55a3daebd Created: Sat Feb 8 01:48:51 2020 Type: Kernel Image Compression: gzip compressed Data Size: 4897744 Bytes = 4782.95 KiB = 4.67 MiB Architecture: MIPS OS: Linux Load Address: 0x80100000 Entry Point: 0x808fd930 Hash algo: sha1 Hash value: 8601937d0e3d6a80556960c34d088597ffddf74f Image 1 (fdt@boston) Description: img,boston Device Tree Created: Sat Feb 8 01:48:51 2020 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: Sat Feb 8 01:48:51 2020 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: Sat Feb 8 01:48:51 2020 Type: Flat Device Tree Compression: uncompressed Data Size: 4639 Bytes = 4.53 KiB = 0.00 MiB Architecture: MIPS Hash algo: sha1 Hash value: 018897896b42c41c943aca35a20e4300dba250c8 Image 4 (fdt@ocelot_pcb120) Description: MSCC Ocelot PCB120 Device Tree Created: Sat Feb 8 01:48:51 2020 Type: Flat Device Tree Compression: uncompressed Data Size: 5198 Bytes = 5.08 KiB = 0.00 MiB Architecture: MIPS Hash algo: sha1 Hash value: 36c7bd0bd79cfc2f7dd6acda6c7996294f4967e6 Image 5 (fdt@xilfpga) Description: MIPSfpga (xilfpga) Device Tree Created: Sat Feb 8 01:48:51 2020 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@0 Configuration 1 (conf@boston) Description: Boston Linux kernel Kernel: kernel@0 FDT: fdt@boston Configuration 2 (conf@ni169445) Description: NI 169445 Linux Kernel Kernel: kernel@0 FDT: fdt@ni169445 Configuration 3 (conf@ocelot_pcb123) Description: Ocelot Linux kernel Kernel: kernel@0 FDT: fdt@ocelot_pcb123 Configuration 4 (conf@ocelot_pcb120) Description: Ocelot Linux kernel Kernel: kernel@0 FDT: fdt@ocelot_pcb120 Configuration 5 (conf@xilfpga) Description: MIPSfpga Linux kernel Kernel: kernel@0 FDT: fdt@xilfpga Completed OK # rm -rf /kisskb/build/powerpc-fixes_mips-defconfig_mips-gcc4.9 # Build took: 0:01:54.495210