On Fri, Jul 31, 2020 at 10:56:16AM +0800, Jin Yao wrote:
> There is a potential security issue that perf kernel samples
> may be leaked even though kernel sampling is disabled. For fixing
> the potential leakage, the idea is to use instruction_pointer_set
> to set invalid ip address in leaked perf samples in some cases.
> 
> But instruction_pointer_set is missing on some architectures.
> Define instruction_pointer_set for these architectures.
> 
> Signed-off-by: Jin Yao <[email protected]>
> ---
>  arch/alpha/include/asm/ptrace.h  | 6 ++++++
>  arch/arc/include/asm/ptrace.h    | 6 ++++++
>  arch/nds32/include/asm/ptrace.h  | 7 +++++++
>  arch/xtensa/include/asm/ptrace.h | 6 ++++++
>  4 files changed, 25 insertions(+)

AFAICT you forgot to actually Cc the maintainers for all that.

> diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrace.h
> index df5f317ab3fc..c464d525c110 100644
> --- a/arch/alpha/include/asm/ptrace.h
> +++ b/arch/alpha/include/asm/ptrace.h
> @@ -25,4 +25,10 @@ static inline unsigned long regs_return_value(struct 
> pt_regs *regs)
>       return regs->r0;
>  }
>  
> +static inline void instruction_pointer_set(struct pt_regs *regs,
> +                                        unsigned long val)
> +{
> +     regs->pc = val;
> +}
> +
>  #endif
> diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h
> index 2fdb87addadc..8869a6c0fe8c 100644
> --- a/arch/arc/include/asm/ptrace.h
> +++ b/arch/arc/include/asm/ptrace.h
> @@ -154,6 +154,12 @@ static inline long regs_return_value(struct pt_regs 
> *regs)
>       return (long)regs->r0;
>  }
>  
> +static inline void instruction_pointer_set(struct pt_regs *regs,
> +                                        unsigned long val)
> +{
> +     regs->ret = val;
> +}
> +
>  #endif /* !__ASSEMBLY__ */
>  
>  #endif /* __ASM_PTRACE_H */
> diff --git a/arch/nds32/include/asm/ptrace.h b/arch/nds32/include/asm/ptrace.h
> index 919ee223620c..19a916bef7f5 100644
> --- a/arch/nds32/include/asm/ptrace.h
> +++ b/arch/nds32/include/asm/ptrace.h
> @@ -62,6 +62,13 @@ static inline unsigned long regs_return_value(struct 
> pt_regs *regs)
>  {
>       return regs->uregs[0];
>  }
> +
> +static inline void instruction_pointer_set(struct pt_regs *regs,
> +                                        unsigned long val)
> +{
> +     regs->ipc = val;
> +}
> +
>  extern void show_regs(struct pt_regs *);
>  /* Avoid circular header include via sched.h */
>  struct task_struct;
> diff --git a/arch/xtensa/include/asm/ptrace.h 
> b/arch/xtensa/include/asm/ptrace.h
> index b109416dc07e..82ab1ba99259 100644
> --- a/arch/xtensa/include/asm/ptrace.h
> +++ b/arch/xtensa/include/asm/ptrace.h
> @@ -90,6 +90,12 @@ struct pt_regs {
>  # define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \
>                                              (regs)->areg[1]))
>  
> +static inline void instruction_pointer_set(struct pt_regs *regs,
> +                                        unsigned long val)
> +{
> +     regs->pc = val;
> +}
> +
>  # ifndef CONFIG_SMP
>  #  define profile_pc(regs) instruction_pointer(regs)
>  # else
> -- 
> 2.17.1
> 

Reply via email to