This source file includes following definitions.
- collect_syscall
- task_current_syscall
1
2 #include <linux/ptrace.h>
3 #include <linux/sched.h>
4 #include <linux/sched/task_stack.h>
5 #include <linux/export.h>
6 #include <asm/syscall.h>
7
8 static int collect_syscall(struct task_struct *target, struct syscall_info *info)
9 {
10 struct pt_regs *regs;
11
12 if (!try_get_task_stack(target)) {
13
14 memset(info, 0, sizeof(*info));
15 info->data.nr = -1;
16 return 0;
17 }
18
19 regs = task_pt_regs(target);
20 if (unlikely(!regs)) {
21 put_task_stack(target);
22 return -EAGAIN;
23 }
24
25 info->sp = user_stack_pointer(regs);
26 info->data.instruction_pointer = instruction_pointer(regs);
27
28 info->data.nr = syscall_get_nr(target, regs);
29 if (info->data.nr != -1L)
30 syscall_get_arguments(target, regs,
31 (unsigned long *)&info->data.args[0]);
32
33 put_task_stack(target);
34 return 0;
35 }
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 int task_current_syscall(struct task_struct *target, struct syscall_info *info)
63 {
64 long state;
65 unsigned long ncsw;
66
67 if (target == current)
68 return collect_syscall(target, info);
69
70 state = target->state;
71 if (unlikely(!state))
72 return -EAGAIN;
73
74 ncsw = wait_task_inactive(target, state);
75 if (unlikely(!ncsw) ||
76 unlikely(collect_syscall(target, info)) ||
77 unlikely(wait_task_inactive(target, state) != ncsw))
78 return -EAGAIN;
79
80 return 0;
81 }