lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191028163421.GI4097@hirez.programming.kicks-ass.net>
Date:   Mon, 28 Oct 2019 17:34:21 +0100
From:   Peter Zijlstra <peterz@...radead.org>
To:     Will Deacon <will@...nel.org>
Cc:     x86@...nel.org, linux-kernel@...r.kernel.org, rostedt@...dmis.org,
        mhiramat@...nel.org, bristot@...hat.com, jbaron@...mai.com,
        torvalds@...ux-foundation.org, tglx@...utronix.de,
        mingo@...nel.org, namit@...are.com, hpa@...or.com, luto@...nel.org,
        ard.biesheuvel@...aro.org, jpoimboe@...hat.com, jeyu@...nel.org,
        rabin@....in, Mark Rutland <mark.rutland@....com>,
        james.morse@....com
Subject: Re: [PATCH v4 13/16] arm/ftrace: Use __patch_text_real()

On Mon, Oct 28, 2019 at 04:25:26PM +0000, Will Deacon wrote:
> Hi Peter,
> 
> On Fri, Oct 18, 2019 at 09:35:38AM +0200, Peter Zijlstra wrote:
> > Instead of flipping text protection, use the patch_text infrastructure
> > that uses a fixmap alias where required.
> > 
> > This removes the last user of set_all_modules_text_*().
> > 
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> > Cc: ard.biesheuvel@...aro.org
> > Cc: rabin@....in
> > Cc: Mark Rutland <mark.rutland@....com>
> > Cc: Will Deacon <will@...nel.org>
> > Cc: james.morse@....com
> > ---
> >  arch/arm/kernel/ftrace.c |   16 ++++++++--------
> >  1 file changed, 8 insertions(+), 8 deletions(-)
> > 
> > --- a/arch/arm/kernel/ftrace.c
> > +++ b/arch/arm/kernel/ftrace.c
> > @@ -22,6 +22,7 @@
> >  #include <asm/ftrace.h>
> >  #include <asm/insn.h>
> >  #include <asm/set_memory.h>
> > +#include <asm/patch.h>
> >  
> >  #ifdef CONFIG_THUMB2_KERNEL
> >  #define	NOP		0xf85deb04	/* pop.w {lr} */
> > @@ -31,13 +32,15 @@
> >  
> >  #ifdef CONFIG_DYNAMIC_FTRACE
> >  
> > +static int patch_text_remap = 0;
> > +
> >  static int __ftrace_modify_code(void *data)
> >  {
> >  	int *command = data;
> >  
> > -	set_kernel_text_rw();
> > +	patch_text_remap++;
> >  	ftrace_modify_all_code(*command);
> > -	set_kernel_text_ro();
> > +	patch_text_remap--;
> >  
> >  	return 0;
> >  }
> > @@ -59,13 +62,13 @@ static unsigned long adjust_address(stru
> >  
> >  int ftrace_arch_code_modify_prepare(void)
> >  {
> > -	set_all_modules_text_rw();
> > +	patch_text_remap++;
> >  	return 0;
> >  }
> >  
> >  int ftrace_arch_code_modify_post_process(void)
> >  {
> > -	set_all_modules_text_ro();
> > +	patch_text_remap--;
> >  	/* Make sure any TLB misses during machine stop are cleared. */
> >  	flush_tlb_all();
> >  	return 0;
> > @@ -97,10 +100,7 @@ static int ftrace_modify_code(unsigned l
> >  			return -EINVAL;
> >  	}
> >  
> > -	if (probe_kernel_write((void *)pc, &new, MCOUNT_INSN_SIZE))
> > -		return -EPERM;
> > -
> > -	flush_icache_range(pc, pc + MCOUNT_INSN_SIZE);
> > +	__patch_text_real((void *)pc, new, patch_text_remap);
> 
> Why can't you just pass 'true' for patch_text_remap? AFAICT, the only
> time you want to pass false is during early boot when the text is
> assumedly still writable without the fixmap.

Ah, it will also become true for module loading once we rework where we
flip the module text RO,X. See this patch:

  https://lkml.kernel.org/r/20191018074634.858645375@infradead.org

But for that to land, there's still a few other issues to fix (KLP).

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ