forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/sh/kernel/ptrace_32.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * SuperH process tracing
34 *
....@@ -5,10 +6,6 @@
56 * Copyright (C) 2002 - 2009 Paul Mundt
67 *
78 * Audit support by Yuichi Nakamura <ynakam@hitachisoft.jp>
8
- *
9
- * This file is subject to the terms and conditions of the GNU General Public
10
- * License. See the file "COPYING" in the main directory of this archive
11
- * for more details.
129 */
1310 #include <linux/kernel.h>
1411 #include <linux/sched.h>
....@@ -28,7 +25,6 @@
2825 #include <linux/regset.h>
2926 #include <linux/hw_breakpoint.h>
3027 #include <linux/uaccess.h>
31
-#include <asm/pgtable.h>
3228 #include <asm/processor.h>
3329 #include <asm/mmu_context.h>
3430 #include <asm/syscalls.h>
....@@ -138,26 +134,11 @@
138134
139135 static int genregs_get(struct task_struct *target,
140136 const struct user_regset *regset,
141
- unsigned int pos, unsigned int count,
142
- void *kbuf, void __user *ubuf)
137
+ struct membuf to)
143138 {
144139 const struct pt_regs *regs = task_pt_regs(target);
145
- int ret;
146140
147
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
148
- regs->regs,
149
- 0, 16 * sizeof(unsigned long));
150
- if (!ret)
151
- /* PC, PR, SR, GBR, MACH, MACL, TRA */
152
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
153
- &regs->pc,
154
- offsetof(struct pt_regs, pc),
155
- sizeof(struct pt_regs));
156
- if (!ret)
157
- ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
158
- sizeof(struct pt_regs), -1);
159
-
160
- return ret;
141
+ return membuf_write(&to, regs, sizeof(struct pt_regs));
161142 }
162143
163144 static int genregs_set(struct task_struct *target,
....@@ -184,10 +165,9 @@
184165 }
185166
186167 #ifdef CONFIG_SH_FPU
187
-int fpregs_get(struct task_struct *target,
168
+static int fpregs_get(struct task_struct *target,
188169 const struct user_regset *regset,
189
- unsigned int pos, unsigned int count,
190
- void *kbuf, void __user *ubuf)
170
+ struct membuf to)
191171 {
192172 int ret;
193173
....@@ -195,12 +175,8 @@
195175 if (ret)
196176 return ret;
197177
198
- if ((boot_cpu_data.flags & CPU_HAS_FPU))
199
- return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
200
- &target->thread.xstate->hardfpu, 0, -1);
201
-
202
- return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
203
- &target->thread.xstate->softfpu, 0, -1);
178
+ return membuf_write(&to, target->thread.xstate,
179
+ sizeof(struct user_fpu_struct));
204180 }
205181
206182 static int fpregs_set(struct task_struct *target,
....@@ -234,20 +210,12 @@
234210 #ifdef CONFIG_SH_DSP
235211 static int dspregs_get(struct task_struct *target,
236212 const struct user_regset *regset,
237
- unsigned int pos, unsigned int count,
238
- void *kbuf, void __user *ubuf)
213
+ struct membuf to)
239214 {
240215 const struct pt_dspregs *regs =
241216 (struct pt_dspregs *)&target->thread.dsp_status.dsp_regs;
242
- int ret;
243217
244
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, regs,
245
- 0, sizeof(struct pt_dspregs));
246
- if (!ret)
247
- ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
248
- sizeof(struct pt_dspregs), -1);
249
-
250
- return ret;
218
+ return membuf_write(&to, regs, sizeof(struct pt_dspregs));
251219 }
252220
253221 static int dspregs_set(struct task_struct *target,
....@@ -328,7 +296,7 @@
328296 .n = ELF_NGREG,
329297 .size = sizeof(long),
330298 .align = sizeof(long),
331
- .get = genregs_get,
299
+ .regset_get = genregs_get,
332300 .set = genregs_set,
333301 },
334302
....@@ -338,7 +306,7 @@
338306 .n = sizeof(struct user_fpu_struct) / sizeof(long),
339307 .size = sizeof(long),
340308 .align = sizeof(long),
341
- .get = fpregs_get,
309
+ .regset_get = fpregs_get,
342310 .set = fpregs_set,
343311 .active = fpregs_active,
344312 },
....@@ -349,7 +317,7 @@
349317 .n = sizeof(struct pt_dspregs) / sizeof(long),
350318 .size = sizeof(long),
351319 .align = sizeof(long),
352
- .get = dspregs_get,
320
+ .regset_get = dspregs_get,
353321 .set = dspregs_set,
354322 .active = dspregs_active,
355323 },
....@@ -487,18 +455,14 @@
487455
488456 asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
489457 {
490
- long ret = 0;
491
-
492
- secure_computing_strict(regs->regs[0]);
493
-
494458 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
495
- tracehook_report_syscall_entry(regs))
496
- /*
497
- * Tracing decided this syscall should not happen.
498
- * We'll return a bogus call number to get an ENOSYS
499
- * error, but leave the original number in regs->regs[0].
500
- */
501
- ret = -1L;
459
+ tracehook_report_syscall_entry(regs)) {
460
+ regs->regs[0] = -ENOSYS;
461
+ return -1;
462
+ }
463
+
464
+ if (secure_computing() == -1)
465
+ return -1;
502466
503467 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
504468 trace_sys_enter(regs, regs->regs[0]);
....@@ -506,7 +470,7 @@
506470 audit_syscall_entry(regs->regs[3], regs->regs[4], regs->regs[5],
507471 regs->regs[6], regs->regs[7]);
508472
509
- return ret ?: regs->regs[0];
473
+ return 0;
510474 }
511475
512476 asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)