Re: [PATCH v1 1/2] stackprotector: move CANARY_MASK and get_random_canary() into stackprotector.h

2022-10-24 Thread Philippe Mathieu-Daudé
On 23/10/22 22:32, Jason A. Donenfeld wrote: This has nothing to do with random.c and everything to do with stack protectors. Yes, it uses randomness. But many things use randomness. random.h and random.c are concerned with the generation of randomness, not with each and every use. So move this

Re: [PATCH v8 5/6] powerpc/code-patching: Use temporary mm for Radix MMU

2022-10-24 Thread Christopher M. Riedl
On Mon Oct 24, 2022 at 12:17 AM CDT, Benjamin Gray wrote: > On Mon, 2022-10-24 at 14:45 +1100, Russell Currey wrote: > > On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > > > From: "Christopher M. Riedl" > > > -%<-- > > > > > > --- > > > > Is the section following the --- your

[PATCH v9 5/7] powerpc/tlb: Add local flush for page given mm_struct and psize

2022-10-24 Thread Benjamin Gray
Adds a local TLB flush operation that works given an mm_struct, VA to flush, and page size representation. Most implementations mirror the surrounding code. The book3s/32/tlbflush.h implementation is left as a WARN_ONCE_ON because it is more complicated and not required for anything as yet. This

[PATCH v9 1/7] powerpc: Allow clearing and restoring registers independent of saved breakpoint state

2022-10-24 Thread Benjamin Gray
From: Jordan Niethe For the coming temporary mm used for instruction patching, the breakpoint registers need to be cleared to prevent them from accidentally being triggered. As soon as the patching is done, the breakpoints will be restored. The breakpoint state is stored in the per-cpu variable

[PATCH v9 0/7] Use per-CPU temporary mappings for patching on Radix MMU

2022-10-24 Thread Benjamin Gray
This is a revision of Chris and Jordan's series to introduce a per-cpu temporary mm to be used for patching with strict rwx on radix mmus. v9: * Fixed patch series name to include "on Radix MMU" again * Renamed breakpoint functions * Introduce patch to gracefully return when

[PATCH v9 3/7] powerpc/code-patching: Use WARN_ON and fix check in poking_init

2022-10-24 Thread Benjamin Gray
BUG_ON() when failing to initialise the code patching window is excessive, as most critical patching happens during boot before strict RWX control is enabled. Failure to patch after boot is not inherently fatal, so aborting the kernel is better determined by the caller. The return value of

Re: [PATCH v4 2/6] powerpc/module: Handle caller-saved TOC in module linker

2022-10-24 Thread Andrew Donnellan
On Mon, 2022-10-10 at 11:29 +1100, Benjamin Gray wrote: > > A function symbol may set a value in the st_other field to indicate > > the TOC should be treated as caller-saved. The linker should > > ensure> the > > current TOC is saved before calling it and restore the TOC> > > afterwards, > > much

Re: [PATCH v8 3/6] powerpc/code-patching: Verify instruction patch succeeded

2022-10-24 Thread Benjamin Gray
On Mon, 2022-10-24 at 14:20 +1100, Russell Currey wrote: > On Fri, 2022-10-21 at 16:22 +1100, Benjamin Gray wrote: > > diff --git a/arch/powerpc/lib/code-patching.c > > b/arch/powerpc/lib/code-patching.c > > index 34fc7ac34d91..9b9eba574d7e 100644 > > --- a/arch/powerpc/lib/code-patching.c > > +++

[PATCH v9 6/7] powerpc/code-patching: Use temporary mm for Radix MMU

2022-10-24 Thread Benjamin Gray
From: "Christopher M. Riedl" x86 supports the notion of a temporary mm which restricts access to temporary PTEs to a single CPU. A temporary mm is useful for situations where a CPU needs to perform sensitive operations (such as patching a STRICT_KERNEL_RWX kernel) requiring temporary mappings

[PATCH v9 7/7] powerpc/code-patching: Consolidate and cache per-cpu patching context

2022-10-24 Thread Benjamin Gray
With the temp mm context support, there are CPU local variables to hold the patch address and pte. Use these in the non-temp mm path as well instead of adding a level of indirection through the text_poke_area vm_struct and pointer chasing the pte. As both paths use these fields now, there is no

[PATCH v9 2/7] powerpc/code-patching: Handle RWX patching initialisation error

2022-10-24 Thread Benjamin Gray
Detect and abort __do_patch_instruction() when there is no text_poke_area, which implies there is no patching address. This allows patch_instruction() to fail gracefully and let the caller decide what to do, as opposed to the current behaviour of kernel panicking when the null pointer is

[PATCH v9 4/7] powerpc/code-patching: Verify instruction patch succeeded

2022-10-24 Thread Benjamin Gray
Verifies that if the instruction patching did not return an error then the value stored at the given address to patch is now equal to the instruction we patched it to. Signed-off-by: Benjamin Gray --- arch/powerpc/lib/code-patching.c | 2 ++ 1 file changed, 2 insertions(+) diff --git

[PATCH] powerpc: Interrupt handler stack randomisation

2022-10-24 Thread Rohan McLure
Stack frames used by syscall handlers support random offsets as of commit f4a0318f278d (powerpc: add support for syscall stack randomization). Implement the same for general interrupt handlers, by applying the random stack offset and then updating this offset from within the

Re: [PATCH v1 0/5] convert tree to get_random_u32_{below,above,between}()

2022-10-24 Thread Jason Gunthorpe
On Fri, Oct 21, 2022 at 09:43:58PM -0400, Jason A. Donenfeld wrote: > Hey everyone, > > Here's the second and final tranche of tree-wide conversions to get > random integer handling a bit tamer. It's predominantly another > Coccinelle-based patchset. > > First we

[PATCH] soc: fsl: qe: Avoid using gpio_to_desc()

2022-10-24 Thread Linus Walleij
We want to get rid of the old GPIO numberspace, so instead of calling gpio_to_desc() we get the gpio descriptor for the requested line from the device tree directly without passing through the GPIO numberspace, and then we get the gpiochip from the descriptor. Cc: Bartosz Golaszewski Cc:

Re: [PATCH v1 0/5] convert tree to get_random_u32_{below,above,between}()

2022-10-24 Thread Jason A. Donenfeld
On Sun, Oct 23, 2022 at 05:07:13PM -0400, Theodore Ts'o wrote: > On Fri, Oct 21, 2022 at 11:03:22PM -0700, Jakub Kicinski wrote: > > On Sat, 22 Oct 2022 07:47:06 +0200 Jason A. Donenfeld wrote: > > > On Fri, Oct 21, 2022 at 10:32:42PM -0700, Jakub Kicinski wrote: > > > > But whatever. I mean -

Re: [PATCH v8 5/6] powerpc/code-patching: Use temporary mm for Radix MMU

2022-10-24 Thread kernel test robot
Hi Benjamin, Thank you for the patch! Yet something to improve: [auto build test ERROR on 8636df94ec917019c4cb744ba0a1f94cf9057790] url: https://github.com/intel-lab-lkp/linux/commits/Benjamin-Gray/Use-per-CPU-temporary-mappings-for-patching/20221021-133129 base: