GNU Linux-libre 4.9.317-gnu1
[releases.git] / arch / x86 / kernel / ptrace.c
1 /* By Ross Biro 1/23/92 */
2 /*
3  * Pentium III FXSR, SSE support
4  *      Gareth Hughes <gareth@valinux.com>, May 2000
5  */
6
7 #include <linux/kernel.h>
8 #include <linux/sched.h>
9 #include <linux/mm.h>
10 #include <linux/smp.h>
11 #include <linux/errno.h>
12 #include <linux/slab.h>
13 #include <linux/ptrace.h>
14 #include <linux/tracehook.h>
15 #include <linux/user.h>
16 #include <linux/elf.h>
17 #include <linux/security.h>
18 #include <linux/audit.h>
19 #include <linux/seccomp.h>
20 #include <linux/signal.h>
21 #include <linux/perf_event.h>
22 #include <linux/hw_breakpoint.h>
23 #include <linux/rcupdate.h>
24 #include <linux/export.h>
25 #include <linux/context_tracking.h>
26 #include <linux/nospec.h>
27
28 #include <asm/uaccess.h>
29 #include <asm/pgtable.h>
30 #include <asm/processor.h>
31 #include <asm/fpu/internal.h>
32 #include <asm/fpu/signal.h>
33 #include <asm/fpu/regset.h>
34 #include <asm/debugreg.h>
35 #include <asm/ldt.h>
36 #include <asm/desc.h>
37 #include <asm/prctl.h>
38 #include <asm/proto.h>
39 #include <asm/hw_breakpoint.h>
40 #include <asm/traps.h>
41 #include <asm/syscall.h>
42
43 #include "tls.h"
44
45 enum x86_regset {
46         REGSET_GENERAL,
47         REGSET_FP,
48         REGSET_XFP,
49         REGSET_IOPERM64 = REGSET_XFP,
50         REGSET_XSTATE,
51         REGSET_TLS,
52         REGSET_IOPERM32,
53 };
54
55 struct pt_regs_offset {
56         const char *name;
57         int offset;
58 };
59
60 #define REG_OFFSET_NAME(r) {.name = #r, .offset = offsetof(struct pt_regs, r)}
61 #define REG_OFFSET_END {.name = NULL, .offset = 0}
62
63 static const struct pt_regs_offset regoffset_table[] = {
64 #ifdef CONFIG_X86_64
65         REG_OFFSET_NAME(r15),
66         REG_OFFSET_NAME(r14),
67         REG_OFFSET_NAME(r13),
68         REG_OFFSET_NAME(r12),
69         REG_OFFSET_NAME(r11),
70         REG_OFFSET_NAME(r10),
71         REG_OFFSET_NAME(r9),
72         REG_OFFSET_NAME(r8),
73 #endif
74         REG_OFFSET_NAME(bx),
75         REG_OFFSET_NAME(cx),
76         REG_OFFSET_NAME(dx),
77         REG_OFFSET_NAME(si),
78         REG_OFFSET_NAME(di),
79         REG_OFFSET_NAME(bp),
80         REG_OFFSET_NAME(ax),
81 #ifdef CONFIG_X86_32
82         REG_OFFSET_NAME(ds),
83         REG_OFFSET_NAME(es),
84         REG_OFFSET_NAME(fs),
85         REG_OFFSET_NAME(gs),
86 #endif
87         REG_OFFSET_NAME(orig_ax),
88         REG_OFFSET_NAME(ip),
89         REG_OFFSET_NAME(cs),
90         REG_OFFSET_NAME(flags),
91         REG_OFFSET_NAME(sp),
92         REG_OFFSET_NAME(ss),
93         REG_OFFSET_END,
94 };
95
96 /**
97  * regs_query_register_offset() - query register offset from its name
98  * @name:       the name of a register
99  *
100  * regs_query_register_offset() returns the offset of a register in struct
101  * pt_regs from its name. If the name is invalid, this returns -EINVAL;
102  */
103 int regs_query_register_offset(const char *name)
104 {
105         const struct pt_regs_offset *roff;
106         for (roff = regoffset_table; roff->name != NULL; roff++)
107                 if (!strcmp(roff->name, name))
108                         return roff->offset;
109         return -EINVAL;
110 }
111
112 /**
113  * regs_query_register_name() - query register name from its offset
114  * @offset:     the offset of a register in struct pt_regs.
115  *
116  * regs_query_register_name() returns the name of a register from its
117  * offset in struct pt_regs. If the @offset is invalid, this returns NULL;
118  */
119 const char *regs_query_register_name(unsigned int offset)
120 {
121         const struct pt_regs_offset *roff;
122         for (roff = regoffset_table; roff->name != NULL; roff++)
123                 if (roff->offset == offset)
124                         return roff->name;
125         return NULL;
126 }
127
128 /*
129  * does not yet catch signals sent when the child dies.
130  * in exit.c or in signal.c.
131  */
132
133 /*
134  * Determines which flags the user has access to [1 = access, 0 = no access].
135  */
136 #define FLAG_MASK_32            ((unsigned long)                        \
137                                  (X86_EFLAGS_CF | X86_EFLAGS_PF |       \
138                                   X86_EFLAGS_AF | X86_EFLAGS_ZF |       \
139                                   X86_EFLAGS_SF | X86_EFLAGS_TF |       \
140                                   X86_EFLAGS_DF | X86_EFLAGS_OF |       \
141                                   X86_EFLAGS_RF | X86_EFLAGS_AC))
142
143 /*
144  * Determines whether a value may be installed in a segment register.
145  */
146 static inline bool invalid_selector(u16 value)
147 {
148         return unlikely(value != 0 && (value & SEGMENT_RPL_MASK) != USER_RPL);
149 }
150
151 #ifdef CONFIG_X86_32
152
153 #define FLAG_MASK               FLAG_MASK_32
154
155 /*
156  * X86_32 CPUs don't save ss and esp if the CPU is already in kernel mode
157  * when it traps.  The previous stack will be directly underneath the saved
158  * registers, and 'sp/ss' won't even have been saved. Thus the '&regs->sp'.
159  *
160  * Now, if the stack is empty, '&regs->sp' is out of range. In this
161  * case we try to take the previous stack. To always return a non-null
162  * stack pointer we fall back to regs as stack if no previous stack
163  * exists.
164  *
165  * This is valid only for kernel mode traps.
166  */
167 unsigned long kernel_stack_pointer(struct pt_regs *regs)
168 {
169         unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
170         unsigned long sp = (unsigned long)&regs->sp;
171         u32 *prev_esp;
172
173         if (context == (sp & ~(THREAD_SIZE - 1)))
174                 return sp;
175
176         prev_esp = (u32 *)(context);
177         if (*prev_esp)
178                 return (unsigned long)*prev_esp;
179
180         return (unsigned long)regs;
181 }
182 EXPORT_SYMBOL_GPL(kernel_stack_pointer);
183
184 static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
185 {
186         BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
187         return &regs->bx + (regno >> 2);
188 }
189
190 static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
191 {
192         /*
193          * Returning the value truncates it to 16 bits.
194          */
195         unsigned int retval;
196         if (offset != offsetof(struct user_regs_struct, gs))
197                 retval = *pt_regs_access(task_pt_regs(task), offset);
198         else {
199                 if (task == current)
200                         retval = get_user_gs(task_pt_regs(task));
201                 else
202                         retval = task_user_gs(task);
203         }
204         return retval;
205 }
206
207 static int set_segment_reg(struct task_struct *task,
208                            unsigned long offset, u16 value)
209 {
210         /*
211          * The value argument was already truncated to 16 bits.
212          */
213         if (invalid_selector(value))
214                 return -EIO;
215
216         /*
217          * For %cs and %ss we cannot permit a null selector.
218          * We can permit a bogus selector as long as it has USER_RPL.
219          * Null selectors are fine for other segment registers, but
220          * we will never get back to user mode with invalid %cs or %ss
221          * and will take the trap in iret instead.  Much code relies
222          * on user_mode() to distinguish a user trap frame (which can
223          * safely use invalid selectors) from a kernel trap frame.
224          */
225         switch (offset) {
226         case offsetof(struct user_regs_struct, cs):
227         case offsetof(struct user_regs_struct, ss):
228                 if (unlikely(value == 0))
229                         return -EIO;
230
231         default:
232                 *pt_regs_access(task_pt_regs(task), offset) = value;
233                 break;
234
235         case offsetof(struct user_regs_struct, gs):
236                 if (task == current)
237                         set_user_gs(task_pt_regs(task), value);
238                 else
239                         task_user_gs(task) = value;
240         }
241
242         return 0;
243 }
244
245 #else  /* CONFIG_X86_64 */
246
247 #define FLAG_MASK               (FLAG_MASK_32 | X86_EFLAGS_NT)
248
249 static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long offset)
250 {
251         BUILD_BUG_ON(offsetof(struct pt_regs, r15) != 0);
252         return &regs->r15 + (offset / sizeof(regs->r15));
253 }
254
255 static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
256 {
257         /*
258          * Returning the value truncates it to 16 bits.
259          */
260         unsigned int seg;
261
262         switch (offset) {
263         case offsetof(struct user_regs_struct, fs):
264                 if (task == current) {
265                         /* Older gas can't assemble movq %?s,%r?? */
266                         asm("movl %%fs,%0" : "=r" (seg));
267                         return seg;
268                 }
269                 return task->thread.fsindex;
270         case offsetof(struct user_regs_struct, gs):
271                 if (task == current) {
272                         asm("movl %%gs,%0" : "=r" (seg));
273                         return seg;
274                 }
275                 return task->thread.gsindex;
276         case offsetof(struct user_regs_struct, ds):
277                 if (task == current) {
278                         asm("movl %%ds,%0" : "=r" (seg));
279                         return seg;
280                 }
281                 return task->thread.ds;
282         case offsetof(struct user_regs_struct, es):
283                 if (task == current) {
284                         asm("movl %%es,%0" : "=r" (seg));
285                         return seg;
286                 }
287                 return task->thread.es;
288
289         case offsetof(struct user_regs_struct, cs):
290         case offsetof(struct user_regs_struct, ss):
291                 break;
292         }
293         return *pt_regs_access(task_pt_regs(task), offset);
294 }
295
296 static int set_segment_reg(struct task_struct *task,
297                            unsigned long offset, u16 value)
298 {
299         /*
300          * The value argument was already truncated to 16 bits.
301          */
302         if (invalid_selector(value))
303                 return -EIO;
304
305         switch (offset) {
306         case offsetof(struct user_regs_struct,fs):
307                 task->thread.fsindex = value;
308                 if (task == current)
309                         loadsegment(fs, task->thread.fsindex);
310                 break;
311         case offsetof(struct user_regs_struct,gs):
312                 task->thread.gsindex = value;
313                 if (task == current)
314                         load_gs_index(task->thread.gsindex);
315                 break;
316         case offsetof(struct user_regs_struct,ds):
317                 task->thread.ds = value;
318                 if (task == current)
319                         loadsegment(ds, task->thread.ds);
320                 break;
321         case offsetof(struct user_regs_struct,es):
322                 task->thread.es = value;
323                 if (task == current)
324                         loadsegment(es, task->thread.es);
325                 break;
326
327                 /*
328                  * Can't actually change these in 64-bit mode.
329                  */
330         case offsetof(struct user_regs_struct,cs):
331                 if (unlikely(value == 0))
332                         return -EIO;
333                 task_pt_regs(task)->cs = value;
334                 break;
335         case offsetof(struct user_regs_struct,ss):
336                 if (unlikely(value == 0))
337                         return -EIO;
338                 task_pt_regs(task)->ss = value;
339                 break;
340         }
341
342         return 0;
343 }
344
345 #endif  /* CONFIG_X86_32 */
346
347 static unsigned long get_flags(struct task_struct *task)
348 {
349         unsigned long retval = task_pt_regs(task)->flags;
350
351         /*
352          * If the debugger set TF, hide it from the readout.
353          */
354         if (test_tsk_thread_flag(task, TIF_FORCED_TF))
355                 retval &= ~X86_EFLAGS_TF;
356
357         return retval;
358 }
359
360 static int set_flags(struct task_struct *task, unsigned long value)
361 {
362         struct pt_regs *regs = task_pt_regs(task);
363
364         /*
365          * If the user value contains TF, mark that
366          * it was not "us" (the debugger) that set it.
367          * If not, make sure it stays set if we had.
368          */
369         if (value & X86_EFLAGS_TF)
370                 clear_tsk_thread_flag(task, TIF_FORCED_TF);
371         else if (test_tsk_thread_flag(task, TIF_FORCED_TF))
372                 value |= X86_EFLAGS_TF;
373
374         regs->flags = (regs->flags & ~FLAG_MASK) | (value & FLAG_MASK);
375
376         return 0;
377 }
378
379 static int putreg(struct task_struct *child,
380                   unsigned long offset, unsigned long value)
381 {
382         switch (offset) {
383         case offsetof(struct user_regs_struct, cs):
384         case offsetof(struct user_regs_struct, ds):
385         case offsetof(struct user_regs_struct, es):
386         case offsetof(struct user_regs_struct, fs):
387         case offsetof(struct user_regs_struct, gs):
388         case offsetof(struct user_regs_struct, ss):
389                 return set_segment_reg(child, offset, value);
390
391         case offsetof(struct user_regs_struct, flags):
392                 return set_flags(child, value);
393
394 #ifdef CONFIG_X86_64
395         case offsetof(struct user_regs_struct,fs_base):
396                 if (value >= TASK_SIZE_MAX)
397                         return -EIO;
398                 /*
399                  * When changing the segment base, use do_arch_prctl
400                  * to set either thread.fs or thread.fsindex and the
401                  * corresponding GDT slot.
402                  */
403                 if (child->thread.fsbase != value)
404                         return do_arch_prctl(child, ARCH_SET_FS, value);
405                 return 0;
406         case offsetof(struct user_regs_struct,gs_base):
407                 /*
408                  * Exactly the same here as the %fs handling above.
409                  */
410                 if (value >= TASK_SIZE_MAX)
411                         return -EIO;
412                 if (child->thread.gsbase != value)
413                         return do_arch_prctl(child, ARCH_SET_GS, value);
414                 return 0;
415 #endif
416         }
417
418         *pt_regs_access(task_pt_regs(child), offset) = value;
419         return 0;
420 }
421
422 static unsigned long getreg(struct task_struct *task, unsigned long offset)
423 {
424         switch (offset) {
425         case offsetof(struct user_regs_struct, cs):
426         case offsetof(struct user_regs_struct, ds):
427         case offsetof(struct user_regs_struct, es):
428         case offsetof(struct user_regs_struct, fs):
429         case offsetof(struct user_regs_struct, gs):
430         case offsetof(struct user_regs_struct, ss):
431                 return get_segment_reg(task, offset);
432
433         case offsetof(struct user_regs_struct, flags):
434                 return get_flags(task);
435
436 #ifdef CONFIG_X86_64
437         case offsetof(struct user_regs_struct, fs_base): {
438                 /*
439                  * XXX: This will not behave as expected if called on
440                  * current or if fsindex != 0.
441                  */
442                 return task->thread.fsbase;
443         }
444         case offsetof(struct user_regs_struct, gs_base): {
445                 /*
446                  * XXX: This will not behave as expected if called on
447                  * current or if fsindex != 0.
448                  */
449                 return task->thread.gsbase;
450         }
451 #endif
452         }
453
454         return *pt_regs_access(task_pt_regs(task), offset);
455 }
456
457 static int genregs_get(struct task_struct *target,
458                        const struct user_regset *regset,
459                        unsigned int pos, unsigned int count,
460                        void *kbuf, void __user *ubuf)
461 {
462         if (kbuf) {
463                 unsigned long *k = kbuf;
464                 while (count >= sizeof(*k)) {
465                         *k++ = getreg(target, pos);
466                         count -= sizeof(*k);
467                         pos += sizeof(*k);
468                 }
469         } else {
470                 unsigned long __user *u = ubuf;
471                 while (count >= sizeof(*u)) {
472                         if (__put_user(getreg(target, pos), u++))
473                                 return -EFAULT;
474                         count -= sizeof(*u);
475                         pos += sizeof(*u);
476                 }
477         }
478
479         return 0;
480 }
481
482 static int genregs_set(struct task_struct *target,
483                        const struct user_regset *regset,
484                        unsigned int pos, unsigned int count,
485                        const void *kbuf, const void __user *ubuf)
486 {
487         int ret = 0;
488         if (kbuf) {
489                 const unsigned long *k = kbuf;
490                 while (count >= sizeof(*k) && !ret) {
491                         ret = putreg(target, pos, *k++);
492                         count -= sizeof(*k);
493                         pos += sizeof(*k);
494                 }
495         } else {
496                 const unsigned long  __user *u = ubuf;
497                 while (count >= sizeof(*u) && !ret) {
498                         unsigned long word;
499                         ret = __get_user(word, u++);
500                         if (ret)
501                                 break;
502                         ret = putreg(target, pos, word);
503                         count -= sizeof(*u);
504                         pos += sizeof(*u);
505                 }
506         }
507         return ret;
508 }
509
510 static void ptrace_triggered(struct perf_event *bp,
511                              struct perf_sample_data *data,
512                              struct pt_regs *regs)
513 {
514         int i;
515         struct thread_struct *thread = &(current->thread);
516
517         /*
518          * Store in the virtual DR6 register the fact that the breakpoint
519          * was hit so the thread's debugger will see it.
520          */
521         for (i = 0; i < HBP_NUM; i++) {
522                 if (thread->ptrace_bps[i] == bp)
523                         break;
524         }
525
526         thread->debugreg6 |= (DR_TRAP0 << i);
527 }
528
529 /*
530  * Walk through every ptrace breakpoints for this thread and
531  * build the dr7 value on top of their attributes.
532  *
533  */
534 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
535 {
536         int i;
537         int dr7 = 0;
538         struct arch_hw_breakpoint *info;
539
540         for (i = 0; i < HBP_NUM; i++) {
541                 if (bp[i] && !bp[i]->attr.disabled) {
542                         info = counter_arch_bp(bp[i]);
543                         dr7 |= encode_dr7(i, info->len, info->type);
544                 }
545         }
546
547         return dr7;
548 }
549
550 static int ptrace_fill_bp_fields(struct perf_event_attr *attr,
551                                         int len, int type, bool disabled)
552 {
553         int err, bp_len, bp_type;
554
555         err = arch_bp_generic_fields(len, type, &bp_len, &bp_type);
556         if (!err) {
557                 attr->bp_len = bp_len;
558                 attr->bp_type = bp_type;
559                 attr->disabled = disabled;
560         }
561
562         return err;
563 }
564
565 static struct perf_event *
566 ptrace_register_breakpoint(struct task_struct *tsk, int len, int type,
567                                 unsigned long addr, bool disabled)
568 {
569         struct perf_event_attr attr;
570         int err;
571
572         ptrace_breakpoint_init(&attr);
573         attr.bp_addr = addr;
574
575         err = ptrace_fill_bp_fields(&attr, len, type, disabled);
576         if (err)
577                 return ERR_PTR(err);
578
579         return register_user_hw_breakpoint(&attr, ptrace_triggered,
580                                                  NULL, tsk);
581 }
582
583 static int ptrace_modify_breakpoint(struct perf_event *bp, int len, int type,
584                                         int disabled)
585 {
586         struct perf_event_attr attr = bp->attr;
587         int err;
588
589         err = ptrace_fill_bp_fields(&attr, len, type, disabled);
590         if (err)
591                 return err;
592
593         return modify_user_hw_breakpoint(bp, &attr);
594 }
595
596 /*
597  * Handle ptrace writes to debug register 7.
598  */
599 static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data)
600 {
601         struct thread_struct *thread = &tsk->thread;
602         unsigned long old_dr7;
603         bool second_pass = false;
604         int i, rc, ret = 0;
605
606         data &= ~DR_CONTROL_RESERVED;
607         old_dr7 = ptrace_get_dr7(thread->ptrace_bps);
608
609 restore:
610         rc = 0;
611         for (i = 0; i < HBP_NUM; i++) {
612                 unsigned len, type;
613                 bool disabled = !decode_dr7(data, i, &len, &type);
614                 struct perf_event *bp = thread->ptrace_bps[i];
615
616                 if (!bp) {
617                         if (disabled)
618                                 continue;
619
620                         bp = ptrace_register_breakpoint(tsk,
621                                         len, type, 0, disabled);
622                         if (IS_ERR(bp)) {
623                                 rc = PTR_ERR(bp);
624                                 break;
625                         }
626
627                         thread->ptrace_bps[i] = bp;
628                         continue;
629                 }
630
631                 rc = ptrace_modify_breakpoint(bp, len, type, disabled);
632                 if (rc)
633                         break;
634         }
635
636         /* Restore if the first pass failed, second_pass shouldn't fail. */
637         if (rc && !WARN_ON(second_pass)) {
638                 ret = rc;
639                 data = old_dr7;
640                 second_pass = true;
641                 goto restore;
642         }
643
644         return ret;
645 }
646
647 /*
648  * Handle PTRACE_PEEKUSR calls for the debug register area.
649  */
650 static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
651 {
652         struct thread_struct *thread = &tsk->thread;
653         unsigned long val = 0;
654
655         if (n < HBP_NUM) {
656                 int index = array_index_nospec(n, HBP_NUM);
657                 struct perf_event *bp = thread->ptrace_bps[index];
658
659                 if (bp)
660                         val = bp->hw.info.address;
661         } else if (n == 6) {
662                 val = thread->debugreg6;
663         } else if (n == 7) {
664                 val = thread->ptrace_dr7;
665         }
666         return val;
667 }
668
669 static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr,
670                                       unsigned long addr)
671 {
672         struct thread_struct *t = &tsk->thread;
673         struct perf_event *bp = t->ptrace_bps[nr];
674         int err = 0;
675
676         if (!bp) {
677                 /*
678                  * Put stub len and type to create an inactive but correct bp.
679                  *
680                  * CHECKME: the previous code returned -EIO if the addr wasn't
681                  * a valid task virtual addr. The new one will return -EINVAL in
682                  *  this case.
683                  * -EINVAL may be what we want for in-kernel breakpoints users,
684                  * but -EIO looks better for ptrace, since we refuse a register
685                  * writing for the user. And anyway this is the previous
686                  * behaviour.
687                  */
688                 bp = ptrace_register_breakpoint(tsk,
689                                 X86_BREAKPOINT_LEN_1, X86_BREAKPOINT_WRITE,
690                                 addr, true);
691                 if (IS_ERR(bp))
692                         err = PTR_ERR(bp);
693                 else
694                         t->ptrace_bps[nr] = bp;
695         } else {
696                 struct perf_event_attr attr = bp->attr;
697
698                 attr.bp_addr = addr;
699                 err = modify_user_hw_breakpoint(bp, &attr);
700         }
701
702         return err;
703 }
704
705 /*
706  * Handle PTRACE_POKEUSR calls for the debug register area.
707  */
708 static int ptrace_set_debugreg(struct task_struct *tsk, int n,
709                                unsigned long val)
710 {
711         struct thread_struct *thread = &tsk->thread;
712         /* There are no DR4 or DR5 registers */
713         int rc = -EIO;
714
715         if (n < HBP_NUM) {
716                 rc = ptrace_set_breakpoint_addr(tsk, n, val);
717         } else if (n == 6) {
718                 thread->debugreg6 = val;
719                 rc = 0;
720         } else if (n == 7) {
721                 rc = ptrace_write_dr7(tsk, val);
722                 if (!rc)
723                         thread->ptrace_dr7 = val;
724         }
725         return rc;
726 }
727
728 /*
729  * These access the current or another (stopped) task's io permission
730  * bitmap for debugging or core dump.
731  */
732 static int ioperm_active(struct task_struct *target,
733                          const struct user_regset *regset)
734 {
735         return target->thread.io_bitmap_max / regset->size;
736 }
737
738 static int ioperm_get(struct task_struct *target,
739                       const struct user_regset *regset,
740                       unsigned int pos, unsigned int count,
741                       void *kbuf, void __user *ubuf)
742 {
743         if (!target->thread.io_bitmap_ptr)
744                 return -ENXIO;
745
746         return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
747                                    target->thread.io_bitmap_ptr,
748                                    0, IO_BITMAP_BYTES);
749 }
750
751 /*
752  * Called by kernel/ptrace.c when detaching..
753  *
754  * Make sure the single step bit is not set.
755  */
756 void ptrace_disable(struct task_struct *child)
757 {
758         user_disable_single_step(child);
759 #ifdef TIF_SYSCALL_EMU
760         clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
761 #endif
762 }
763
764 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
765 static const struct user_regset_view user_x86_32_view; /* Initialized below. */
766 #endif
767
768 long arch_ptrace(struct task_struct *child, long request,
769                  unsigned long addr, unsigned long data)
770 {
771         int ret;
772         unsigned long __user *datap = (unsigned long __user *)data;
773
774         switch (request) {
775         /* read the word at location addr in the USER area. */
776         case PTRACE_PEEKUSR: {
777                 unsigned long tmp;
778
779                 ret = -EIO;
780                 if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user))
781                         break;
782
783                 tmp = 0;  /* Default return condition */
784                 if (addr < sizeof(struct user_regs_struct))
785                         tmp = getreg(child, addr);
786                 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
787                          addr <= offsetof(struct user, u_debugreg[7])) {
788                         addr -= offsetof(struct user, u_debugreg[0]);
789                         tmp = ptrace_get_debugreg(child, addr / sizeof(data));
790                 }
791                 ret = put_user(tmp, datap);
792                 break;
793         }
794
795         case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
796                 ret = -EIO;
797                 if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user))
798                         break;
799
800                 if (addr < sizeof(struct user_regs_struct))
801                         ret = putreg(child, addr, data);
802                 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
803                          addr <= offsetof(struct user, u_debugreg[7])) {
804                         addr -= offsetof(struct user, u_debugreg[0]);
805                         ret = ptrace_set_debugreg(child,
806                                                   addr / sizeof(data), data);
807                 }
808                 break;
809
810         case PTRACE_GETREGS:    /* Get all gp regs from the child. */
811                 return copy_regset_to_user(child,
812                                            task_user_regset_view(current),
813                                            REGSET_GENERAL,
814                                            0, sizeof(struct user_regs_struct),
815                                            datap);
816
817         case PTRACE_SETREGS:    /* Set all gp regs in the child. */
818                 return copy_regset_from_user(child,
819                                              task_user_regset_view(current),
820                                              REGSET_GENERAL,
821                                              0, sizeof(struct user_regs_struct),
822                                              datap);
823
824         case PTRACE_GETFPREGS:  /* Get the child FPU state. */
825                 return copy_regset_to_user(child,
826                                            task_user_regset_view(current),
827                                            REGSET_FP,
828                                            0, sizeof(struct user_i387_struct),
829                                            datap);
830
831         case PTRACE_SETFPREGS:  /* Set the child FPU state. */
832                 return copy_regset_from_user(child,
833                                              task_user_regset_view(current),
834                                              REGSET_FP,
835                                              0, sizeof(struct user_i387_struct),
836                                              datap);
837
838 #ifdef CONFIG_X86_32
839         case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
840                 return copy_regset_to_user(child, &user_x86_32_view,
841                                            REGSET_XFP,
842                                            0, sizeof(struct user_fxsr_struct),
843                                            datap) ? -EIO : 0;
844
845         case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
846                 return copy_regset_from_user(child, &user_x86_32_view,
847                                              REGSET_XFP,
848                                              0, sizeof(struct user_fxsr_struct),
849                                              datap) ? -EIO : 0;
850 #endif
851
852 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
853         case PTRACE_GET_THREAD_AREA:
854                 if ((int) addr < 0)
855                         return -EIO;
856                 ret = do_get_thread_area(child, addr,
857                                         (struct user_desc __user *)data);
858                 break;
859
860         case PTRACE_SET_THREAD_AREA:
861                 if ((int) addr < 0)
862                         return -EIO;
863                 ret = do_set_thread_area(child, addr,
864                                         (struct user_desc __user *)data, 0);
865                 break;
866 #endif
867
868 #ifdef CONFIG_X86_64
869                 /* normal 64bit interface to access TLS data.
870                    Works just like arch_prctl, except that the arguments
871                    are reversed. */
872         case PTRACE_ARCH_PRCTL:
873                 ret = do_arch_prctl(child, data, addr);
874                 break;
875 #endif
876
877         default:
878                 ret = ptrace_request(child, request, addr, data);
879                 break;
880         }
881
882         return ret;
883 }
884
885 #ifdef CONFIG_IA32_EMULATION
886
887 #include <linux/compat.h>
888 #include <linux/syscalls.h>
889 #include <asm/ia32.h>
890 #include <asm/user32.h>
891
892 #define R32(l,q)                                                        \
893         case offsetof(struct user32, regs.l):                           \
894                 regs->q = value; break
895
896 #define SEG32(rs)                                                       \
897         case offsetof(struct user32, regs.rs):                          \
898                 return set_segment_reg(child,                           \
899                                        offsetof(struct user_regs_struct, rs), \
900                                        value);                          \
901                 break
902
903 static int putreg32(struct task_struct *child, unsigned regno, u32 value)
904 {
905         struct pt_regs *regs = task_pt_regs(child);
906
907         switch (regno) {
908
909         SEG32(cs);
910         SEG32(ds);
911         SEG32(es);
912         SEG32(fs);
913         SEG32(gs);
914         SEG32(ss);
915
916         R32(ebx, bx);
917         R32(ecx, cx);
918         R32(edx, dx);
919         R32(edi, di);
920         R32(esi, si);
921         R32(ebp, bp);
922         R32(eax, ax);
923         R32(eip, ip);
924         R32(esp, sp);
925
926         case offsetof(struct user32, regs.orig_eax):
927                 /*
928                  * Warning: bizarre corner case fixup here.  A 32-bit
929                  * debugger setting orig_eax to -1 wants to disable
930                  * syscall restart.  Make sure that the syscall
931                  * restart code sign-extends orig_ax.  Also make sure
932                  * we interpret the -ERESTART* codes correctly if
933                  * loaded into regs->ax in case the task is not
934                  * actually still sitting at the exit from a 32-bit
935                  * syscall with TS_COMPAT still set.
936                  */
937                 regs->orig_ax = value;
938                 if (syscall_get_nr(child, regs) >= 0)
939                         child->thread_info.status |= TS_I386_REGS_POKED;
940                 break;
941
942         case offsetof(struct user32, regs.eflags):
943                 return set_flags(child, value);
944
945         case offsetof(struct user32, u_debugreg[0]) ...
946                 offsetof(struct user32, u_debugreg[7]):
947                 regno -= offsetof(struct user32, u_debugreg[0]);
948                 return ptrace_set_debugreg(child, regno / 4, value);
949
950         default:
951                 if (regno > sizeof(struct user32) || (regno & 3))
952                         return -EIO;
953
954                 /*
955                  * Other dummy fields in the virtual user structure
956                  * are ignored
957                  */
958                 break;
959         }
960         return 0;
961 }
962
963 #undef R32
964 #undef SEG32
965
966 #define R32(l,q)                                                        \
967         case offsetof(struct user32, regs.l):                           \
968                 *val = regs->q; break
969
970 #define SEG32(rs)                                                       \
971         case offsetof(struct user32, regs.rs):                          \
972                 *val = get_segment_reg(child,                           \
973                                        offsetof(struct user_regs_struct, rs)); \
974                 break
975
976 static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
977 {
978         struct pt_regs *regs = task_pt_regs(child);
979
980         switch (regno) {
981
982         SEG32(ds);
983         SEG32(es);
984         SEG32(fs);
985         SEG32(gs);
986
987         R32(cs, cs);
988         R32(ss, ss);
989         R32(ebx, bx);
990         R32(ecx, cx);
991         R32(edx, dx);
992         R32(edi, di);
993         R32(esi, si);
994         R32(ebp, bp);
995         R32(eax, ax);
996         R32(orig_eax, orig_ax);
997         R32(eip, ip);
998         R32(esp, sp);
999
1000         case offsetof(struct user32, regs.eflags):
1001                 *val = get_flags(child);
1002                 break;
1003
1004         case offsetof(struct user32, u_debugreg[0]) ...
1005                 offsetof(struct user32, u_debugreg[7]):
1006                 regno -= offsetof(struct user32, u_debugreg[0]);
1007                 *val = ptrace_get_debugreg(child, regno / 4);
1008                 break;
1009
1010         default:
1011                 if (regno > sizeof(struct user32) || (regno & 3))
1012                         return -EIO;
1013
1014                 /*
1015                  * Other dummy fields in the virtual user structure
1016                  * are ignored
1017                  */
1018                 *val = 0;
1019                 break;
1020         }
1021         return 0;
1022 }
1023
1024 #undef R32
1025 #undef SEG32
1026
1027 static int genregs32_get(struct task_struct *target,
1028                          const struct user_regset *regset,
1029                          unsigned int pos, unsigned int count,
1030                          void *kbuf, void __user *ubuf)
1031 {
1032         if (kbuf) {
1033                 compat_ulong_t *k = kbuf;
1034                 while (count >= sizeof(*k)) {
1035                         getreg32(target, pos, k++);
1036                         count -= sizeof(*k);
1037                         pos += sizeof(*k);
1038                 }
1039         } else {
1040                 compat_ulong_t __user *u = ubuf;
1041                 while (count >= sizeof(*u)) {
1042                         compat_ulong_t word;
1043                         getreg32(target, pos, &word);
1044                         if (__put_user(word, u++))
1045                                 return -EFAULT;
1046                         count -= sizeof(*u);
1047                         pos += sizeof(*u);
1048                 }
1049         }
1050
1051         return 0;
1052 }
1053
1054 static int genregs32_set(struct task_struct *target,
1055                          const struct user_regset *regset,
1056                          unsigned int pos, unsigned int count,
1057                          const void *kbuf, const void __user *ubuf)
1058 {
1059         int ret = 0;
1060         if (kbuf) {
1061                 const compat_ulong_t *k = kbuf;
1062                 while (count >= sizeof(*k) && !ret) {
1063                         ret = putreg32(target, pos, *k++);
1064                         count -= sizeof(*k);
1065                         pos += sizeof(*k);
1066                 }
1067         } else {
1068                 const compat_ulong_t __user *u = ubuf;
1069                 while (count >= sizeof(*u) && !ret) {
1070                         compat_ulong_t word;
1071                         ret = __get_user(word, u++);
1072                         if (ret)
1073                                 break;
1074                         ret = putreg32(target, pos, word);
1075                         count -= sizeof(*u);
1076                         pos += sizeof(*u);
1077                 }
1078         }
1079         return ret;
1080 }
1081
1082 static long ia32_arch_ptrace(struct task_struct *child, compat_long_t request,
1083                              compat_ulong_t caddr, compat_ulong_t cdata)
1084 {
1085         unsigned long addr = caddr;
1086         unsigned long data = cdata;
1087         void __user *datap = compat_ptr(data);
1088         int ret;
1089         __u32 val;
1090
1091         switch (request) {
1092         case PTRACE_PEEKUSR:
1093                 ret = getreg32(child, addr, &val);
1094                 if (ret == 0)
1095                         ret = put_user(val, (__u32 __user *)datap);
1096                 break;
1097
1098         case PTRACE_POKEUSR:
1099                 ret = putreg32(child, addr, data);
1100                 break;
1101
1102         case PTRACE_GETREGS:    /* Get all gp regs from the child. */
1103                 return copy_regset_to_user(child, &user_x86_32_view,
1104                                            REGSET_GENERAL,
1105                                            0, sizeof(struct user_regs_struct32),
1106                                            datap);
1107
1108         case PTRACE_SETREGS:    /* Set all gp regs in the child. */
1109                 return copy_regset_from_user(child, &user_x86_32_view,
1110                                              REGSET_GENERAL, 0,
1111                                              sizeof(struct user_regs_struct32),
1112                                              datap);
1113
1114         case PTRACE_GETFPREGS:  /* Get the child FPU state. */
1115                 return copy_regset_to_user(child, &user_x86_32_view,
1116                                            REGSET_FP, 0,
1117                                            sizeof(struct user_i387_ia32_struct),
1118                                            datap);
1119
1120         case PTRACE_SETFPREGS:  /* Set the child FPU state. */
1121                 return copy_regset_from_user(
1122                         child, &user_x86_32_view, REGSET_FP,
1123                         0, sizeof(struct user_i387_ia32_struct), datap);
1124
1125         case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
1126                 return copy_regset_to_user(child, &user_x86_32_view,
1127                                            REGSET_XFP, 0,
1128                                            sizeof(struct user32_fxsr_struct),
1129                                            datap);
1130
1131         case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
1132                 return copy_regset_from_user(child, &user_x86_32_view,
1133                                              REGSET_XFP, 0,
1134                                              sizeof(struct user32_fxsr_struct),
1135                                              datap);
1136
1137         case PTRACE_GET_THREAD_AREA:
1138         case PTRACE_SET_THREAD_AREA:
1139                 return arch_ptrace(child, request, addr, data);
1140
1141         default:
1142                 return compat_ptrace_request(child, request, addr, data);
1143         }
1144
1145         return ret;
1146 }
1147 #endif /* CONFIG_IA32_EMULATION */
1148
1149 #ifdef CONFIG_X86_X32_ABI
1150 static long x32_arch_ptrace(struct task_struct *child,
1151                             compat_long_t request, compat_ulong_t caddr,
1152                             compat_ulong_t cdata)
1153 {
1154         unsigned long addr = caddr;
1155         unsigned long data = cdata;
1156         void __user *datap = compat_ptr(data);
1157         int ret;
1158
1159         switch (request) {
1160         /* Read 32bits at location addr in the USER area.  Only allow
1161            to return the lower 32bits of segment and debug registers.  */
1162         case PTRACE_PEEKUSR: {
1163                 u32 tmp;
1164
1165                 ret = -EIO;
1166                 if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user) ||
1167                     addr < offsetof(struct user_regs_struct, cs))
1168                         break;
1169
1170                 tmp = 0;  /* Default return condition */
1171                 if (addr < sizeof(struct user_regs_struct))
1172                         tmp = getreg(child, addr);
1173                 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
1174                          addr <= offsetof(struct user, u_debugreg[7])) {
1175                         addr -= offsetof(struct user, u_debugreg[0]);
1176                         tmp = ptrace_get_debugreg(child, addr / sizeof(data));
1177                 }
1178                 ret = put_user(tmp, (__u32 __user *)datap);
1179                 break;
1180         }
1181
1182         /* Write the word at location addr in the USER area.  Only allow
1183            to update segment and debug registers with the upper 32bits
1184            zero-extended. */
1185         case PTRACE_POKEUSR:
1186                 ret = -EIO;
1187                 if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user) ||
1188                     addr < offsetof(struct user_regs_struct, cs))
1189                         break;
1190
1191                 if (addr < sizeof(struct user_regs_struct))
1192                         ret = putreg(child, addr, data);
1193                 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
1194                          addr <= offsetof(struct user, u_debugreg[7])) {
1195                         addr -= offsetof(struct user, u_debugreg[0]);
1196                         ret = ptrace_set_debugreg(child,
1197                                                   addr / sizeof(data), data);
1198                 }
1199                 break;
1200
1201         case PTRACE_GETREGS:    /* Get all gp regs from the child. */
1202                 return copy_regset_to_user(child,
1203                                            task_user_regset_view(current),
1204                                            REGSET_GENERAL,
1205                                            0, sizeof(struct user_regs_struct),
1206                                            datap);
1207
1208         case PTRACE_SETREGS:    /* Set all gp regs in the child. */
1209                 return copy_regset_from_user(child,
1210                                              task_user_regset_view(current),
1211                                              REGSET_GENERAL,
1212                                              0, sizeof(struct user_regs_struct),
1213                                              datap);
1214
1215         case PTRACE_GETFPREGS:  /* Get the child FPU state. */
1216                 return copy_regset_to_user(child,
1217                                            task_user_regset_view(current),
1218                                            REGSET_FP,
1219                                            0, sizeof(struct user_i387_struct),
1220                                            datap);
1221
1222         case PTRACE_SETFPREGS:  /* Set the child FPU state. */
1223                 return copy_regset_from_user(child,
1224                                              task_user_regset_view(current),
1225                                              REGSET_FP,
1226                                              0, sizeof(struct user_i387_struct),
1227                                              datap);
1228
1229         default:
1230                 return compat_ptrace_request(child, request, addr, data);
1231         }
1232
1233         return ret;
1234 }
1235 #endif
1236
1237 #ifdef CONFIG_COMPAT
1238 long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
1239                         compat_ulong_t caddr, compat_ulong_t cdata)
1240 {
1241 #ifdef CONFIG_X86_X32_ABI
1242         if (!in_ia32_syscall())
1243                 return x32_arch_ptrace(child, request, caddr, cdata);
1244 #endif
1245 #ifdef CONFIG_IA32_EMULATION
1246         return ia32_arch_ptrace(child, request, caddr, cdata);
1247 #else
1248         return 0;
1249 #endif
1250 }
1251 #endif  /* CONFIG_COMPAT */
1252
1253 #ifdef CONFIG_X86_64
1254
1255 static struct user_regset x86_64_regsets[] __ro_after_init = {
1256         [REGSET_GENERAL] = {
1257                 .core_note_type = NT_PRSTATUS,
1258                 .n = sizeof(struct user_regs_struct) / sizeof(long),
1259                 .size = sizeof(long), .align = sizeof(long),
1260                 .get = genregs_get, .set = genregs_set
1261         },
1262         [REGSET_FP] = {
1263                 .core_note_type = NT_PRFPREG,
1264                 .n = sizeof(struct user_i387_struct) / sizeof(long),
1265                 .size = sizeof(long), .align = sizeof(long),
1266                 .active = regset_xregset_fpregs_active, .get = xfpregs_get, .set = xfpregs_set
1267         },
1268         [REGSET_XSTATE] = {
1269                 .core_note_type = NT_X86_XSTATE,
1270                 .size = sizeof(u64), .align = sizeof(u64),
1271                 .active = xstateregs_active, .get = xstateregs_get,
1272                 .set = xstateregs_set
1273         },
1274         [REGSET_IOPERM64] = {
1275                 .core_note_type = NT_386_IOPERM,
1276                 .n = IO_BITMAP_LONGS,
1277                 .size = sizeof(long), .align = sizeof(long),
1278                 .active = ioperm_active, .get = ioperm_get
1279         },
1280 };
1281
1282 static const struct user_regset_view user_x86_64_view = {
1283         .name = "x86_64", .e_machine = EM_X86_64,
1284         .regsets = x86_64_regsets, .n = ARRAY_SIZE(x86_64_regsets)
1285 };
1286
1287 #else  /* CONFIG_X86_32 */
1288
1289 #define user_regs_struct32      user_regs_struct
1290 #define genregs32_get           genregs_get
1291 #define genregs32_set           genregs_set
1292
1293 #endif  /* CONFIG_X86_64 */
1294
1295 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1296 static struct user_regset x86_32_regsets[] __ro_after_init = {
1297         [REGSET_GENERAL] = {
1298                 .core_note_type = NT_PRSTATUS,
1299                 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
1300                 .size = sizeof(u32), .align = sizeof(u32),
1301                 .get = genregs32_get, .set = genregs32_set
1302         },
1303         [REGSET_FP] = {
1304                 .core_note_type = NT_PRFPREG,
1305                 .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32),
1306                 .size = sizeof(u32), .align = sizeof(u32),
1307                 .active = regset_fpregs_active, .get = fpregs_get, .set = fpregs_set
1308         },
1309         [REGSET_XFP] = {
1310                 .core_note_type = NT_PRXFPREG,
1311                 .n = sizeof(struct user32_fxsr_struct) / sizeof(u32),
1312                 .size = sizeof(u32), .align = sizeof(u32),
1313                 .active = regset_xregset_fpregs_active, .get = xfpregs_get, .set = xfpregs_set
1314         },
1315         [REGSET_XSTATE] = {
1316                 .core_note_type = NT_X86_XSTATE,
1317                 .size = sizeof(u64), .align = sizeof(u64),
1318                 .active = xstateregs_active, .get = xstateregs_get,
1319                 .set = xstateregs_set
1320         },
1321         [REGSET_TLS] = {
1322                 .core_note_type = NT_386_TLS,
1323                 .n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN,
1324                 .size = sizeof(struct user_desc),
1325                 .align = sizeof(struct user_desc),
1326                 .active = regset_tls_active,
1327                 .get = regset_tls_get, .set = regset_tls_set
1328         },
1329         [REGSET_IOPERM32] = {
1330                 .core_note_type = NT_386_IOPERM,
1331                 .n = IO_BITMAP_BYTES / sizeof(u32),
1332                 .size = sizeof(u32), .align = sizeof(u32),
1333                 .active = ioperm_active, .get = ioperm_get
1334         },
1335 };
1336
1337 static const struct user_regset_view user_x86_32_view = {
1338         .name = "i386", .e_machine = EM_386,
1339         .regsets = x86_32_regsets, .n = ARRAY_SIZE(x86_32_regsets)
1340 };
1341 #endif
1342
1343 /*
1344  * This represents bytes 464..511 in the memory layout exported through
1345  * the REGSET_XSTATE interface.
1346  */
1347 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
1348
1349 void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
1350 {
1351 #ifdef CONFIG_X86_64
1352         x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
1353 #endif
1354 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1355         x86_32_regsets[REGSET_XSTATE].n = size / sizeof(u64);
1356 #endif
1357         xstate_fx_sw_bytes[USER_XSTATE_XCR0_WORD] = xstate_mask;
1358 }
1359
1360 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
1361 {
1362 #ifdef CONFIG_IA32_EMULATION
1363         if (!user_64bit_mode(task_pt_regs(task)))
1364 #endif
1365 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1366                 return &user_x86_32_view;
1367 #endif
1368 #ifdef CONFIG_X86_64
1369         return &user_x86_64_view;
1370 #endif
1371 }
1372
1373 static void fill_sigtrap_info(struct task_struct *tsk,
1374                                 struct pt_regs *regs,
1375                                 int error_code, int si_code,
1376                                 struct siginfo *info)
1377 {
1378         tsk->thread.trap_nr = X86_TRAP_DB;
1379         tsk->thread.error_code = error_code;
1380
1381         memset(info, 0, sizeof(*info));
1382         info->si_signo = SIGTRAP;
1383         info->si_code = si_code;
1384         info->si_addr = user_mode(regs) ? (void __user *)regs->ip : NULL;
1385 }
1386
1387 void user_single_step_siginfo(struct task_struct *tsk,
1388                                 struct pt_regs *regs,
1389                                 struct siginfo *info)
1390 {
1391         fill_sigtrap_info(tsk, regs, 0, TRAP_BRKPT, info);
1392 }
1393
1394 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
1395                                          int error_code, int si_code)
1396 {
1397         struct siginfo info;
1398
1399         fill_sigtrap_info(tsk, regs, error_code, si_code, &info);
1400         /* Send us the fake SIGTRAP */
1401         force_sig_info(SIGTRAP, &info, tsk);
1402 }