[Devel] [PATCH rh7 1/3] Revert "ms/x86/unwind: Disable KASAN checks for non-current tasks"

Konstantin Khorenko khorenko at virtuozzo.com
Tue Aug 29 19:09:57 MSK 2023


This reverts commit 226263231f8ce9f54a4fec6e0279c8c13e570d3b.

We are reverting the patch because we need to revert an underlying patch
d21e78475d01 "(ms/sched/x86: Add 'struct inactive_task_frame' to better
document the sleeping task stack frame")

and later we'll rework and re-apply "ms/x86/unwind: Disable KASAN checks
for non-current tasks" again.

https://jira.vzint.dev/browse/PSBM-149932

Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 arch/x86/include/asm/stacktrace.h |  5 +----
 arch/x86/kernel/unwind_frame.c    | 19 ++-----------------
 2 files changed, 3 insertions(+), 21 deletions(-)

diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
index 2af5f0bac060..a4fe84fd293c 100644
--- a/arch/x86/include/asm/stacktrace.h
+++ b/arch/x86/include/asm/stacktrace.h
@@ -53,16 +53,13 @@ static inline bool on_stack(struct stack_info *info, void *addr, size_t len)
 static inline unsigned long *
 get_frame_pointer(struct task_struct *task, struct pt_regs *regs)
 {
-	struct inactive_task_frame *frame;
-
 	if (regs)
 		return (unsigned long *)regs->bp;
 
 	if (task == current)
 		return __builtin_frame_address(0);
 
-	frame = (struct inactive_task_frame *)task->thread.sp;
-	return (unsigned long *)READ_ONCE_NOCHECK(frame->bp);
+	return ((struct inactive_task_frame *)task->thread.sp)->bp;
 }
 #else
 static inline unsigned long *
diff --git a/arch/x86/kernel/unwind_frame.c b/arch/x86/kernel/unwind_frame.c
index 0a7d7d265053..05a9f845c417 100644
--- a/arch/x86/kernel/unwind_frame.c
+++ b/arch/x86/kernel/unwind_frame.c
@@ -6,21 +6,6 @@
 
 #define FRAME_HEADER_SIZE (sizeof(long) * 2)
 
-/*
- * This disables KASAN checking when reading a value from another task's stack,
- * since the other task could be running on another CPU and could have poisoned
- * the stack in the meantime.
- */
-#define READ_ONCE_TASK_STACK(task, x)			\
-({							\
-	unsigned long val;				\
-	if (task == current)				\
-		val = READ_ONCE(x);			\
-	else						\
-		val = READ_ONCE_NOCHECK(x);		\
-	val;						\
-})
-
 unsigned long unwind_get_return_address(struct unwind_state *state)
 {
 	if (unwind_done(state))
@@ -59,7 +44,7 @@ static bool update_stack_state(struct unwind_state *state,
 	/* Move state to the next frame: */
 	state->bp = next_bp;
 	addr_p = state->bp + 1;
-	addr = READ_ONCE_TASK_STACK(state->task, *addr_p);
+	addr = READ_ONCE(*addr_p);
 	state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx,
 					  addr, addr_p);
 
@@ -128,7 +113,7 @@ bool unwind_next_frame(struct unwind_state *state)
 	if (unwind_end(state))
 		goto the_end;
 
-	next_bp = (unsigned long *)READ_ONCE_TASK_STACK(state->task,*state->bp);
+	next_bp = (unsigned long *)READ_ONCE(*state->bp);
 
 	/* make sure the next frame's data is accessible */
 	if (!update_stack_state(state, next_bp)) {
-- 
2.24.3



More information about the Devel mailing list