# git rev-parse -q --verify dc8b1290efbbe974d9968106a03077823d0863d6^{commit} dc8b1290efbbe974d9968106a03077823d0863d6 already have revision, skipping fetch # git checkout -q -f -B kisskb dc8b1290efbbe974d9968106a03077823d0863d6 # git clean -qxdf # < git log -1 # commit dc8b1290efbbe974d9968106a03077823d0863d6 # Author: Russell Currey # Date: Fri Mar 1 01:49:17 2019 +1100 # # powerpc/64s: Implement KUAP for Radix MMU # # Kernel Userspace Access Prevention utilises a feature of the Radix MMU # which disallows read and write access to userspace addresses. By # utilising this, the kernel is prevented from accessing user data from # outside of trusted paths that perform proper safety checks, such as # copy_{to/from}_user() and friends. # # Userspace access is disabled from early boot and is only enabled when # performing an operation like copy_{to/from}_user(). The register that # controls this (AMR) does not prevent userspace from accessing itself, # so there is no need to save and restore when entering and exiting # userspace. # # This feature has a slight performance impact which I roughly measured # to be 3% slower in the worst case (performing 1GB of 1 byte # read()/write() syscalls), and is gated behind the CONFIG_PPC_KUAP # option for performance-critical builds. # # This feature can be tested by using the lkdtm driver (CONFIG_LKDTM=y) # and performing the following: # # # (echo ACCESS_USERSPACE) > [debugfs]/provoke-crash/DIRECT # # If enabled, this should send SIGSEGV to the thread. # # mpe: # - Drop the unused paca flags. # - Zero the UAMOR to be safe. # - Save the AMR when we enter the kernel from the kernel and then # block user access again if it's not already blocked. # - Restore on the way back to the kernel. # - This means we handle nesting of interrupts properly, ie. we are # protected inside the page fault handler caused by a user access. # - Add paranoid checking of AMR in switch and syscall return. # - Add isync()'s around AMR writes as per the ISA. # - Support selectively disabling read or write, with no support for # nesting. # # Co-authored-by: Michael Ellerman # Signed-off-by: Russell Currey # Signed-off-by: Michael Ellerman # --- # # v5: # - On kernel entry check if the AMR is already blocking user access # and if so don't do the mtspr again (pointed out by Nick). # - Rework the constants to make the asm a bit cleaner and avoid any # hard coded shifts. # - Selectively disable read or write, we don't support nesting and # shouldn't need to (famous last words). # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-gcc --version # < /opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux-ld --version # < git log --format=%s --max-count=1 dc8b1290efbbe974d9968106a03077823d0863d6 # < make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next_ppc6xx_defconfig_powerpc-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- ppc6xx_defconfig # make -s -j 48 ARCH=powerpc O=/kisskb/build/powerpc-next_ppc6xx_defconfig_powerpc-gcc8 CROSS_COMPILE=/opt/cross/kisskb/korg/gcc-8.1.0-nolibc/powerpc64-linux/bin/powerpc64-linux- In file included from /kisskb/src/sound/ppc/pmac.h:25, from /kisskb/src/sound/ppc/awacs.c:29: /kisskb/src/sound/ppc/awacs.c: In function 'snd_pmac_awacs_init': /kisskb/src/include/sound/control.h:223:9: warning: 'speaker_vol' may be used uninitialized in this function [-Wmaybe-uninitialized] return _snd_ctl_add_slave(master, slave, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /kisskb/src/sound/ppc/awacs.c:886:36: note: 'speaker_vol' was declared here struct snd_kcontrol *master_vol, *speaker_vol; ^~~~~~~~~~~ INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb774c8) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb66db0) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) INFO: Uncompressed kernel (size 0xb66db0) overlaps the address of the wrapper(0x400000) INFO: Fixing the link_address of wrapper to (0xc00000) Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:06 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5507173 Bytes = 5378.10 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c002a4 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:06 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5506088 Bytes = 5377.04 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c002a4 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:07 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5506966 Bytes = 5377.90 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c002a4 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:07 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5470837 Bytes = 5342.61 KiB = 5.22 MiB Load Address: 00000000 Entry Point: 00000000 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:07 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5507015 Bytes = 5377.94 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c00934 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:07 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5507060 Bytes = 5377.99 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c00934 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:07 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5507059 Bytes = 5377.99 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c002a4 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:07 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5505913 Bytes = 5376.87 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c002a4 Image Name: Linux-5.0.0-rc2+ Created: Sat Mar 2 23:24:07 2019 Image Type: PowerPC Linux Kernel Image (gzip compressed) Data Size: 5507401 Bytes = 5378.32 KiB = 5.25 MiB Load Address: 00c00000 Entry Point: 00c002a4 Completed OK # rm -rf /kisskb/build/powerpc-next_ppc6xx_defconfig_powerpc-gcc8 # Build took: 0:03:48.486543