Re: [RFC PATCH] kernel/module: have the callers of set_memory_*() check the return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Nov 19, 2019 at 09:07:34AM -0800, Kees Cook wrote:
> > diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c
> > index bda949fd84e8..7ea1338821d6 100644
> > --- a/arch/arm/kernel/ftrace.c
> > +++ b/arch/arm/kernel/ftrace.c
> > @@ -59,13 +59,15 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr)
> >  
> >  int ftrace_arch_code_modify_prepare(void)
> >  {
> > -	set_all_modules_text_rw();
> > -	return 0;
> > +	return set_all_modules_text_rw();
> >  }
> >  
> >  int ftrace_arch_code_modify_post_process(void)
> >  {
> > -	set_all_modules_text_ro();
> > +	int ret;
> 
> Blank line here...
> 
> > +	ret = set_all_modules_text_ro();
> > +	if (ret)
> > +		return ret;
> >  	/* Make sure any TLB misses during machine stop are cleared. */
> >  	flush_tlb_all();
> >  	return 0;
> 
> Are callers of these ftrace functions checking return values too?

Aside from the fact that I just deleted the set_all_modules_text_*()
functions, ftrace actually does check the return value. It prvides a
nice WARN and kills ftrace dead.

> > diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c
> > index 171773257974..97a89c38f6b9 100644
> > --- a/arch/arm64/kernel/ftrace.c
> > +++ b/arch/arm64/kernel/ftrace.c
> > @@ -115,9 +115,11 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr)
> >  			}
> >  
> >  			/* point the trampoline to our ftrace entry point */
> > -			module_disable_ro(mod);
> > +			if (module_disable_ro(mod))
> > +				return -EINVAL;
> >  			*dst = trampoline;
> > -			module_enable_ro(mod, true);
> > +			if (module_enable_ro(mod, true))
> > +				return -EINVAL;
> >  
> >  			/*
> >  			 * Ensure updated trampoline is visible to instruction

Patching dead code again:

  https://lkml.kernel.org/r/20191029165832.33606-5-mark.rutland@xxxxxxx





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux