All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/2] Missing instruction_pointer_set() instances
@ 2020-07-31  2:56 Jin Yao
  2020-07-31  2:56 ` [PATCH v1 2/2] perf/core: Fake regs for leaked kernel samples Jin Yao
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Jin Yao @ 2020-07-31  2:56 UTC (permalink / raw)
  To: peterz, mingo, oleg, acme, jolsa
  Cc: Linux-kernel, ak, kan.liang, yao.jin, alexander.shishkin,
	mark.rutland, Jin Yao

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 <yao.jin@linux.intel.com>
---
 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(+)

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


^ permalink raw reply related	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2020-08-12  7:25 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-31  2:56 [PATCH v1 1/2] Missing instruction_pointer_set() instances Jin Yao
2020-07-31  2:56 ` [PATCH v1 2/2] perf/core: Fake regs for leaked kernel samples Jin Yao
2020-08-04 11:49   ` peterz
2020-08-05  2:15     ` Jin, Yao
2020-08-05 12:44       ` peterz
2020-08-05 12:57         ` peterz
2020-08-06  2:26         ` Jin, Yao
2020-08-06  9:18           ` peterz
2020-08-06  9:24             ` peterz
2020-08-07  5:32               ` Jin, Yao
2020-08-06 11:00             ` peterz
2020-08-07  6:24               ` Jin, Yao
2020-08-07  9:02                 ` peterz
2020-08-10  2:03                   ` Jin, Yao
2020-08-07  5:23             ` Jin, Yao
2020-08-11  7:50           ` Jin, Yao
2020-08-11  7:59             ` Peter Zijlstra
2020-08-11  8:31               ` Jin, Yao
2020-08-11  8:45                 ` Peter Zijlstra
2020-08-12  3:52                   ` Jin, Yao
2020-08-12  7:25                     ` Like Xu
2020-08-04 11:31 ` [PATCH v1 1/2] Missing instruction_pointer_set() instances peterz
2020-08-05  0:26   ` Jin, Yao
2020-08-04 21:31 ` Max Filippov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.