3e34b14e884657a20bf1d6b58e3da03e0419e4d6
[deliverable/linux.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 * BTS tracing
7 * Markus Metzger <markus.t.metzger@intel.com>, Dec 2007
8 */
9
10 #include <linux/kernel.h>
11 #include <linux/sched.h>
12 #include <linux/mm.h>
13 #include <linux/smp.h>
14 #include <linux/errno.h>
15 #include <linux/ptrace.h>
16 #include <linux/regset.h>
17 #include <linux/user.h>
18 #include <linux/elf.h>
19 #include <linux/security.h>
20 #include <linux/audit.h>
21 #include <linux/seccomp.h>
22 #include <linux/signal.h>
23
24 #include <asm/uaccess.h>
25 #include <asm/pgtable.h>
26 #include <asm/system.h>
27 #include <asm/processor.h>
28 #include <asm/i387.h>
29 #include <asm/debugreg.h>
30 #include <asm/ldt.h>
31 #include <asm/desc.h>
32 #include <asm/prctl.h>
33 #include <asm/proto.h>
34 #include <asm/ds.h>
35
36 #include "tls.h"
37
38 enum x86_regset {
39 REGSET_GENERAL,
40 REGSET_FP,
41 REGSET_XFP,
42 REGSET_TLS,
43 };
44
45 /*
46 * does not yet catch signals sent when the child dies.
47 * in exit.c or in signal.c.
48 */
49
50 /*
51 * Determines which flags the user has access to [1 = access, 0 = no access].
52 */
53 #define FLAG_MASK_32 ((unsigned long) \
54 (X86_EFLAGS_CF | X86_EFLAGS_PF | \
55 X86_EFLAGS_AF | X86_EFLAGS_ZF | \
56 X86_EFLAGS_SF | X86_EFLAGS_TF | \
57 X86_EFLAGS_DF | X86_EFLAGS_OF | \
58 X86_EFLAGS_RF | X86_EFLAGS_AC))
59
60 /*
61 * Determines whether a value may be installed in a segment register.
62 */
63 static inline bool invalid_selector(u16 value)
64 {
65 return unlikely(value != 0 && (value & SEGMENT_RPL_MASK) != USER_RPL);
66 }
67
68 #ifdef CONFIG_X86_32
69
70 #define FLAG_MASK FLAG_MASK_32
71
72 static long *pt_regs_access(struct pt_regs *regs, unsigned long regno)
73 {
74 BUILD_BUG_ON(offsetof(struct pt_regs, bx) != 0);
75 regno >>= 2;
76 if (regno > FS)
77 --regno;
78 return &regs->bx + regno;
79 }
80
81 static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
82 {
83 /*
84 * Returning the value truncates it to 16 bits.
85 */
86 unsigned int retval;
87 if (offset != offsetof(struct user_regs_struct, gs))
88 retval = *pt_regs_access(task_pt_regs(task), offset);
89 else {
90 retval = task->thread.gs;
91 if (task == current)
92 savesegment(gs, retval);
93 }
94 return retval;
95 }
96
97 static int set_segment_reg(struct task_struct *task,
98 unsigned long offset, u16 value)
99 {
100 /*
101 * The value argument was already truncated to 16 bits.
102 */
103 if (invalid_selector(value))
104 return -EIO;
105
106 if (offset != offsetof(struct user_regs_struct, gs))
107 *pt_regs_access(task_pt_regs(task), offset) = value;
108 else {
109 task->thread.gs = value;
110 if (task == current)
111 /*
112 * The user-mode %gs is not affected by
113 * kernel entry, so we must update the CPU.
114 */
115 loadsegment(gs, value);
116 }
117
118 return 0;
119 }
120
121 static unsigned long debugreg_addr_limit(struct task_struct *task)
122 {
123 return TASK_SIZE - 3;
124 }
125
126 #else /* CONFIG_X86_64 */
127
128 #define FLAG_MASK (FLAG_MASK_32 | X86_EFLAGS_NT)
129
130 static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long offset)
131 {
132 BUILD_BUG_ON(offsetof(struct pt_regs, r15) != 0);
133 return &regs->r15 + (offset / sizeof(regs->r15));
134 }
135
136 static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
137 {
138 /*
139 * Returning the value truncates it to 16 bits.
140 */
141 unsigned int seg;
142
143 switch (offset) {
144 case offsetof(struct user_regs_struct, fs):
145 if (task == current) {
146 /* Older gas can't assemble movq %?s,%r?? */
147 asm("movl %%fs,%0" : "=r" (seg));
148 return seg;
149 }
150 return task->thread.fsindex;
151 case offsetof(struct user_regs_struct, gs):
152 if (task == current) {
153 asm("movl %%gs,%0" : "=r" (seg));
154 return seg;
155 }
156 return task->thread.gsindex;
157 case offsetof(struct user_regs_struct, ds):
158 if (task == current) {
159 asm("movl %%ds,%0" : "=r" (seg));
160 return seg;
161 }
162 return task->thread.ds;
163 case offsetof(struct user_regs_struct, es):
164 if (task == current) {
165 asm("movl %%es,%0" : "=r" (seg));
166 return seg;
167 }
168 return task->thread.es;
169
170 case offsetof(struct user_regs_struct, cs):
171 case offsetof(struct user_regs_struct, ss):
172 break;
173 }
174 return *pt_regs_access(task_pt_regs(task), offset);
175 }
176
177 static int set_segment_reg(struct task_struct *task,
178 unsigned long offset, u16 value)
179 {
180 /*
181 * The value argument was already truncated to 16 bits.
182 */
183 if (invalid_selector(value))
184 return -EIO;
185
186 switch (offset) {
187 case offsetof(struct user_regs_struct,fs):
188 /*
189 * If this is setting fs as for normal 64-bit use but
190 * setting fs_base has implicitly changed it, leave it.
191 */
192 if ((value == FS_TLS_SEL && task->thread.fsindex == 0 &&
193 task->thread.fs != 0) ||
194 (value == 0 && task->thread.fsindex == FS_TLS_SEL &&
195 task->thread.fs == 0))
196 break;
197 task->thread.fsindex = value;
198 if (task == current)
199 loadsegment(fs, task->thread.fsindex);
200 break;
201 case offsetof(struct user_regs_struct,gs):
202 /*
203 * If this is setting gs as for normal 64-bit use but
204 * setting gs_base has implicitly changed it, leave it.
205 */
206 if ((value == GS_TLS_SEL && task->thread.gsindex == 0 &&
207 task->thread.gs != 0) ||
208 (value == 0 && task->thread.gsindex == GS_TLS_SEL &&
209 task->thread.gs == 0))
210 break;
211 task->thread.gsindex = value;
212 if (task == current)
213 load_gs_index(task->thread.gsindex);
214 break;
215 case offsetof(struct user_regs_struct,ds):
216 task->thread.ds = value;
217 if (task == current)
218 loadsegment(ds, task->thread.ds);
219 break;
220 case offsetof(struct user_regs_struct,es):
221 task->thread.es = value;
222 if (task == current)
223 loadsegment(es, task->thread.es);
224 break;
225
226 /*
227 * Can't actually change these in 64-bit mode.
228 */
229 case offsetof(struct user_regs_struct,cs):
230 #ifdef CONFIG_IA32_EMULATION
231 if (test_tsk_thread_flag(task, TIF_IA32))
232 task_pt_regs(task)->cs = value;
233 #endif
234 break;
235 case offsetof(struct user_regs_struct,ss):
236 #ifdef CONFIG_IA32_EMULATION
237 if (test_tsk_thread_flag(task, TIF_IA32))
238 task_pt_regs(task)->ss = value;
239 #endif
240 break;
241 }
242
243 return 0;
244 }
245
246 static unsigned long debugreg_addr_limit(struct task_struct *task)
247 {
248 #ifdef CONFIG_IA32_EMULATION
249 if (test_tsk_thread_flag(task, TIF_IA32))
250 return IA32_PAGE_OFFSET - 3;
251 #endif
252 return TASK_SIZE64 - 7;
253 }
254
255 #endif /* CONFIG_X86_32 */
256
257 static unsigned long get_flags(struct task_struct *task)
258 {
259 unsigned long retval = task_pt_regs(task)->flags;
260
261 /*
262 * If the debugger set TF, hide it from the readout.
263 */
264 if (test_tsk_thread_flag(task, TIF_FORCED_TF))
265 retval &= ~X86_EFLAGS_TF;
266
267 return retval;
268 }
269
270 static int set_flags(struct task_struct *task, unsigned long value)
271 {
272 struct pt_regs *regs = task_pt_regs(task);
273
274 /*
275 * If the user value contains TF, mark that
276 * it was not "us" (the debugger) that set it.
277 * If not, make sure it stays set if we had.
278 */
279 if (value & X86_EFLAGS_TF)
280 clear_tsk_thread_flag(task, TIF_FORCED_TF);
281 else if (test_tsk_thread_flag(task, TIF_FORCED_TF))
282 value |= X86_EFLAGS_TF;
283
284 regs->flags = (regs->flags & ~FLAG_MASK) | (value & FLAG_MASK);
285
286 return 0;
287 }
288
289 static int putreg(struct task_struct *child,
290 unsigned long offset, unsigned long value)
291 {
292 switch (offset) {
293 case offsetof(struct user_regs_struct, cs):
294 case offsetof(struct user_regs_struct, ds):
295 case offsetof(struct user_regs_struct, es):
296 case offsetof(struct user_regs_struct, fs):
297 case offsetof(struct user_regs_struct, gs):
298 case offsetof(struct user_regs_struct, ss):
299 return set_segment_reg(child, offset, value);
300
301 case offsetof(struct user_regs_struct, flags):
302 return set_flags(child, value);
303
304 #ifdef CONFIG_X86_64
305 case offsetof(struct user_regs_struct,fs_base):
306 if (value >= TASK_SIZE_OF(child))
307 return -EIO;
308 /*
309 * When changing the segment base, use do_arch_prctl
310 * to set either thread.fs or thread.fsindex and the
311 * corresponding GDT slot.
312 */
313 if (child->thread.fs != value)
314 return do_arch_prctl(child, ARCH_SET_FS, value);
315 return 0;
316 case offsetof(struct user_regs_struct,gs_base):
317 /*
318 * Exactly the same here as the %fs handling above.
319 */
320 if (value >= TASK_SIZE_OF(child))
321 return -EIO;
322 if (child->thread.gs != value)
323 return do_arch_prctl(child, ARCH_SET_GS, value);
324 return 0;
325 #endif
326 }
327
328 *pt_regs_access(task_pt_regs(child), offset) = value;
329 return 0;
330 }
331
332 static unsigned long getreg(struct task_struct *task, unsigned long offset)
333 {
334 switch (offset) {
335 case offsetof(struct user_regs_struct, cs):
336 case offsetof(struct user_regs_struct, ds):
337 case offsetof(struct user_regs_struct, es):
338 case offsetof(struct user_regs_struct, fs):
339 case offsetof(struct user_regs_struct, gs):
340 case offsetof(struct user_regs_struct, ss):
341 return get_segment_reg(task, offset);
342
343 case offsetof(struct user_regs_struct, flags):
344 return get_flags(task);
345
346 #ifdef CONFIG_X86_64
347 case offsetof(struct user_regs_struct, fs_base): {
348 /*
349 * do_arch_prctl may have used a GDT slot instead of
350 * the MSR. To userland, it appears the same either
351 * way, except the %fs segment selector might not be 0.
352 */
353 unsigned int seg = task->thread.fsindex;
354 if (task->thread.fs != 0)
355 return task->thread.fs;
356 if (task == current)
357 asm("movl %%fs,%0" : "=r" (seg));
358 if (seg != FS_TLS_SEL)
359 return 0;
360 return get_desc_base(&task->thread.tls_array[FS_TLS]);
361 }
362 case offsetof(struct user_regs_struct, gs_base): {
363 /*
364 * Exactly the same here as the %fs handling above.
365 */
366 unsigned int seg = task->thread.gsindex;
367 if (task->thread.gs != 0)
368 return task->thread.gs;
369 if (task == current)
370 asm("movl %%gs,%0" : "=r" (seg));
371 if (seg != GS_TLS_SEL)
372 return 0;
373 return get_desc_base(&task->thread.tls_array[GS_TLS]);
374 }
375 #endif
376 }
377
378 return *pt_regs_access(task_pt_regs(task), offset);
379 }
380
381 static int genregs_get(struct task_struct *target,
382 const struct user_regset *regset,
383 unsigned int pos, unsigned int count,
384 void *kbuf, void __user *ubuf)
385 {
386 if (kbuf) {
387 unsigned long *k = kbuf;
388 while (count > 0) {
389 *k++ = getreg(target, pos);
390 count -= sizeof(*k);
391 pos += sizeof(*k);
392 }
393 } else {
394 unsigned long __user *u = ubuf;
395 while (count > 0) {
396 if (__put_user(getreg(target, pos), u++))
397 return -EFAULT;
398 count -= sizeof(*u);
399 pos += sizeof(*u);
400 }
401 }
402
403 return 0;
404 }
405
406 static int genregs_set(struct task_struct *target,
407 const struct user_regset *regset,
408 unsigned int pos, unsigned int count,
409 const void *kbuf, const void __user *ubuf)
410 {
411 int ret = 0;
412 if (kbuf) {
413 const unsigned long *k = kbuf;
414 while (count > 0 && !ret) {
415 ret = putreg(target, pos, *k++);
416 count -= sizeof(*k);
417 pos += sizeof(*k);
418 }
419 } else {
420 const unsigned long __user *u = ubuf;
421 while (count > 0 && !ret) {
422 unsigned long word;
423 ret = __get_user(word, u++);
424 if (ret)
425 break;
426 ret = putreg(target, pos, word);
427 count -= sizeof(*u);
428 pos += sizeof(*u);
429 }
430 }
431 return ret;
432 }
433
434 /*
435 * This function is trivial and will be inlined by the compiler.
436 * Having it separates the implementation details of debug
437 * registers from the interface details of ptrace.
438 */
439 static unsigned long ptrace_get_debugreg(struct task_struct *child, int n)
440 {
441 switch (n) {
442 case 0: return child->thread.debugreg0;
443 case 1: return child->thread.debugreg1;
444 case 2: return child->thread.debugreg2;
445 case 3: return child->thread.debugreg3;
446 case 6: return child->thread.debugreg6;
447 case 7: return child->thread.debugreg7;
448 }
449 return 0;
450 }
451
452 static int ptrace_set_debugreg(struct task_struct *child,
453 int n, unsigned long data)
454 {
455 int i;
456
457 if (unlikely(n == 4 || n == 5))
458 return -EIO;
459
460 if (n < 4 && unlikely(data >= debugreg_addr_limit(child)))
461 return -EIO;
462
463 switch (n) {
464 case 0: child->thread.debugreg0 = data; break;
465 case 1: child->thread.debugreg1 = data; break;
466 case 2: child->thread.debugreg2 = data; break;
467 case 3: child->thread.debugreg3 = data; break;
468
469 case 6:
470 if ((data & ~0xffffffffUL) != 0)
471 return -EIO;
472 child->thread.debugreg6 = data;
473 break;
474
475 case 7:
476 /*
477 * Sanity-check data. Take one half-byte at once with
478 * check = (val >> (16 + 4*i)) & 0xf. It contains the
479 * R/Wi and LENi bits; bits 0 and 1 are R/Wi, and bits
480 * 2 and 3 are LENi. Given a list of invalid values,
481 * we do mask |= 1 << invalid_value, so that
482 * (mask >> check) & 1 is a correct test for invalid
483 * values.
484 *
485 * R/Wi contains the type of the breakpoint /
486 * watchpoint, LENi contains the length of the watched
487 * data in the watchpoint case.
488 *
489 * The invalid values are:
490 * - LENi == 0x10 (undefined), so mask |= 0x0f00. [32-bit]
491 * - R/Wi == 0x10 (break on I/O reads or writes), so
492 * mask |= 0x4444.
493 * - R/Wi == 0x00 && LENi != 0x00, so we have mask |=
494 * 0x1110.
495 *
496 * Finally, mask = 0x0f00 | 0x4444 | 0x1110 == 0x5f54.
497 *
498 * See the Intel Manual "System Programming Guide",
499 * 15.2.4
500 *
501 * Note that LENi == 0x10 is defined on x86_64 in long
502 * mode (i.e. even for 32-bit userspace software, but
503 * 64-bit kernel), so the x86_64 mask value is 0x5454.
504 * See the AMD manual no. 24593 (AMD64 System Programming)
505 */
506 #ifdef CONFIG_X86_32
507 #define DR7_MASK 0x5f54
508 #else
509 #define DR7_MASK 0x5554
510 #endif
511 data &= ~DR_CONTROL_RESERVED;
512 for (i = 0; i < 4; i++)
513 if ((DR7_MASK >> ((data >> (16 + 4*i)) & 0xf)) & 1)
514 return -EIO;
515 child->thread.debugreg7 = data;
516 if (data)
517 set_tsk_thread_flag(child, TIF_DEBUG);
518 else
519 clear_tsk_thread_flag(child, TIF_DEBUG);
520 break;
521 }
522
523 return 0;
524 }
525
526 static int ptrace_bts_get_size(struct task_struct *child)
527 {
528 if (!child->thread.ds_area_msr)
529 return -ENXIO;
530
531 return ds_get_bts_index((void *)child->thread.ds_area_msr);
532 }
533
534 static int ptrace_bts_read_record(struct task_struct *child,
535 long index,
536 struct bts_struct __user *out)
537 {
538 struct bts_struct ret;
539 int retval;
540 int bts_end;
541 int bts_index;
542
543 if (!child->thread.ds_area_msr)
544 return -ENXIO;
545
546 if (index < 0)
547 return -EINVAL;
548
549 bts_end = ds_get_bts_end((void *)child->thread.ds_area_msr);
550 if (bts_end <= index)
551 return -EINVAL;
552
553 /* translate the ptrace bts index into the ds bts index */
554 bts_index = ds_get_bts_index((void *)child->thread.ds_area_msr);
555 bts_index -= (index + 1);
556 if (bts_index < 0)
557 bts_index += bts_end;
558
559 retval = ds_read_bts((void *)child->thread.ds_area_msr,
560 bts_index, &ret);
561 if (retval)
562 return retval;
563
564 if (copy_to_user(out, &ret, sizeof(ret)))
565 return -EFAULT;
566
567 return sizeof(ret);
568 }
569
570 static int ptrace_bts_write_record(struct task_struct *child,
571 const struct bts_struct *in)
572 {
573 int retval;
574
575 if (!child->thread.ds_area_msr)
576 return -ENXIO;
577
578 retval = ds_write_bts((void *)child->thread.ds_area_msr, in);
579 if (retval)
580 return retval;
581
582 return sizeof(*in);
583 }
584
585 static int ptrace_bts_clear(struct task_struct *child)
586 {
587 if (!child->thread.ds_area_msr)
588 return -ENXIO;
589
590 return ds_clear((void *)child->thread.ds_area_msr);
591 }
592
593 static int ptrace_bts_drain(struct task_struct *child,
594 struct bts_struct __user *out)
595 {
596 int end, i;
597 void *ds = (void *)child->thread.ds_area_msr;
598
599 if (!ds)
600 return -ENXIO;
601
602 end = ds_get_bts_index(ds);
603 if (end <= 0)
604 return end;
605
606 for (i = 0; i < end; i++, out++) {
607 struct bts_struct ret;
608 int retval;
609
610 retval = ds_read_bts(ds, i, &ret);
611 if (retval < 0)
612 return retval;
613
614 if (copy_to_user(out, &ret, sizeof(ret)))
615 return -EFAULT;
616 }
617
618 ds_clear(ds);
619
620 return i;
621 }
622
623 static int ptrace_bts_config(struct task_struct *child,
624 const struct ptrace_bts_config __user *ucfg)
625 {
626 struct ptrace_bts_config cfg;
627 unsigned long debugctl_mask;
628 int bts_size, ret;
629 void *ds;
630
631 if (copy_from_user(&cfg, ucfg, sizeof(cfg)))
632 return -EFAULT;
633
634 bts_size = 0;
635 ds = (void *)child->thread.ds_area_msr;
636 if (ds) {
637 bts_size = ds_get_bts_size(ds);
638 if (bts_size < 0)
639 return bts_size;
640 }
641
642 if (bts_size != cfg.size) {
643 ret = ds_free((void **)&child->thread.ds_area_msr);
644 if (ret < 0)
645 return ret;
646
647 if (cfg.size > 0)
648 ret = ds_allocate((void **)&child->thread.ds_area_msr,
649 cfg.size);
650 ds = (void *)child->thread.ds_area_msr;
651 if (ds)
652 set_tsk_thread_flag(child, TIF_DS_AREA_MSR);
653 else
654 clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);
655
656 if (ret < 0)
657 return ret;
658
659 bts_size = ds_get_bts_size(ds);
660 if (bts_size <= 0)
661 return bts_size;
662 }
663
664 if (ds) {
665 if (cfg.flags & PTRACE_BTS_O_SIGNAL) {
666 ret = ds_set_overflow(ds, DS_O_SIGNAL);
667 } else {
668 ret = ds_set_overflow(ds, DS_O_WRAP);
669 }
670 if (ret < 0)
671 return ret;
672 }
673
674 debugctl_mask = ds_debugctl_mask();
675 if (ds && (cfg.flags & PTRACE_BTS_O_TRACE)) {
676 child->thread.debugctlmsr |= debugctl_mask;
677 set_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
678 } else {
679 /* there is no way for us to check whether we 'own'
680 * the respective bits in the DEBUGCTL MSR, we're
681 * about to clear */
682 child->thread.debugctlmsr &= ~debugctl_mask;
683
684 if (!child->thread.debugctlmsr)
685 clear_tsk_thread_flag(child, TIF_DEBUGCTLMSR);
686 }
687
688 if (ds && (cfg.flags & PTRACE_BTS_O_SCHED))
689 set_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
690 else
691 clear_tsk_thread_flag(child, TIF_BTS_TRACE_TS);
692
693 return 0;
694 }
695
696 static int ptrace_bts_status(struct task_struct *child,
697 struct ptrace_bts_config __user *ucfg)
698 {
699 void *ds = (void *)child->thread.ds_area_msr;
700 struct ptrace_bts_config cfg;
701
702 memset(&cfg, 0, sizeof(cfg));
703
704 if (ds) {
705 cfg.size = ds_get_bts_size(ds);
706
707 if (ds_get_overflow(ds) == DS_O_SIGNAL)
708 cfg.flags |= PTRACE_BTS_O_SIGNAL;
709
710 if (test_tsk_thread_flag(child, TIF_DEBUGCTLMSR) &&
711 child->thread.debugctlmsr & ds_debugctl_mask())
712 cfg.flags |= PTRACE_BTS_O_TRACE;
713
714 if (test_tsk_thread_flag(child, TIF_BTS_TRACE_TS))
715 cfg.flags |= PTRACE_BTS_O_SCHED;
716 }
717
718 if (copy_to_user(ucfg, &cfg, sizeof(cfg)))
719 return -EFAULT;
720
721 return sizeof(cfg);
722 }
723
724 void ptrace_bts_take_timestamp(struct task_struct *tsk,
725 enum bts_qualifier qualifier)
726 {
727 struct bts_struct rec = {
728 .qualifier = qualifier,
729 .variant.jiffies = jiffies
730 };
731
732 ptrace_bts_write_record(tsk, &rec);
733 }
734
735 /*
736 * Called by kernel/ptrace.c when detaching..
737 *
738 * Make sure the single step bit is not set.
739 */
740 void ptrace_disable(struct task_struct *child)
741 {
742 user_disable_single_step(child);
743 #ifdef TIF_SYSCALL_EMU
744 clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
745 #endif
746 ptrace_bts_config(child, /* options = */ 0);
747 if (child->thread.ds_area_msr) {
748 ds_free((void **)&child->thread.ds_area_msr);
749 clear_tsk_thread_flag(child, TIF_DS_AREA_MSR);
750 }
751 }
752
753 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
754 static const struct user_regset_view user_x86_32_view; /* Initialized below. */
755 #endif
756
757 long arch_ptrace(struct task_struct *child, long request, long addr, long data)
758 {
759 int ret;
760 unsigned long __user *datap = (unsigned long __user *)data;
761
762 switch (request) {
763 /* read the word at location addr in the USER area. */
764 case PTRACE_PEEKUSR: {
765 unsigned long tmp;
766
767 ret = -EIO;
768 if ((addr & (sizeof(data) - 1)) || addr < 0 ||
769 addr >= sizeof(struct user))
770 break;
771
772 tmp = 0; /* Default return condition */
773 if (addr < sizeof(struct user_regs_struct))
774 tmp = getreg(child, addr);
775 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
776 addr <= offsetof(struct user, u_debugreg[7])) {
777 addr -= offsetof(struct user, u_debugreg[0]);
778 tmp = ptrace_get_debugreg(child, addr / sizeof(data));
779 }
780 ret = put_user(tmp, datap);
781 break;
782 }
783
784 case PTRACE_POKEUSR: /* write the word at location addr in the USER area */
785 ret = -EIO;
786 if ((addr & (sizeof(data) - 1)) || addr < 0 ||
787 addr >= sizeof(struct user))
788 break;
789
790 if (addr < sizeof(struct user_regs_struct))
791 ret = putreg(child, addr, data);
792 else if (addr >= offsetof(struct user, u_debugreg[0]) &&
793 addr <= offsetof(struct user, u_debugreg[7])) {
794 addr -= offsetof(struct user, u_debugreg[0]);
795 ret = ptrace_set_debugreg(child,
796 addr / sizeof(data), data);
797 }
798 break;
799
800 case PTRACE_GETREGS: /* Get all gp regs from the child. */
801 return copy_regset_to_user(child,
802 task_user_regset_view(current),
803 REGSET_GENERAL,
804 0, sizeof(struct user_regs_struct),
805 datap);
806
807 case PTRACE_SETREGS: /* Set all gp regs in the child. */
808 return copy_regset_from_user(child,
809 task_user_regset_view(current),
810 REGSET_GENERAL,
811 0, sizeof(struct user_regs_struct),
812 datap);
813
814 case PTRACE_GETFPREGS: /* Get the child FPU state. */
815 return copy_regset_to_user(child,
816 task_user_regset_view(current),
817 REGSET_FP,
818 0, sizeof(struct user_i387_struct),
819 datap);
820
821 case PTRACE_SETFPREGS: /* Set the child FPU state. */
822 return copy_regset_from_user(child,
823 task_user_regset_view(current),
824 REGSET_FP,
825 0, sizeof(struct user_i387_struct),
826 datap);
827
828 #ifdef CONFIG_X86_32
829 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
830 return copy_regset_to_user(child, &user_x86_32_view,
831 REGSET_XFP,
832 0, sizeof(struct user_fxsr_struct),
833 datap);
834
835 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
836 return copy_regset_from_user(child, &user_x86_32_view,
837 REGSET_XFP,
838 0, sizeof(struct user_fxsr_struct),
839 datap);
840 #endif
841
842 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
843 case PTRACE_GET_THREAD_AREA:
844 if (addr < 0)
845 return -EIO;
846 ret = do_get_thread_area(child, addr,
847 (struct user_desc __user *) data);
848 break;
849
850 case PTRACE_SET_THREAD_AREA:
851 if (addr < 0)
852 return -EIO;
853 ret = do_set_thread_area(child, addr,
854 (struct user_desc __user *) data, 0);
855 break;
856 #endif
857
858 #ifdef CONFIG_X86_64
859 /* normal 64bit interface to access TLS data.
860 Works just like arch_prctl, except that the arguments
861 are reversed. */
862 case PTRACE_ARCH_PRCTL:
863 ret = do_arch_prctl(child, data, addr);
864 break;
865 #endif
866
867 case PTRACE_BTS_CONFIG:
868 ret = ptrace_bts_config
869 (child, (struct ptrace_bts_config __user *)addr);
870 break;
871
872 case PTRACE_BTS_STATUS:
873 ret = ptrace_bts_status
874 (child, (struct ptrace_bts_config __user *)addr);
875 break;
876
877 case PTRACE_BTS_SIZE:
878 ret = ptrace_bts_get_size(child);
879 break;
880
881 case PTRACE_BTS_GET:
882 ret = ptrace_bts_read_record
883 (child, data, (struct bts_struct __user *) addr);
884 break;
885
886 case PTRACE_BTS_CLEAR:
887 ret = ptrace_bts_clear(child);
888 break;
889
890 case PTRACE_BTS_DRAIN:
891 ret = ptrace_bts_drain
892 (child, (struct bts_struct __user *) addr);
893 break;
894
895 default:
896 ret = ptrace_request(child, request, addr, data);
897 break;
898 }
899
900 return ret;
901 }
902
903 #ifdef CONFIG_IA32_EMULATION
904
905 #include <linux/compat.h>
906 #include <linux/syscalls.h>
907 #include <asm/ia32.h>
908 #include <asm/user32.h>
909
910 #define R32(l,q) \
911 case offsetof(struct user32, regs.l): \
912 regs->q = value; break
913
914 #define SEG32(rs) \
915 case offsetof(struct user32, regs.rs): \
916 return set_segment_reg(child, \
917 offsetof(struct user_regs_struct, rs), \
918 value); \
919 break
920
921 static int putreg32(struct task_struct *child, unsigned regno, u32 value)
922 {
923 struct pt_regs *regs = task_pt_regs(child);
924
925 switch (regno) {
926
927 SEG32(cs);
928 SEG32(ds);
929 SEG32(es);
930 SEG32(fs);
931 SEG32(gs);
932 SEG32(ss);
933
934 R32(ebx, bx);
935 R32(ecx, cx);
936 R32(edx, dx);
937 R32(edi, di);
938 R32(esi, si);
939 R32(ebp, bp);
940 R32(eax, ax);
941 R32(orig_eax, orig_ax);
942 R32(eip, ip);
943 R32(esp, sp);
944
945 case offsetof(struct user32, regs.eflags):
946 return set_flags(child, value);
947
948 case offsetof(struct user32, u_debugreg[0]) ...
949 offsetof(struct user32, u_debugreg[7]):
950 regno -= offsetof(struct user32, u_debugreg[0]);
951 return ptrace_set_debugreg(child, regno / 4, value);
952
953 default:
954 if (regno > sizeof(struct user32) || (regno & 3))
955 return -EIO;
956
957 /*
958 * Other dummy fields in the virtual user structure
959 * are ignored
960 */
961 break;
962 }
963 return 0;
964 }
965
966 #undef R32
967 #undef SEG32
968
969 #define R32(l,q) \
970 case offsetof(struct user32, regs.l): \
971 *val = regs->q; break
972
973 #define SEG32(rs) \
974 case offsetof(struct user32, regs.rs): \
975 *val = get_segment_reg(child, \
976 offsetof(struct user_regs_struct, rs)); \
977 break
978
979 static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
980 {
981 struct pt_regs *regs = task_pt_regs(child);
982
983 switch (regno) {
984
985 SEG32(ds);
986 SEG32(es);
987 SEG32(fs);
988 SEG32(gs);
989
990 R32(cs, cs);
991 R32(ss, ss);
992 R32(ebx, bx);
993 R32(ecx, cx);
994 R32(edx, dx);
995 R32(edi, di);
996 R32(esi, si);
997 R32(ebp, bp);
998 R32(eax, ax);
999 R32(orig_eax, orig_ax);
1000 R32(eip, ip);
1001 R32(esp, sp);
1002
1003 case offsetof(struct user32, regs.eflags):
1004 *val = get_flags(child);
1005 break;
1006
1007 case offsetof(struct user32, u_debugreg[0]) ...
1008 offsetof(struct user32, u_debugreg[7]):
1009 regno -= offsetof(struct user32, u_debugreg[0]);
1010 *val = ptrace_get_debugreg(child, regno / 4);
1011 break;
1012
1013 default:
1014 if (regno > sizeof(struct user32) || (regno & 3))
1015 return -EIO;
1016
1017 /*
1018 * Other dummy fields in the virtual user structure
1019 * are ignored
1020 */
1021 *val = 0;
1022 break;
1023 }
1024 return 0;
1025 }
1026
1027 #undef R32
1028 #undef SEG32
1029
1030 static int genregs32_get(struct task_struct *target,
1031 const struct user_regset *regset,
1032 unsigned int pos, unsigned int count,
1033 void *kbuf, void __user *ubuf)
1034 {
1035 if (kbuf) {
1036 compat_ulong_t *k = kbuf;
1037 while (count > 0) {
1038 getreg32(target, pos, k++);
1039 count -= sizeof(*k);
1040 pos += sizeof(*k);
1041 }
1042 } else {
1043 compat_ulong_t __user *u = ubuf;
1044 while (count > 0) {
1045 compat_ulong_t word;
1046 getreg32(target, pos, &word);
1047 if (__put_user(word, u++))
1048 return -EFAULT;
1049 count -= sizeof(*u);
1050 pos += sizeof(*u);
1051 }
1052 }
1053
1054 return 0;
1055 }
1056
1057 static int genregs32_set(struct task_struct *target,
1058 const struct user_regset *regset,
1059 unsigned int pos, unsigned int count,
1060 const void *kbuf, const void __user *ubuf)
1061 {
1062 int ret = 0;
1063 if (kbuf) {
1064 const compat_ulong_t *k = kbuf;
1065 while (count > 0 && !ret) {
1066 ret = putreg(target, pos, *k++);
1067 count -= sizeof(*k);
1068 pos += sizeof(*k);
1069 }
1070 } else {
1071 const compat_ulong_t __user *u = ubuf;
1072 while (count > 0 && !ret) {
1073 compat_ulong_t word;
1074 ret = __get_user(word, u++);
1075 if (ret)
1076 break;
1077 ret = putreg(target, pos, word);
1078 count -= sizeof(*u);
1079 pos += sizeof(*u);
1080 }
1081 }
1082 return ret;
1083 }
1084
1085 static long ptrace32_siginfo(unsigned request, u32 pid, u32 addr, u32 data)
1086 {
1087 siginfo_t __user *si = compat_alloc_user_space(sizeof(siginfo_t));
1088 compat_siginfo_t __user *si32 = compat_ptr(data);
1089 siginfo_t ssi;
1090 int ret;
1091
1092 if (request == PTRACE_SETSIGINFO) {
1093 memset(&ssi, 0, sizeof(siginfo_t));
1094 ret = copy_siginfo_from_user32(&ssi, si32);
1095 if (ret)
1096 return ret;
1097 if (copy_to_user(si, &ssi, sizeof(siginfo_t)))
1098 return -EFAULT;
1099 }
1100 ret = sys_ptrace(request, pid, addr, (unsigned long)si);
1101 if (ret)
1102 return ret;
1103 if (request == PTRACE_GETSIGINFO) {
1104 if (copy_from_user(&ssi, si, sizeof(siginfo_t)))
1105 return -EFAULT;
1106 ret = copy_siginfo_to_user32(si32, &ssi);
1107 }
1108 return ret;
1109 }
1110
1111 asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data)
1112 {
1113 struct task_struct *child;
1114 struct pt_regs *childregs;
1115 void __user *datap = compat_ptr(data);
1116 int ret;
1117 __u32 val;
1118
1119 switch (request) {
1120 case PTRACE_TRACEME:
1121 case PTRACE_ATTACH:
1122 case PTRACE_KILL:
1123 case PTRACE_CONT:
1124 case PTRACE_SINGLESTEP:
1125 case PTRACE_SINGLEBLOCK:
1126 case PTRACE_DETACH:
1127 case PTRACE_SYSCALL:
1128 case PTRACE_OLDSETOPTIONS:
1129 case PTRACE_SETOPTIONS:
1130 case PTRACE_SET_THREAD_AREA:
1131 case PTRACE_GET_THREAD_AREA:
1132 case PTRACE_BTS_CONFIG:
1133 case PTRACE_BTS_STATUS:
1134 case PTRACE_BTS_SIZE:
1135 case PTRACE_BTS_GET:
1136 case PTRACE_BTS_CLEAR:
1137 case PTRACE_BTS_DRAIN:
1138 return sys_ptrace(request, pid, addr, data);
1139
1140 default:
1141 return -EINVAL;
1142
1143 case PTRACE_PEEKTEXT:
1144 case PTRACE_PEEKDATA:
1145 case PTRACE_POKEDATA:
1146 case PTRACE_POKETEXT:
1147 case PTRACE_POKEUSR:
1148 case PTRACE_PEEKUSR:
1149 case PTRACE_GETREGS:
1150 case PTRACE_SETREGS:
1151 case PTRACE_SETFPREGS:
1152 case PTRACE_GETFPREGS:
1153 case PTRACE_SETFPXREGS:
1154 case PTRACE_GETFPXREGS:
1155 case PTRACE_GETEVENTMSG:
1156 break;
1157
1158 case PTRACE_SETSIGINFO:
1159 case PTRACE_GETSIGINFO:
1160 return ptrace32_siginfo(request, pid, addr, data);
1161 }
1162
1163 child = ptrace_get_task_struct(pid);
1164 if (IS_ERR(child))
1165 return PTR_ERR(child);
1166
1167 ret = ptrace_check_attach(child, request == PTRACE_KILL);
1168 if (ret < 0)
1169 goto out;
1170
1171 childregs = task_pt_regs(child);
1172
1173 switch (request) {
1174 case PTRACE_PEEKUSR:
1175 ret = getreg32(child, addr, &val);
1176 if (ret == 0)
1177 ret = put_user(val, (__u32 __user *)datap);
1178 break;
1179
1180 case PTRACE_POKEUSR:
1181 ret = putreg32(child, addr, data);
1182 break;
1183
1184 case PTRACE_GETREGS: /* Get all gp regs from the child. */
1185 return copy_regset_to_user(child, &user_x86_32_view,
1186 REGSET_GENERAL,
1187 0, sizeof(struct user_regs_struct32),
1188 datap);
1189
1190 case PTRACE_SETREGS: /* Set all gp regs in the child. */
1191 return copy_regset_from_user(child, &user_x86_32_view,
1192 REGSET_GENERAL, 0,
1193 sizeof(struct user_regs_struct32),
1194 datap);
1195
1196 case PTRACE_GETFPREGS: /* Get the child FPU state. */
1197 return copy_regset_to_user(child, &user_x86_32_view,
1198 REGSET_FP, 0,
1199 sizeof(struct user_i387_ia32_struct),
1200 datap);
1201
1202 case PTRACE_SETFPREGS: /* Set the child FPU state. */
1203 return copy_regset_from_user(
1204 child, &user_x86_32_view, REGSET_FP,
1205 0, sizeof(struct user_i387_ia32_struct), datap);
1206
1207 case PTRACE_GETFPXREGS: /* Get the child extended FPU state. */
1208 return copy_regset_to_user(child, &user_x86_32_view,
1209 REGSET_XFP, 0,
1210 sizeof(struct user32_fxsr_struct),
1211 datap);
1212
1213 case PTRACE_SETFPXREGS: /* Set the child extended FPU state. */
1214 return copy_regset_from_user(child, &user_x86_32_view,
1215 REGSET_XFP, 0,
1216 sizeof(struct user32_fxsr_struct),
1217 datap);
1218
1219 default:
1220 return compat_ptrace_request(child, request, addr, data);
1221 }
1222
1223 out:
1224 put_task_struct(child);
1225 return ret;
1226 }
1227
1228 #endif /* CONFIG_IA32_EMULATION */
1229
1230 #ifdef CONFIG_X86_64
1231
1232 static const struct user_regset x86_64_regsets[] = {
1233 [REGSET_GENERAL] = {
1234 .core_note_type = NT_PRSTATUS,
1235 .n = sizeof(struct user_regs_struct) / sizeof(long),
1236 .size = sizeof(long), .align = sizeof(long),
1237 .get = genregs_get, .set = genregs_set
1238 },
1239 [REGSET_FP] = {
1240 .core_note_type = NT_PRFPREG,
1241 .n = sizeof(struct user_i387_struct) / sizeof(long),
1242 .size = sizeof(long), .align = sizeof(long),
1243 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1244 },
1245 };
1246
1247 static const struct user_regset_view user_x86_64_view = {
1248 .name = "x86_64", .e_machine = EM_X86_64,
1249 .regsets = x86_64_regsets, .n = ARRAY_SIZE(x86_64_regsets)
1250 };
1251
1252 #else /* CONFIG_X86_32 */
1253
1254 #define user_regs_struct32 user_regs_struct
1255 #define genregs32_get genregs_get
1256 #define genregs32_set genregs_set
1257
1258 #endif /* CONFIG_X86_64 */
1259
1260 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1261 static const struct user_regset x86_32_regsets[] = {
1262 [REGSET_GENERAL] = {
1263 .core_note_type = NT_PRSTATUS,
1264 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
1265 .size = sizeof(u32), .align = sizeof(u32),
1266 .get = genregs32_get, .set = genregs32_set
1267 },
1268 [REGSET_FP] = {
1269 .core_note_type = NT_PRFPREG,
1270 .n = sizeof(struct user_i387_struct) / sizeof(u32),
1271 .size = sizeof(u32), .align = sizeof(u32),
1272 .active = fpregs_active, .get = fpregs_get, .set = fpregs_set
1273 },
1274 [REGSET_XFP] = {
1275 .core_note_type = NT_PRXFPREG,
1276 .n = sizeof(struct user_i387_struct) / sizeof(u32),
1277 .size = sizeof(u32), .align = sizeof(u32),
1278 .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
1279 },
1280 [REGSET_TLS] = {
1281 .core_note_type = NT_386_TLS,
1282 .n = GDT_ENTRY_TLS_ENTRIES, .bias = GDT_ENTRY_TLS_MIN,
1283 .size = sizeof(struct user_desc),
1284 .align = sizeof(struct user_desc),
1285 .active = regset_tls_active,
1286 .get = regset_tls_get, .set = regset_tls_set
1287 },
1288 };
1289
1290 static const struct user_regset_view user_x86_32_view = {
1291 .name = "i386", .e_machine = EM_386,
1292 .regsets = x86_32_regsets, .n = ARRAY_SIZE(x86_32_regsets)
1293 };
1294 #endif
1295
1296 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
1297 {
1298 #ifdef CONFIG_IA32_EMULATION
1299 if (test_tsk_thread_flag(task, TIF_IA32))
1300 #endif
1301 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
1302 return &user_x86_32_view;
1303 #endif
1304 #ifdef CONFIG_X86_64
1305 return &user_x86_64_view;
1306 #endif
1307 }
1308
1309 #ifdef CONFIG_X86_32
1310
1311 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
1312 {
1313 struct siginfo info;
1314
1315 tsk->thread.trap_no = 1;
1316 tsk->thread.error_code = error_code;
1317
1318 memset(&info, 0, sizeof(info));
1319 info.si_signo = SIGTRAP;
1320 info.si_code = TRAP_BRKPT;
1321
1322 /* User-mode ip? */
1323 info.si_addr = user_mode_vm(regs) ? (void __user *) regs->ip : NULL;
1324
1325 /* Send us the fake SIGTRAP */
1326 force_sig_info(SIGTRAP, &info, tsk);
1327 }
1328
1329 /* notification of system call entry/exit
1330 * - triggered by current->work.syscall_trace
1331 */
1332 __attribute__((regparm(3)))
1333 int do_syscall_trace(struct pt_regs *regs, int entryexit)
1334 {
1335 int is_sysemu = test_thread_flag(TIF_SYSCALL_EMU);
1336 /*
1337 * With TIF_SYSCALL_EMU set we want to ignore TIF_SINGLESTEP for syscall
1338 * interception
1339 */
1340 int is_singlestep = !is_sysemu && test_thread_flag(TIF_SINGLESTEP);
1341 int ret = 0;
1342
1343 /* do the secure computing check first */
1344 if (!entryexit)
1345 secure_computing(regs->orig_ax);
1346
1347 if (unlikely(current->audit_context)) {
1348 if (entryexit)
1349 audit_syscall_exit(AUDITSC_RESULT(regs->ax),
1350 regs->ax);
1351 /* Debug traps, when using PTRACE_SINGLESTEP, must be sent only
1352 * on the syscall exit path. Normally, when TIF_SYSCALL_AUDIT is
1353 * not used, entry.S will call us only on syscall exit, not
1354 * entry; so when TIF_SYSCALL_AUDIT is used we must avoid
1355 * calling send_sigtrap() on syscall entry.
1356 *
1357 * Note that when PTRACE_SYSEMU_SINGLESTEP is used,
1358 * is_singlestep is false, despite his name, so we will still do
1359 * the correct thing.
1360 */
1361 else if (is_singlestep)
1362 goto out;
1363 }
1364
1365 if (!(current->ptrace & PT_PTRACED))
1366 goto out;
1367
1368 /* If a process stops on the 1st tracepoint with SYSCALL_TRACE
1369 * and then is resumed with SYSEMU_SINGLESTEP, it will come in
1370 * here. We have to check this and return */
1371 if (is_sysemu && entryexit)
1372 return 0;
1373
1374 /* Fake a debug trap */
1375 if (is_singlestep)
1376 send_sigtrap(current, regs, 0);
1377
1378 if (!test_thread_flag(TIF_SYSCALL_TRACE) && !is_sysemu)
1379 goto out;
1380
1381 /* the 0x80 provides a way for the tracing parent to distinguish
1382 between a syscall stop and SIGTRAP delivery */
1383 /* Note that the debugger could change the result of test_thread_flag!*/
1384 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) ? 0x80:0));
1385
1386 /*
1387 * this isn't the same as continuing with a signal, but it will do
1388 * for normal use. strace only continues with a signal if the
1389 * stopping signal is not SIGTRAP. -brl
1390 */
1391 if (current->exit_code) {
1392 send_sig(current->exit_code, current, 1);
1393 current->exit_code = 0;
1394 }
1395 ret = is_sysemu;
1396 out:
1397 if (unlikely(current->audit_context) && !entryexit)
1398 audit_syscall_entry(AUDIT_ARCH_I386, regs->orig_ax,
1399 regs->bx, regs->cx, regs->dx, regs->si);
1400 if (ret == 0)
1401 return 0;
1402
1403 regs->orig_ax = -1; /* force skip of syscall restarting */
1404 if (unlikely(current->audit_context))
1405 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
1406 return 1;
1407 }
1408
1409 #else /* CONFIG_X86_64 */
1410
1411 static void syscall_trace(struct pt_regs *regs)
1412 {
1413
1414 #if 0
1415 printk("trace %s ip %lx sp %lx ax %d origrax %d caller %lx tiflags %x ptrace %x\n",
1416 current->comm,
1417 regs->ip, regs->sp, regs->ax, regs->orig_ax, __builtin_return_address(0),
1418 current_thread_info()->flags, current->ptrace);
1419 #endif
1420
1421 ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
1422 ? 0x80 : 0));
1423 /*
1424 * this isn't the same as continuing with a signal, but it will do
1425 * for normal use. strace only continues with a signal if the
1426 * stopping signal is not SIGTRAP. -brl
1427 */
1428 if (current->exit_code) {
1429 send_sig(current->exit_code, current, 1);
1430 current->exit_code = 0;
1431 }
1432 }
1433
1434 asmlinkage void syscall_trace_enter(struct pt_regs *regs)
1435 {
1436 /* do the secure computing check first */
1437 secure_computing(regs->orig_ax);
1438
1439 if (test_thread_flag(TIF_SYSCALL_TRACE)
1440 && (current->ptrace & PT_PTRACED))
1441 syscall_trace(regs);
1442
1443 if (unlikely(current->audit_context)) {
1444 if (test_thread_flag(TIF_IA32)) {
1445 audit_syscall_entry(AUDIT_ARCH_I386,
1446 regs->orig_ax,
1447 regs->bx, regs->cx,
1448 regs->dx, regs->si);
1449 } else {
1450 audit_syscall_entry(AUDIT_ARCH_X86_64,
1451 regs->orig_ax,
1452 regs->di, regs->si,
1453 regs->dx, regs->r10);
1454 }
1455 }
1456 }
1457
1458 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
1459 {
1460 if (unlikely(current->audit_context))
1461 audit_syscall_exit(AUDITSC_RESULT(regs->ax), regs->ax);
1462
1463 if ((test_thread_flag(TIF_SYSCALL_TRACE)
1464 || test_thread_flag(TIF_SINGLESTEP))
1465 && (current->ptrace & PT_PTRACED))
1466 syscall_trace(regs);
1467 }
1468
1469 #endif /* CONFIG_X86_32 */
This page took 0.077029 seconds and 4 git commands to generate.