hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/arch/arm/kernel/stacktrace.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 #include <linux/export.h>
23 #include <linux/sched.h>
34 #include <linux/sched/debug.h>
....@@ -52,17 +53,17 @@
5253 return -EINVAL;
5354
5455 frame->sp = frame->fp;
55
- frame->fp = *(unsigned long *)(fp);
56
- frame->pc = *(unsigned long *)(fp + 4);
56
+ frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp));
57
+ frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp + 4));
5758 #else
5859 /* check current frame pointer is within bounds */
5960 if (fp < low + 12 || fp > high - 4)
6061 return -EINVAL;
6162
6263 /* restore the registers from the stack frame */
63
- frame->fp = *(unsigned long *)(fp - 12);
64
- frame->sp = *(unsigned long *)(fp - 8);
65
- frame->pc = *(unsigned long *)(fp - 4);
64
+ frame->fp = READ_ONCE_NOCHECK(*(unsigned long *)(fp - 12));
65
+ frame->sp = READ_ONCE_NOCHECK(*(unsigned long *)(fp - 8));
66
+ frame->pc = READ_ONCE_NOCHECK(*(unsigned long *)(fp - 4));
6667 #endif
6768
6869 return 0;
....@@ -140,8 +141,6 @@
140141 * running on another CPU? For now, ignore it as we
141142 * can't guarantee we won't explode.
142143 */
143
- if (trace->nr_entries < trace->max_entries)
144
- trace->entries[trace->nr_entries++] = ULONG_MAX;
145144 return;
146145 #else
147146 frame.fp = thread_saved_fp(tsk);
....@@ -159,8 +158,6 @@
159158 }
160159
161160 walk_stackframe(&frame, save_trace, &data);
162
- if (trace->nr_entries < trace->max_entries)
163
- trace->entries[trace->nr_entries++] = ULONG_MAX;
164161 }
165162
166163 void save_stack_trace_regs(struct pt_regs *regs, struct stack_trace *trace)
....@@ -178,8 +175,6 @@
178175 frame.pc = regs->ARM_pc;
179176
180177 walk_stackframe(&frame, save_trace, &data);
181
- if (trace->nr_entries < trace->max_entries)
182
- trace->entries[trace->nr_entries++] = ULONG_MAX;
183178 }
184179
185180 void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)