hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/arm/kernel/ptrace.c
....@@ -1,13 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/arch/arm/kernel/ptrace.c
34 *
45 * By Ross Biro 1/23/92
56 * edited by Linus Torvalds
67 * ARM modifications Copyright (C) 2000 Russell King
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License version 2 as
10
- * published by the Free Software Foundation.
118 */
129 #include <linux/kernel.h>
1310 #include <linux/sched/signal.h>
....@@ -28,7 +25,6 @@
2825 #include <linux/tracehook.h>
2926 #include <linux/unistd.h>
3027
31
-#include <asm/pgtable.h>
3228 #include <asm/traps.h>
3329
3430 #define CREATE_TRACE_POINTS
....@@ -201,22 +197,15 @@
201197 /*
202198 * Handle hitting a breakpoint.
203199 */
204
-void ptrace_break(struct task_struct *tsk, struct pt_regs *regs)
200
+void ptrace_break(struct pt_regs *regs)
205201 {
206
- siginfo_t info;
207
-
208
- clear_siginfo(&info);
209
- info.si_signo = SIGTRAP;
210
- info.si_errno = 0;
211
- info.si_code = TRAP_BRKPT;
212
- info.si_addr = (void __user *)instruction_pointer(regs);
213
-
214
- force_sig_info(SIGTRAP, &info, tsk);
202
+ force_sig_fault(SIGTRAP, TRAP_BRKPT,
203
+ (void __user *)instruction_pointer(regs));
215204 }
216205
217206 static int break_trap(struct pt_regs *regs, unsigned int instr)
218207 {
219
- ptrace_break(current, regs);
208
+ ptrace_break(regs);
220209 return 0;
221210 }
222211
....@@ -580,14 +569,9 @@
580569
581570 static int gpr_get(struct task_struct *target,
582571 const struct user_regset *regset,
583
- unsigned int pos, unsigned int count,
584
- void *kbuf, void __user *ubuf)
572
+ struct membuf to)
585573 {
586
- struct pt_regs *regs = task_pt_regs(target);
587
-
588
- return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
589
- regs,
590
- 0, sizeof(*regs));
574
+ return membuf_write(&to, task_pt_regs(target), sizeof(struct pt_regs));
591575 }
592576
593577 static int gpr_set(struct task_struct *target,
....@@ -613,12 +597,10 @@
613597
614598 static int fpa_get(struct task_struct *target,
615599 const struct user_regset *regset,
616
- unsigned int pos, unsigned int count,
617
- void *kbuf, void __user *ubuf)
600
+ struct membuf to)
618601 {
619
- return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
620
- &task_thread_info(target)->fpstate,
621
- 0, sizeof(struct user_fp));
602
+ return membuf_write(&to, &task_thread_info(target)->fpstate,
603
+ sizeof(struct user_fp));
622604 }
623605
624606 static int fpa_set(struct task_struct *target,
....@@ -653,41 +635,20 @@
653635 * vfp_set() ignores this chunk
654636 *
655637 * 1 word for the FPSCR
656
- *
657
- * The bounds-checking logic built into user_regset_copyout and friends
658
- * means that we can make a simple sequence of calls to map the relevant data
659
- * to/from the specified slice of the user regset structure.
660638 */
661639 static int vfp_get(struct task_struct *target,
662640 const struct user_regset *regset,
663
- unsigned int pos, unsigned int count,
664
- void *kbuf, void __user *ubuf)
641
+ struct membuf to)
665642 {
666
- int ret;
667643 struct thread_info *thread = task_thread_info(target);
668644 struct vfp_hard_struct const *vfp = &thread->vfpstate.hard;
669
- const size_t user_fpregs_offset = offsetof(struct user_vfp, fpregs);
670645 const size_t user_fpscr_offset = offsetof(struct user_vfp, fpscr);
671646
672647 vfp_sync_hwstate(thread);
673648
674
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
675
- &vfp->fpregs,
676
- user_fpregs_offset,
677
- user_fpregs_offset + sizeof(vfp->fpregs));
678
- if (ret)
679
- return ret;
680
-
681
- ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
682
- user_fpregs_offset + sizeof(vfp->fpregs),
683
- user_fpscr_offset);
684
- if (ret)
685
- return ret;
686
-
687
- return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
688
- &vfp->fpscr,
689
- user_fpscr_offset,
690
- user_fpscr_offset + sizeof(vfp->fpscr));
649
+ membuf_write(&to, vfp->fpregs, sizeof(vfp->fpregs));
650
+ membuf_zero(&to, user_fpscr_offset - sizeof(vfp->fpregs));
651
+ return membuf_store(&to, vfp->fpscr);
691652 }
692653
693654 /*
....@@ -750,7 +711,7 @@
750711 .n = ELF_NGREG,
751712 .size = sizeof(u32),
752713 .align = sizeof(u32),
753
- .get = gpr_get,
714
+ .regset_get = gpr_get,
754715 .set = gpr_set
755716 },
756717 [REGSET_FPR] = {
....@@ -762,7 +723,7 @@
762723 .n = sizeof(struct user_fp) / sizeof(u32),
763724 .size = sizeof(u32),
764725 .align = sizeof(u32),
765
- .get = fpa_get,
726
+ .regset_get = fpa_get,
766727 .set = fpa_set
767728 },
768729 #ifdef CONFIG_VFP
....@@ -775,7 +736,7 @@
775736 .n = ARM_VFPREGS_SIZE / sizeof(u32),
776737 .size = sizeof(u32),
777738 .align = sizeof(u32),
778
- .get = vfp_get,
739
+ .regset_get = vfp_get,
779740 .set = vfp_set
780741 },
781742 #endif /* CONFIG_VFP */
....@@ -933,7 +894,7 @@
933894
934895 /* Do seccomp after ptrace; syscall may have changed. */
935896 #ifdef CONFIG_HAVE_ARCH_SECCOMP_FILTER
936
- if (secure_computing(NULL) == -1)
897
+ if (secure_computing() == -1)
937898 return -1;
938899 #else
939900 /* XXX: remove this once OABI gets fixed */