Unreachable code
File: arch/x86/kernel/.tmp_ptrace.o.preproc
Full description: The code is unreachable by any path. Superfluous semicolon, break or return statement.
Importance: 3
Checker: ReachabilityChecker
Trace:
This one is:
False positive index (the lower the better): 0
File contents (this file is distributed under the terms specified in the original file):
1|enum x86_regset {
2| REGSET_GENERAL,
3| REGSET_FP,
4| REGSET_XFP,
5| REGSET_IOPERM64 = REGSET_XFP,
6| REGSET_XSTATE,
7| REGSET_TLS,
8| REGSET_IOPERM32,
9|};
10|
11|struct pt_regs_offset {
12| const char *name;
13| int offset;
14|};
15|
16|
17|
18|
19|static const struct pt_regs_offset regoffset_table[] = {
20|
21| {.name = "r15", .offset = 1},
22| {.name = "r14", .offset = 1},
23| {.name = "r13", .offset = 1},
24| {.name = "r12", .offset = 1},
25| {.name = "r11", .offset = 1},
26| {.name = "r10", .offset = 1},
27| {.name = "r9", .offset = 1},
28| {.name = "r8", .offset = 1},
29|
30| {.name = "bx", .offset = 1},
31| {.name = "cx", .offset = 1},
32| {.name = "dx", .offset = 1},
33| {.name = "si", .offset = 1},
34| {.name = "di", .offset = 1},
35| {.name = "bp", .offset = 1},
36| {.name = "ax", .offset = 1},
37|
38|
39|
40|
41|
42|
43| {.name = "orig_ax", .offset = 1},
44| {.name = "ip", .offset = 1},
45| {.name = "cs", .offset = 1},
46| {.name = "flags", .offset = 1},
47| {.name = "sp", .offset = 1},
48| {.name = "ss", .offset = 1},
49| {.name = ((void *)0), .offset = 0},
50|};
51|int regs_query_register_offset(const char *name)
52|{
53| const struct pt_regs_offset *roff;
54| for (roff = regoffset_table; roff->name != ((void *)0); roff++)
55| if (!strcmp(roff->name, name))
56| return roff->offset;
57| return -22;
58|}
59|const char *regs_query_register_name(unsigned int offset)
60|{
61| const struct pt_regs_offset *roff;
62| for (roff = regoffset_table; roff->name != ((void *)0); roff++)
63| if (roff->offset == offset)
64| return roff->name;
65| return ((void *)0);
66|}
67|
68|static const int arg_offs_table[] = {
69|
70|
71|
72|
73|
74| [0] = 1,
75| [1] = 1,
76| [2] = 1,
77| [3] = 1,
78| [4] = 1,
79| [5] = 1
80|
81|};
82|static inline bool invalid_selector(u16 value)
83|{
84| return value != 0 && (value & 0x3) != 0x3;
85|}
86|static unsigned long *pt_regs_access(struct pt_regs *regs, unsigned long offset)
87|{
88| ((void)(sizeof(struct { int:-!!(1 != 0); })));
89| return ®s->r15 + (offset / sizeof(regs->r15));
90|}
91|
92|static u16 get_segment_reg(struct task_struct *task, unsigned long offset)
93|{
94|
95|
96|
97| unsigned int seg;
98|
99| switch (offset) {
100| case 1:
101| if (task == get_current()) {
102|
103| asm("movl %%fs,%0" : "=r" (seg));
104| return seg;
105| }
106| return task->thread.fsindex;
107| case 1:
108| if (task == get_current()) {
109| asm("movl %%gs,%0" : "=r" (seg));
110| return seg;
111| }
112| return task->thread.gsindex;
113| case 1:
114| if (task == get_current()) {
115| asm("movl %%ds,%0" : "=r" (seg));
116| return seg;
117| }
118| return task->thread.ds;
119| case 1:
120| if (task == get_current()) {
121| asm("movl %%es,%0" : "=r" (seg));
122| return seg;
123| }
124| return task->thread.es;
125|
126| case 1:
127| case 1:
128| break;
129| }
130| return *pt_regs_access(((struct pt_regs *)(task)->thread.sp0 - 1), offset);
131|}
132|
133|static int set_segment_reg(struct task_struct *task,
134| unsigned long offset, u16 value)
135|{
136|
137|
138|
139| if (invalid_selector(value))
140| return -5;
141|
142| switch (offset) {
143| case 1:
144|
145|
146|
147|
148| if ((value == ((12 +0)*8 + 3) && task->thread.fsindex == 0 &&
149| task->thread.fs != 0) ||
150| (value == 0 && task->thread.fsindex == ((12 +0)*8 + 3) &&
151| task->thread.fs == 0))
152| break;
153| task->thread.fsindex = value;
154| if (task == get_current())
155| do { unsigned short __val = (task->thread.fsindex); asm volatile(" \n" "1: movl %k0,%%" "fs" " \n" ".section .fixup,\"ax\" \n" "2: xorl %k0,%k0 \n" " jmp 1b \n" ".previous \n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "2b" "\n" " .previous\n" : "+r" (__val) : : "memory"); } while (0);
156| break;
157| case 1:
158|
159|
160|
161|
162| if ((value == ((12 +1)*8 + 3) && task->thread.gsindex == 0 &&
163| task->thread.gs != 0) ||
164| (value == 0 && task->thread.gsindex == ((12 +1)*8 + 3) &&
165| task->thread.gs == 0))
166| break;
167| task->thread.gsindex = value;
168| if (task == get_current())
169| load_gs_index(task->thread.gsindex);
170| break;
171| case 1:
172| task->thread.ds = value;
173| if (task == get_current())
174| do { unsigned short __val = (task->thread.ds); asm volatile(" \n" "1: movl %k0,%%" "ds" " \n" ".section .fixup,\"ax\" \n" "2: xorl %k0,%k0 \n" " jmp 1b \n" ".previous \n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "2b" "\n" " .previous\n" : "+r" (__val) : : "memory"); } while (0);
175| break;
176| case 1:
177| task->thread.es = value;
178| if (task == get_current())
179| do { unsigned short __val = (task->thread.es); asm volatile(" \n" "1: movl %k0,%%" "es" " \n" ".section .fixup,\"ax\" \n" "2: xorl %k0,%k0 \n" " jmp 1b \n" ".previous \n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "2b" "\n" " .previous\n" : "+r" (__val) : : "memory"); } while (0);
180| break;
181|
182|
183|
184|
185| case 1:
186| if (value == 0)
187| return -5;
188|
189| if (test_tsk_thread_flag(task, 17))
190| ((struct pt_regs *)(task)->thread.sp0 - 1)->cs = value;
191|
192| break;
193| case 1:
194| if (value == 0)
195| return -5;
196|
197| if (test_tsk_thread_flag(task, 17))
198| ((struct pt_regs *)(task)->thread.sp0 - 1)->ss = value;
199|
200| break;
201| }
202|
203| return 0;
204|}
205|
206|
207|
208|static unsigned long get_flags(struct task_struct *task)
209|{
210| unsigned long retval = ((struct pt_regs *)(task)->thread.sp0 - 1)->flags;
211|
212|
213|
214|
215| if (test_tsk_thread_flag(task, 24))
216| retval &= ~0x00000100;
217|
218| return retval;
219|}
220|
221|static int set_flags(struct task_struct *task, unsigned long value)
222|{
223| struct pt_regs *regs = ((struct pt_regs *)(task)->thread.sp0 - 1);
224|
225|
226|
227|
228|
229|
230| if (value & 0x00000100)
231| clear_tsk_thread_flag(task, 24);
232| else if (test_tsk_thread_flag(task, 24))
233| value |= 0x00000100;
234|
235| regs->flags = (regs->flags & ~(((unsigned long) (0x00000001 | 0x00000004 | 0x00000010 | 0x00000040 | 0x00000080 | 0x00000100 | 0x00000400 | 0x00000800 | 0x00010000 | 0x00040000)) | 0x00004000)) | (value & (((unsigned long) (0x00000001 | 0x00000004 | 0x00000010 | 0x00000040 | 0x00000080 | 0x00000100 | 0x00000400 | 0x00000800 | 0x00010000 | 0x00040000)) | 0x00004000));
236|
237| return 0;
238|}
239|
240|static int putreg(struct task_struct *child,
241| unsigned long offset, unsigned long value)
242|{
243| switch (offset) {
244| case 1:
245| case 1:
246| case 1:
247| case 1:
248| case 1:
249| case 1:
250| return set_segment_reg(child, offset, value);
251|
252| case 1:
253| return set_flags(child, value);
254|
255|
256| case 1:
257| if (value >= ((test_tsk_thread_flag(child, 17)) ? ((get_current()->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000) : ((1UL << 47) - ((1UL) << 12))))
258| return -5;
259|
260|
261|
262|
263|
264| if (child->thread.fs != value)
265| return do_arch_prctl(child, 0x1002, value);
266| return 0;
267| case 1:
268|
269|
270|
271| if (value >= ((test_tsk_thread_flag(child, 17)) ? ((get_current()->personality & ADDR_LIMIT_3GB) ? 0xc0000000 : 0xFFFFe000) : ((1UL << 47) - ((1UL) << 12))))
272| return -5;
273| if (child->thread.gs != value)
274| return do_arch_prctl(child, 0x1001, value);
275| return 0;
276|
277| }
278|
279| *pt_regs_access(((struct pt_regs *)(child)->thread.sp0 - 1), offset) = value;
280| return 0;
281|}
282|
283|static unsigned long getreg(struct task_struct *task, unsigned long offset)
284|{
285| switch (offset) {
286| case 1:
287| case 1:
288| case 1:
289| case 1:
290| case 1:
291| case 1:
292| return get_segment_reg(task, offset);
293|
294| case 1:
295| return get_flags(task);
296|
297|
298| case 1: {
299|
300|
301|
302|
303|
304| unsigned int seg = task->thread.fsindex;
305| if (task->thread.fs != 0)
306| return task->thread.fs;
307| if (task == get_current())
308| asm("movl %%fs,%0" : "=r" (seg));
309| if (seg != ((12 +0)*8 + 3))
310| return 0;
311| return get_desc_base(&task->thread.tls_array[0]);
312| }
313| case 1: {
314|
315|
316|
317| unsigned int seg = task->thread.gsindex;
318| if (task->thread.gs != 0)
319| return task->thread.gs;
320| if (task == get_current())
321| asm("movl %%gs,%0" : "=r" (seg));
322| if (seg != ((12 +1)*8 + 3))
323| return 0;
324| return get_desc_base(&task->thread.tls_array[1]);
325| }
326|
327| }
328|
329| return *pt_regs_access(((struct pt_regs *)(task)->thread.sp0 - 1), offset);
330|}
331|
332|static int genregs_get(struct task_struct *target,
333| const struct user_regset *regset,
334| unsigned int pos, unsigned int count,
335| void *kbuf, void *ubuf)
336|{
337| if (kbuf) {
338| unsigned long *k = kbuf;
339| while (count >= sizeof(*k)) {
340| *k++ = getreg(target, pos);
341| count -= sizeof(*k);
342| pos += sizeof(*k);
343| }
344| } else {
345| unsigned long *u = ubuf;
346| while (count >= sizeof(*u)) {
347| if (({ int __pu_err; do { __pu_err = 0; (void)0; switch ((sizeof(*(u++)))) { case 1: asm volatile("1: mov""b"" %""b""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "iq"(((__typeof__(*(u++)))(getreg(target, pos)))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; case 2: asm volatile("1: mov""w"" %""w""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "ir"(((__typeof__(*(u++)))(getreg(target, pos)))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; case 4: asm volatile("1: mov""l"" %""k""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "ir"(((__typeof__(*(u++)))(getreg(target, pos)))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; case 8: asm volatile("1: mov""q"" %""""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "er"((__typeof__(*((u++))))(((__typeof__(*(u++)))(getreg(target, pos))))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; default: __put_user_bad(); } } while (0); __pu_err; }))
348| return -14;
349| count -= sizeof(*u);
350| pos += sizeof(*u);
351| }
352| }
353|
354| return 0;
355|}
356|
357|static int genregs_set(struct task_struct *target,
358| const struct user_regset *regset,
359| unsigned int pos, unsigned int count,
360| const void *kbuf, const void *ubuf)
361|{
362| int ret = 0;
363| if (kbuf) {
364| const unsigned long *k = kbuf;
365| while (count >= sizeof(*k) && !ret) {
366| ret = putreg(target, pos, *k++);
367| count -= sizeof(*k);
368| pos += sizeof(*k);
369| }
370| } else {
371| const unsigned long *u = ubuf;
372| while (count >= sizeof(*u) && !ret) {
373| unsigned long word;
374| ret = ({ int __gu_err; unsigned long __gu_val; do { __gu_err = 0; (void)0; switch ((sizeof(*(u++)))) { case 1: asm volatile("1: mov""b"" %2,%""b""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""b"" %""b""1,%""b""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=q"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; case 2: asm volatile("1: mov""w"" %2,%""w""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""w"" %""w""1,%""w""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=r"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; case 4: asm volatile("1: mov""l"" %2,%""k""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""l"" %""k""1,%""k""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=r"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; case 8: asm volatile("1: mov""q"" %2,%""""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""q"" %""""1,%""""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=r"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; default: (__gu_val) = __get_user_bad(); } } while (0); ((word)) = ( __typeof__(*((u++))))__gu_val; __gu_err; });
375| if (ret)
376| break;
377| ret = putreg(target, pos, word);
378| count -= sizeof(*u);
379| pos += sizeof(*u);
380| }
381| }
382| return ret;
383|}
384|
385|static void ptrace_triggered(struct perf_event *bp, int nmi,
386| struct perf_sample_data *data,
387| struct pt_regs *regs)
388|{
389| int i;
390| struct thread_struct *thread = &(get_current()->thread);
391|
392|
393|
394|
395|
396| for (i = 0; i < 4; i++) {
397| if (thread->ptrace_bps[i] == bp)
398| break;
399| }
400|
401| thread->debugreg6 |= ((0x1) << i);
402|}
403|
404|
405|
406|
407|
408|
409|static unsigned long ptrace_get_dr7(struct perf_event *bp[])
410|{
411| int i;
412| int dr7 = 0;
413| struct arch_hw_breakpoint *info;
414|
415| for (i = 0; i < 4; i++) {
416| if (bp[i] && !bp[i]->attr.disabled) {
417| info = counter_arch_bp(bp[i]);
418| dr7 |= encode_dr7(i, info->len, info->type);
419| }
420| }
421|
422| return dr7;
423|}
424|
425|static int
426|ptrace_modify_breakpoint(struct perf_event *bp, int len, int type,
427| struct task_struct *tsk, int disabled)
428|{
429| int err;
430| int gen_len, gen_type;
431| struct perf_event_attr attr;
432|
433|
434|
435|
436|
437|
438| if (!bp)
439| return -22;
440|
441| err = arch_bp_generic_fields(len, type, &gen_len, &gen_type);
442| if (err)
443| return err;
444|
445| attr = bp->attr;
446| attr.bp_len = gen_len;
447| attr.bp_type = gen_type;
448| attr.disabled = disabled;
449|
450| return modify_user_hw_breakpoint(bp, &attr);
451|}
452|
453|
454|
455|
456|static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data)
457|{
458| struct thread_struct *thread = &(tsk->thread);
459| unsigned long old_dr7;
460| int i, orig_ret = 0, rc = 0;
461| int enabled, second_pass = 0;
462| unsigned len, type;
463| struct perf_event *bp;
464|
465| data &= ~(0xFFFFFFFF0000FC00UL);
466| old_dr7 = ptrace_get_dr7(thread->ptrace_bps);
467|restore:
468|
469|
470|
471|
472| for (i = 0; i < 4; i++) {
473| enabled = decode_dr7(data, i, &len, &type);
474| bp = thread->ptrace_bps[i];
475|
476| if (!enabled) {
477| if (bp) {
478|
479|
480|
481|
482|
483|
484|
485| if (!second_pass)
486| continue;
487|
488| rc = ptrace_modify_breakpoint(bp, len, type,
489| tsk, 1);
490| if (rc)
491| break;
492| }
493| continue;
494| }
495|
496| rc = ptrace_modify_breakpoint(bp, len, type, tsk, 0);
497| if (rc)
498| break;
499| }
500|
501|
502|
503|
504| if (!second_pass) {
505| second_pass = 1;
506| if (rc < 0) {
507| orig_ret = rc;
508| data = old_dr7;
509| }
510| goto restore;
511| }
512| return ((orig_ret < 0) ? orig_ret : rc);
513|}
514|
515|
516|
517|
518|static unsigned long ptrace_get_debugreg(struct task_struct *tsk, int n)
519|{
520| struct thread_struct *thread = &(tsk->thread);
521| unsigned long val = 0;
522|
523| if (n < 4) {
524| struct perf_event *bp;
525| bp = thread->ptrace_bps[n];
526| if (!bp)
527| return 0;
528| val = bp->hw.info.address;
529| } else if (n == 6) {
530| val = thread->debugreg6;
531| } else if (n == 7) {
532| val = thread->ptrace_dr7;
533| }
534| return val;
535|}
536|
537|static int ptrace_set_breakpoint_addr(struct task_struct *tsk, int nr,
538| unsigned long addr)
539|{
540| struct perf_event *bp;
541| struct thread_struct *t = &tsk->thread;
542| struct perf_event_attr attr;
543|
544| if (!t->ptrace_bps[nr]) {
545| ptrace_breakpoint_init(&attr);
546|
547|
548|
549|
550| attr.bp_addr = addr;
551| attr.bp_len = HW_BREAKPOINT_LEN_1;
552| attr.bp_type = HW_BREAKPOINT_W;
553| attr.disabled = 1;
554|
555| bp = register_user_hw_breakpoint(&attr, ptrace_triggered, tsk);
556| if (IS_ERR(bp))
557| return PTR_ERR(bp);
558|
559| t->ptrace_bps[nr] = bp;
560| } else {
561| int err;
562|
563| bp = t->ptrace_bps[nr];
564|
565| attr = bp->attr;
566| attr.bp_addr = addr;
567| err = modify_user_hw_breakpoint(bp, &attr);
568| if (err)
569| return err;
570| }
571|
572|
573| return 0;
574|}
575|
576|
577|
578|
579|int ptrace_set_debugreg(struct task_struct *tsk, int n, unsigned long val)
580|{
581| struct thread_struct *thread = &(tsk->thread);
582| int rc = 0;
583|
584|
585| if (n == 4 || n == 5)
586| return -5;
587|
588| if (n == 6) {
589| thread->debugreg6 = val;
590| goto ret_path;
591| }
592| if (n < 4) {
593| rc = ptrace_set_breakpoint_addr(tsk, n, val);
594| if (rc)
595| return rc;
596| }
597|
598| if (n == 7) {
599| rc = ptrace_write_dr7(tsk, val);
600| if (!rc)
601| thread->ptrace_dr7 = val;
602| }
603|
604|ret_path:
605| return rc;
606|}
607|
608|
609|
610|
611|
612|static int ioperm_active(struct task_struct *target,
613| const struct user_regset *regset)
614|{
615| return target->thread.io_bitmap_max / regset->size;
616|}
617|
618|static int ioperm_get(struct task_struct *target,
619| const struct user_regset *regset,
620| unsigned int pos, unsigned int count,
621| void *kbuf, void *ubuf)
622|{
623| if (!target->thread.io_bitmap_ptr)
624| return -6;
625|
626| return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
627| target->thread.io_bitmap_ptr,
628| 0, (65536/8));
629|}
630|
631|
632|
633|
634|
635|
636|void ptrace_disable(struct task_struct *child)
637|{
638| user_disable_single_step(child);
639|
640| clear_tsk_thread_flag(child, 6);
641|
642|}
643|
644|
645|static const struct user_regset_view user_x86_32_view;
646|
647|
648|long arch_ptrace(struct task_struct *child, long request,
649| unsigned long addr, unsigned long data)
650|{
651| int ret;
652| unsigned long *datap = (unsigned long *)data;
653|
654| switch (request) {
655|
656| case 3: {
657| unsigned long tmp;
658|
659| ret = -5;
660| if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user))
661| break;
662|
663| tmp = 0;
664| if (addr < sizeof(struct user_regs_struct))
665| tmp = getreg(child, addr);
666| else if (addr >= 1 &&
667| addr <= 1) {
668| addr -= 1;
669| tmp = ptrace_get_debugreg(child, addr / sizeof(data));
670| }
671| ret = __st_put_user_st__(tmp, datap);
672| break;
673| }
674|
675| case 6:
676| ret = -5;
677| if ((addr & (sizeof(data) - 1)) || addr >= sizeof(struct user))
678| break;
679|
680| if (addr < sizeof(struct user_regs_struct))
681| ret = putreg(child, addr, data);
682| else if (addr >= 1 &&
683| addr <= 1) {
684| addr -= 1;
685| ret = ptrace_set_debugreg(child,
686| addr / sizeof(data), data);
687| }
688| break;
689|
690| case 12:
691| return copy_regset_to_user(child,
692| task_user_regset_view(get_current()),
693| REGSET_GENERAL,
694| 0, sizeof(struct user_regs_struct),
695| datap);
696|
697| case 13:
698| return copy_regset_from_user(child,
699| task_user_regset_view(get_current()),
700| REGSET_GENERAL,
701| 0, sizeof(struct user_regs_struct),
702| datap);
703|
704| case 14:
705| return copy_regset_to_user(child,
706| task_user_regset_view(get_current()),
707| REGSET_FP,
708| 0, sizeof(struct user_i387_struct),
709| datap);
710|
711| case 15:
712| return copy_regset_from_user(child,
713| task_user_regset_view(get_current()),
714| REGSET_FP,
715| 0, sizeof(struct user_i387_struct),
716| datap);
717| case 25:
718| if ((int) addr < 0)
719| return -5;
720| ret = do_get_thread_area(child, addr,
721| (struct user_desc *)data);
722| break;
723|
724| case 26:
725| if ((int) addr < 0)
726| return -5;
727| ret = do_set_thread_area(child, addr,
728| (struct user_desc *)data, 0);
729| break;
730|
731|
732|
733|
734|
735|
736| case 30:
737| ret = do_arch_prctl(child, data, addr);
738| break;
739|
740|
741| default:
742| ret = ptrace_request(child, request, addr, data);
743| break;
744| }
745|
746| return ret;
747|}
748|
749|
750|
751|struct __kernel_sockaddr_storage {
752| unsigned short ss_family;
753|
754| char __data[128 - sizeof(unsigned short)];
755|
756|
757|} ;
758|
759|
760|
761|
762|
763|
764|
765|
766|
767|
768|struct pid;
769|struct cred;
770|
771|
772|
773|
774|
775|
776|struct seq_file;
777|extern void socket_seq_show(struct seq_file *seq);
778|
779|
780|
781|typedef unsigned short sa_family_t;
782|
783|
784|
785|
786|
787|struct sockaddr {
788| sa_family_t sa_family;
789| char sa_data[14];
790|};
791|
792|struct linger {
793| int l_onoff;
794| int l_linger;
795|};
796|struct msghdr {
797| void * msg_name;
798| int msg_namelen;
799| struct iovec * msg_iov;
800| __kernel_size_t msg_iovlen;
801| void * msg_control;
802| __kernel_size_t msg_controllen;
803| unsigned msg_flags;
804|};
805|
806|
807|struct mmsghdr {
808| struct msghdr msg_hdr;
809| unsigned msg_len;
810|};
811|
812|
813|
814|
815|
816|
817|
818|struct cmsghdr {
819| __kernel_size_t cmsg_len;
820| int cmsg_level;
821| int cmsg_type;
822|};
823|static inline struct cmsghdr * __cmsg_nxthdr(void *__ctl, __kernel_size_t __size,
824| struct cmsghdr *__cmsg)
825|{
826| struct cmsghdr * __ptr;
827|
828| __ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + ( ((__cmsg->cmsg_len)+sizeof(long)-1) & ~(sizeof(long)-1) ));
829| if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
830| return (struct cmsghdr *)0;
831|
832| return __ptr;
833|}
834|
835|static inline struct cmsghdr * cmsg_nxthdr (struct msghdr *__msg, struct cmsghdr *__cmsg)
836|{
837| return __cmsg_nxthdr(__msg->msg_control, __msg->msg_controllen, __cmsg);
838|}
839|
840|
841|
842|
843|
844|
845|
846|struct ucred {
847| __u32 pid;
848| __u32 uid;
849| __u32 gid;
850|};
851|extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred);
852|
853|extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
854|extern int memcpy_fromiovecend(unsigned char *kdata, const struct iovec *iov,
855| int offset, int len);
856|extern int csum_partial_copy_fromiovecend(unsigned char *kdata,
857| struct iovec *iov,
858| int offset,
859| unsigned int len, __wsum *csump);
860|
861|extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode);
862|extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
863|extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
864| int offset, int len);
865|extern int move_addr_to_kernel(void *uaddr, int ulen, struct sockaddr *kaddr);
866|extern int put_cmsg(struct msghdr*, int level, int type, int len, void *data);
867|
868|struct timespec;
869|
870|extern int __sys_recvmmsg(int fd, struct mmsghdr *mmsg, unsigned int vlen,
871| unsigned int flags, struct timespec *timeout);
872|typedef struct {
873| unsigned int clock_rate;
874| unsigned int clock_type;
875| unsigned short loopback;
876|} sync_serial_settings;
877|
878|typedef struct {
879| unsigned int clock_rate;
880| unsigned int clock_type;
881| unsigned short loopback;
882| unsigned int slot_map;
883|} te1_settings;
884|
885|typedef struct {
886| unsigned short encoding;
887| unsigned short parity;
888|} raw_hdlc_proto;
889|
890|typedef struct {
891| unsigned int t391;
892| unsigned int t392;
893| unsigned int n391;
894| unsigned int n392;
895| unsigned int n393;
896| unsigned short lmi;
897| unsigned short dce;
898|} fr_proto;
899|
900|typedef struct {
901| unsigned int dlci;
902|} fr_proto_pvc;
903|
904|typedef struct {
905| unsigned int dlci;
906| char master[16];
907|}fr_proto_pvc_info;
908|
909|typedef struct {
910| unsigned int interval;
911| unsigned int timeout;
912|} cisco_proto;
913|enum {
914| IF_OPER_UNKNOWN,
915| IF_OPER_NOTPRESENT,
916| IF_OPER_DOWN,
917| IF_OPER_LOWERLAYERDOWN,
918| IF_OPER_TESTING,
919| IF_OPER_DORMANT,
920| IF_OPER_UP,
921|};
922|
923|
924|enum {
925| IF_LINK_MODE_DEFAULT,
926| IF_LINK_MODE_DORMANT,
927|};
928|struct ifmap {
929| unsigned long mem_start;
930| unsigned long mem_end;
931| unsigned short base_addr;
932| unsigned char irq;
933| unsigned char dma;
934| unsigned char port;
935|
936|};
937|
938|struct if_settings {
939| unsigned int type;
940| unsigned int size;
941| union {
942|
943| raw_hdlc_proto *raw_hdlc;
944| cisco_proto *cisco;
945| fr_proto *fr;
946| fr_proto_pvc *fr_pvc;
947| fr_proto_pvc_info *fr_pvc_info;
948|
949|
950| sync_serial_settings *sync;
951| te1_settings *te1;
952| } ifs_ifsu;
953|};
954|struct ifreq {
955|
956| union
957| {
958| char ifrn_name[16];
959| } ifr_ifrn;
960|
961| union {
962| struct sockaddr ifru_addr;
963| struct sockaddr ifru_dstaddr;
964| struct sockaddr ifru_broadaddr;
965| struct sockaddr ifru_netmask;
966| struct sockaddr ifru_hwaddr;
967| short ifru_flags;
968| int ifru_ivalue;
969| int ifru_mtu;
970| struct ifmap ifru_map;
971| char ifru_slave[16];
972| char ifru_newname[16];
973| void * ifru_data;
974| struct if_settings ifru_settings;
975| } ifr_ifru;
976|};
977|struct ifconf {
978| int ifc_len;
979| union {
980| char *ifcu_buf;
981| struct ifreq *ifcu_req;
982| } ifc_ifcu;
983|};
984|
985|
986|
987|
988|
989|
990|
991|struct user_i387_ia32_struct {
992| u32 cwd;
993| u32 swd;
994| u32 twd;
995| u32 fip;
996| u32 fcs;
997| u32 foo;
998| u32 fos;
999| u32 st_space[20];
1000|};
1001|
1002|
1003|struct user32_fxsr_struct {
1004| unsigned short cwd;
1005| unsigned short swd;
1006| unsigned short twd;
1007| unsigned short fop;
1008| int fip;
1009| int fcs;
1010| int foo;
1011| int fos;
1012| int mxcsr;
1013| int reserved;
1014| int st_space[32];
1015| int xmm_space[32];
1016| int padding[56];
1017|};
1018|
1019|struct user_regs_struct32 {
1020| __u32 ebx, ecx, edx, esi, edi, ebp, eax;
1021| unsigned short ds, __ds, es, __es;
1022| unsigned short fs, __fs, gs, __gs;
1023| __u32 orig_eax, eip;
1024| unsigned short cs, __cs;
1025| __u32 eflags, esp;
1026| unsigned short ss, __ss;
1027|};
1028|
1029|struct user32 {
1030| struct user_regs_struct32 regs;
1031| int u_fpvalid;
1032|
1033| struct user_i387_ia32_struct i387;
1034|
1035| __u32 u_tsize;
1036| __u32 u_dsize;
1037| __u32 u_ssize;
1038| __u32 start_code;
1039| __u32 start_stack;
1040|
1041|
1042|
1043| __u32 signal;
1044| int reserved;
1045| __u32 u_ar0;
1046|
1047| __u32 u_fpstate;
1048| __u32 magic;
1049| char u_comm[32];
1050| int u_debugreg[8];
1051|};
1052|
1053|
1054|
1055|
1056|typedef u32 compat_size_t;
1057|typedef s32 compat_ssize_t;
1058|typedef s32 compat_time_t;
1059|typedef s32 compat_clock_t;
1060|typedef s32 compat_pid_t;
1061|typedef u16 __compat_uid_t;
1062|typedef u16 __compat_gid_t;
1063|typedef u32 __compat_uid32_t;
1064|typedef u32 __compat_gid32_t;
1065|typedef u16 compat_mode_t;
1066|typedef u32 compat_ino_t;
1067|typedef u16 compat_dev_t;
1068|typedef s32 compat_off_t;
1069|typedef s64 compat_loff_t;
1070|typedef u16 compat_nlink_t;
1071|typedef u16 compat_ipc_pid_t;
1072|typedef s32 compat_daddr_t;
1073|typedef u32 compat_caddr_t;
1074|typedef __kernel_fsid_t compat_fsid_t;
1075|typedef s32 compat_timer_t;
1076|typedef s32 compat_key_t;
1077|
1078|typedef s32 compat_int_t;
1079|typedef s32 compat_long_t;
1080|typedef s64 compat_s64;
1081|typedef u32 compat_uint_t;
1082|typedef u32 compat_ulong_t;
1083|typedef u64 compat_u64;
1084|
1085|struct compat_timespec {
1086| compat_time_t tv_sec;
1087| s32 tv_nsec;
1088|};
1089|
1090|struct compat_timeval {
1091| compat_time_t tv_sec;
1092| s32 tv_usec;
1093|};
1094|
1095|struct compat_stat {
1096| compat_dev_t st_dev;
1097| u16 __pad1;
1098| compat_ino_t st_ino;
1099| compat_mode_t st_mode;
1100| compat_nlink_t st_nlink;
1101| __compat_uid_t st_uid;
1102| __compat_gid_t st_gid;
1103| compat_dev_t st_rdev;
1104| u16 __pad2;
1105| u32 st_size;
1106| u32 st_blksize;
1107| u32 st_blocks;
1108| u32 st_atime;
1109| u32 st_atime_nsec;
1110| u32 st_mtime;
1111| u32 st_mtime_nsec;
1112| u32 st_ctime;
1113| u32 st_ctime_nsec;
1114| u32 __unused4;
1115| u32 __unused5;
1116|};
1117|
1118|struct compat_flock {
1119| short l_type;
1120| short l_whence;
1121| compat_off_t l_start;
1122| compat_off_t l_len;
1123| compat_pid_t l_pid;
1124|};
1125|struct compat_flock64 {
1126| short l_type;
1127| short l_whence;
1128| compat_loff_t l_start;
1129| compat_loff_t l_len;
1130| compat_pid_t l_pid;
1131|} ;
1132|
1133|struct compat_statfs {
1134| int f_type;
1135| int f_bsize;
1136| int f_blocks;
1137| int f_bfree;
1138| int f_bavail;
1139| int f_files;
1140| int f_ffree;
1141| compat_fsid_t f_fsid;
1142| int f_namelen;
1143| int f_frsize;
1144| int f_spare[5];
1145|};
1146|
1147|
1148|
1149|
1150|typedef u32 compat_old_sigset_t;
1151|
1152|
1153|
1154|
1155|typedef u32 compat_sigset_word;
1156|
1157|
1158|
1159|
1160|struct compat_ipc64_perm {
1161| compat_key_t key;
1162| __compat_uid32_t uid;
1163| __compat_gid32_t gid;
1164| __compat_uid32_t cuid;
1165| __compat_gid32_t cgid;
1166| unsigned short mode;
1167| unsigned short __pad1;
1168| unsigned short seq;
1169| unsigned short __pad2;
1170| compat_ulong_t unused1;
1171| compat_ulong_t unused2;
1172|};
1173|
1174|struct compat_semid64_ds {
1175| struct compat_ipc64_perm sem_perm;
1176| compat_time_t sem_otime;
1177| compat_ulong_t __unused1;
1178| compat_time_t sem_ctime;
1179| compat_ulong_t __unused2;
1180| compat_ulong_t sem_nsems;
1181| compat_ulong_t __unused3;
1182| compat_ulong_t __unused4;
1183|};
1184|
1185|struct compat_msqid64_ds {
1186| struct compat_ipc64_perm msg_perm;
1187| compat_time_t msg_stime;
1188| compat_ulong_t __unused1;
1189| compat_time_t msg_rtime;
1190| compat_ulong_t __unused2;
1191| compat_time_t msg_ctime;
1192| compat_ulong_t __unused3;
1193| compat_ulong_t msg_cbytes;
1194| compat_ulong_t msg_qnum;
1195| compat_ulong_t msg_qbytes;
1196| compat_pid_t msg_lspid;
1197| compat_pid_t msg_lrpid;
1198| compat_ulong_t __unused4;
1199| compat_ulong_t __unused5;
1200|};
1201|
1202|struct compat_shmid64_ds {
1203| struct compat_ipc64_perm shm_perm;
1204| compat_size_t shm_segsz;
1205| compat_time_t shm_atime;
1206| compat_ulong_t __unused1;
1207| compat_time_t shm_dtime;
1208| compat_ulong_t __unused2;
1209| compat_time_t shm_ctime;
1210| compat_ulong_t __unused3;
1211| compat_pid_t shm_cpid;
1212| compat_pid_t shm_lpid;
1213| compat_ulong_t shm_nattch;
1214| compat_ulong_t __unused4;
1215| compat_ulong_t __unused5;
1216|};
1217|
1218|
1219|
1220|
1221|typedef struct user_regs_struct32 compat_elf_gregset_t;
1222|
1223|
1224|
1225|
1226|
1227|
1228|
1229|typedef u32 compat_uptr_t;
1230|
1231|static inline void *compat_ptr(compat_uptr_t uptr)
1232|{
1233| return (void *)(unsigned long)uptr;
1234|}
1235|
1236|static inline compat_uptr_t ptr_to_compat(void *uptr)
1237|{
1238| return (u32)(unsigned long)uptr;
1239|}
1240|
1241|static inline void *arch_compat_alloc_user_space(long len)
1242|{
1243| struct pt_regs *regs = ((struct pt_regs *)(get_current())->thread.sp0 - 1);
1244| return (void *)regs->sp - len;
1245|}
1246|
1247|static inline int is_compat_task(void)
1248|{
1249| return current_thread_info()->status & 0x0002;
1250|}
1251|
1252|
1253|
1254|
1255|
1256|
1257|typedef __compat_uid32_t compat_uid_t;
1258|typedef __compat_gid32_t compat_gid_t;
1259|
1260|struct compat_sel_arg_struct;
1261|struct rusage;
1262|
1263|struct compat_itimerspec {
1264| struct compat_timespec it_interval;
1265| struct compat_timespec it_value;
1266|};
1267|
1268|struct compat_utimbuf {
1269| compat_time_t actime;
1270| compat_time_t modtime;
1271|};
1272|
1273|struct compat_itimerval {
1274| struct compat_timeval it_interval;
1275| struct compat_timeval it_value;
1276|};
1277|
1278|struct compat_tms {
1279| compat_clock_t tms_utime;
1280| compat_clock_t tms_stime;
1281| compat_clock_t tms_cutime;
1282| compat_clock_t tms_cstime;
1283|};
1284|
1285|struct compat_timex {
1286| compat_uint_t modes;
1287| compat_long_t offset;
1288| compat_long_t freq;
1289| compat_long_t maxerror;
1290| compat_long_t esterror;
1291| compat_int_t status;
1292| compat_long_t constant;
1293| compat_long_t precision;
1294| compat_long_t tolerance;
1295| struct compat_timeval time;
1296| compat_long_t tick;
1297| compat_long_t ppsfreq;
1298| compat_long_t jitter;
1299| compat_int_t shift;
1300| compat_long_t stabil;
1301| compat_long_t jitcnt;
1302| compat_long_t calcnt;
1303| compat_long_t errcnt;
1304| compat_long_t stbcnt;
1305| compat_int_t tai;
1306|
1307| compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
1308| compat_int_t :32; compat_int_t :32; compat_int_t :32; compat_int_t :32;
1309| compat_int_t :32; compat_int_t :32; compat_int_t :32;
1310|};
1311|
1312|
1313|
1314|typedef struct {
1315| compat_sigset_word sig[(64 / 32)];
1316|} compat_sigset_t;
1317|
1318|extern int get_compat_timespec(struct timespec *, const struct compat_timespec *);
1319|extern int put_compat_timespec(const struct timespec *, struct compat_timespec *);
1320|
1321|struct compat_iovec {
1322| compat_uptr_t iov_base;
1323| compat_size_t iov_len;
1324|};
1325|
1326|struct compat_rlimit {
1327| compat_ulong_t rlim_cur;
1328| compat_ulong_t rlim_max;
1329|};
1330|
1331|struct compat_rusage {
1332| struct compat_timeval ru_utime;
1333| struct compat_timeval ru_stime;
1334| compat_long_t ru_maxrss;
1335| compat_long_t ru_ixrss;
1336| compat_long_t ru_idrss;
1337| compat_long_t ru_isrss;
1338| compat_long_t ru_minflt;
1339| compat_long_t ru_majflt;
1340| compat_long_t ru_nswap;
1341| compat_long_t ru_inblock;
1342| compat_long_t ru_oublock;
1343| compat_long_t ru_msgsnd;
1344| compat_long_t ru_msgrcv;
1345| compat_long_t ru_nsignals;
1346| compat_long_t ru_nvcsw;
1347| compat_long_t ru_nivcsw;
1348|};
1349|
1350|extern int put_compat_rusage(const struct rusage *, struct compat_rusage *);
1351|
1352|struct compat_siginfo;
1353|
1354|extern long compat_sys_waitid(int, compat_pid_t,
1355| struct compat_siginfo *, int,
1356| struct compat_rusage *);
1357|
1358|struct compat_dirent {
1359| u32 d_ino;
1360| compat_off_t d_off;
1361| u16 d_reclen;
1362| char d_name[256];
1363|};
1364|
1365|struct compat_ustat {
1366| compat_daddr_t f_tfree;
1367| compat_ino_t f_tinode;
1368| char f_fname[6];
1369| char f_fpack[6];
1370|};
1371|
1372|typedef union compat_sigval {
1373| compat_int_t sival_int;
1374| compat_uptr_t sival_ptr;
1375|} compat_sigval_t;
1376|
1377|
1378|
1379|typedef struct compat_sigevent {
1380| compat_sigval_t sigev_value;
1381| compat_int_t sigev_signo;
1382| compat_int_t sigev_notify;
1383| union {
1384| compat_int_t _pad[((64/sizeof(int)) - 3)];
1385| compat_int_t _tid;
1386|
1387| struct {
1388| compat_uptr_t _function;
1389| compat_uptr_t _attribute;
1390| } _sigev_thread;
1391| } _sigev_un;
1392|} compat_sigevent_t;
1393|
1394|struct compat_ifmap {
1395| compat_ulong_t mem_start;
1396| compat_ulong_t mem_end;
1397| unsigned short base_addr;
1398| unsigned char irq;
1399| unsigned char dma;
1400| unsigned char port;
1401|};
1402|
1403|struct compat_if_settings
1404|{
1405| unsigned int type;
1406| unsigned int size;
1407| compat_uptr_t ifs_ifsu;
1408|};
1409|
1410|struct compat_ifreq {
1411| union {
1412| char ifrn_name[16];
1413| } ifr_ifrn;
1414| union {
1415| struct sockaddr ifru_addr;
1416| struct sockaddr ifru_dstaddr;
1417| struct sockaddr ifru_broadaddr;
1418| struct sockaddr ifru_netmask;
1419| struct sockaddr ifru_hwaddr;
1420| short ifru_flags;
1421| compat_int_t ifru_ivalue;
1422| compat_int_t ifru_mtu;
1423| struct compat_ifmap ifru_map;
1424| char ifru_slave[16];
1425| char ifru_newname[16];
1426| compat_caddr_t ifru_data;
1427| struct compat_if_settings ifru_settings;
1428| } ifr_ifru;
1429|};
1430|
1431|struct compat_ifconf {
1432| compat_int_t ifc_len;
1433| compat_caddr_t ifcbuf;
1434|};
1435|
1436|struct compat_robust_list {
1437| compat_uptr_t next;
1438|};
1439|
1440|struct compat_robust_list_head {
1441| struct compat_robust_list list;
1442| compat_long_t futex_offset;
1443| compat_uptr_t list_op_pending;
1444|};
1445|
1446|extern void compat_exit_robust_list(struct task_struct *curr);
1447|
1448| long
1449|compat_sys_set_robust_list(struct compat_robust_list_head *head,
1450| compat_size_t len);
1451| long
1452|compat_sys_get_robust_list(int pid, compat_uptr_t *head_ptr,
1453| compat_size_t *len_ptr);
1454|
1455|long compat_sys_semctl(int first, int second, int third, void *uptr);
1456|long compat_sys_msgsnd(int first, int second, int third, void *uptr);
1457|long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
1458| int version, void *uptr);
1459|long compat_sys_msgctl(int first, int second, void *uptr);
1460|long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
1461| void *uptr);
1462|long compat_sys_shmctl(int first, int second, void *uptr);
1463|long compat_sys_semtimedop(int semid, struct sembuf *tsems,
1464| unsigned nsems, const struct compat_timespec *timeout);
1465| long compat_sys_keyctl(u32 option,
1466| u32 arg2, u32 arg3, u32 arg4, u32 arg5);
1467| long compat_sys_ustat(unsigned dev, struct compat_ustat *u32);
1468|
1469| ssize_t compat_sys_readv(unsigned long fd,
1470| const struct compat_iovec *vec, unsigned long vlen);
1471| ssize_t compat_sys_writev(unsigned long fd,
1472| const struct compat_iovec *vec, unsigned long vlen);
1473| ssize_t compat_sys_preadv(unsigned long fd,
1474| const struct compat_iovec *vec,
1475| unsigned long vlen, u32 pos_low, u32 pos_high);
1476| ssize_t compat_sys_pwritev(unsigned long fd,
1477| const struct compat_iovec *vec,
1478| unsigned long vlen, u32 pos_low, u32 pos_high);
1479|
1480|int compat_do_execve(char * filename, compat_uptr_t *argv,
1481| compat_uptr_t *envp, struct pt_regs * regs);
1482|
1483| long compat_sys_select(int n, compat_ulong_t *inp,
1484| compat_ulong_t *outp, compat_ulong_t *exp,
1485| struct compat_timeval *tvp);
1486|
1487| long compat_sys_old_select(struct compat_sel_arg_struct *arg);
1488|
1489| long compat_sys_wait4(compat_pid_t pid,
1490| compat_uint_t *stat_addr, int options,
1491| struct compat_rusage *ru);
1492|
1493|
1494|
1495|
1496|
1497|
1498|long compat_get_bitmap(unsigned long *mask, const compat_ulong_t *umask,
1499| unsigned long bitmap_size);
1500|long compat_put_bitmap(compat_ulong_t *umask, unsigned long *mask,
1501| unsigned long bitmap_size);
1502|int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo *from);
1503|int copy_siginfo_to_user32(struct compat_siginfo *to, siginfo_t *from);
1504|int get_compat_sigevent(struct sigevent *event,
1505| const struct compat_sigevent *u_event);
1506|long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
1507| struct compat_siginfo *uinfo);
1508|
1509|static inline int compat_timeval_compare(struct compat_timeval *lhs,
1510| struct compat_timeval *rhs)
1511|{
1512| if (lhs->tv_sec < rhs->tv_sec)
1513| return -1;
1514| if (lhs->tv_sec > rhs->tv_sec)
1515| return 1;
1516| return lhs->tv_usec - rhs->tv_usec;
1517|}
1518|
1519|static inline int compat_timespec_compare(struct compat_timespec *lhs,
1520| struct compat_timespec *rhs)
1521|{
1522| if (lhs->tv_sec < rhs->tv_sec)
1523| return -1;
1524| if (lhs->tv_sec > rhs->tv_sec)
1525| return 1;
1526| return lhs->tv_nsec - rhs->tv_nsec;
1527|}
1528|
1529|extern int get_compat_itimerspec(struct itimerspec *dst,
1530| const struct compat_itimerspec *src);
1531|extern int put_compat_itimerspec(struct compat_itimerspec *dst,
1532| const struct itimerspec *src);
1533|
1534| long compat_sys_gettimeofday(struct compat_timeval *tv,
1535| struct timezone *tz);
1536| long compat_sys_settimeofday(struct compat_timeval *tv,
1537| struct timezone *tz);
1538|
1539| long compat_sys_adjtimex(struct compat_timex *utp);
1540|
1541|extern int compat_printk(const char *fmt, ...);
1542|extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
1543|
1544| long compat_sys_migrate_pages(compat_pid_t pid,
1545| compat_ulong_t maxnode, const compat_ulong_t *old_nodes,
1546| const compat_ulong_t *new_nodes);
1547|
1548|extern int compat_ptrace_request(struct task_struct *child,
1549| compat_long_t request,
1550| compat_ulong_t addr, compat_ulong_t data);
1551|
1552|extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
1553| compat_ulong_t addr, compat_ulong_t data);
1554| long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
1555| compat_long_t addr, compat_long_t data);
1556|
1557|
1558|
1559|
1560|struct epoll_event;
1561|
1562| long compat_sys_epoll_pwait(int epfd,
1563| struct epoll_event *events,
1564| int maxevents, int timeout,
1565| const compat_sigset_t *sigmask,
1566| compat_size_t sigsetsize);
1567|
1568| long compat_sys_utimensat(unsigned int dfd, const char *filename,
1569| struct compat_timespec *t, int flags);
1570|
1571| long compat_sys_signalfd(int ufd,
1572| const compat_sigset_t *sigmask,
1573| compat_size_t sigsetsize);
1574| long compat_sys_timerfd_settime(int ufd, int flags,
1575| const struct compat_itimerspec *utmr,
1576| struct compat_itimerspec *otmr);
1577| long compat_sys_timerfd_gettime(int ufd,
1578| struct compat_itimerspec *otmr);
1579|
1580| long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
1581| __u32 *pages,
1582| const int *nodes,
1583| int *status,
1584| int flags);
1585| long compat_sys_futimesat(unsigned int dfd, const char *filename,
1586| struct compat_timeval *t);
1587| long compat_sys_newfstatat(unsigned int dfd, const char * filename,
1588| struct compat_stat *statbuf,
1589| int flag);
1590| long compat_sys_openat(unsigned int dfd, const char *filename,
1591| int flags, int mode);
1592|
1593|extern ssize_t compat_rw_copy_check_uvector(int type,
1594| const struct compat_iovec *uvector, unsigned long nr_segs,
1595| unsigned long fast_segs, struct iovec *fast_pointer,
1596| struct iovec **ret_pointer);
1597|
1598|extern void *compat_alloc_user_space(unsigned long len);
1599|struct epoll_event;
1600|struct iattr;
1601|struct inode;
1602|struct iocb;
1603|struct io_event;
1604|struct iovec;
1605|struct itimerspec;
1606|struct itimerval;
1607|struct kexec_segment;
1608|struct linux_dirent;
1609|struct linux_dirent64;
1610|struct list_head;
1611|struct mmap_arg_struct;
1612|struct msgbuf;
1613|struct msghdr;
1614|struct mmsghdr;
1615|struct msqid_ds;
1616|struct new_utsname;
1617|struct nfsctl_arg;
1618|struct __old_kernel_stat;
1619|struct oldold_utsname;
1620|struct old_utsname;
1621|struct pollfd;
1622|struct rlimit;
1623|struct rlimit64;
1624|struct rusage;
1625|struct sched_param;
1626|struct sel_arg_struct;
1627|struct semaphore;
1628|struct sembuf;
1629|struct shmid_ds;
1630|struct sockaddr;
1631|struct stat;
1632|struct stat64;
1633|struct statfs;
1634|struct statfs64;
1635|struct __sysctl_args;
1636|struct sysinfo;
1637|struct timespec;
1638|struct timeval;
1639|struct timex;
1640|struct timezone;
1641|struct tms;
1642|struct utimbuf;
1643|struct mq_attr;
1644|struct compat_stat;
1645|struct compat_timeval;
1646|struct robust_list_head;
1647|struct getcpu_cache;
1648|struct old_linux_dirent;
1649|struct perf_event_attr;
1650|
1651|
1652|
1653|struct syscall_metadata {
1654| const char *name;
1655| int syscall_nr;
1656| int nb_args;
1657| const char **types;
1658| const char **args;
1659| struct list_head enter_fields;
1660|
1661| struct ftrace_event_call *enter_event;
1662| struct ftrace_event_call *exit_event;
1663|};
1664|
1665|
1666|extern unsigned long arch_syscall_addr(int nr);
1667|extern int init_syscall_trace(struct ftrace_event_call *call);
1668|
1669|extern int reg_event_syscall_enter(struct ftrace_event_call *call);
1670|extern void unreg_event_syscall_enter(struct ftrace_event_call *call);
1671|extern int reg_event_syscall_exit(struct ftrace_event_call *call);
1672|extern void unreg_event_syscall_exit(struct ftrace_event_call *call);
1673|extern int
1674|ftrace_format_syscall(struct ftrace_event_call *call, struct trace_seq *s);
1675|enum print_line_t print_syscall_enter(struct trace_iterator *iter, int flags,
1676| struct trace_event *event);
1677|enum print_line_t print_syscall_exit(struct trace_iterator *iter, int flags,
1678| struct trace_event *event);
1679|
1680|
1681|
1682|int perf_sysenter_enable(struct ftrace_event_call *call);
1683|void perf_sysenter_disable(struct ftrace_event_call *call);
1684|int perf_sysexit_enable(struct ftrace_event_call *call);
1685|void perf_sysexit_disable(struct ftrace_event_call *call);
1686|extern struct ftrace_event_class event_class_syscall_enter;
1687|extern struct ftrace_event_class event_class_syscall_exit;
1688|extern struct trace_event_functions enter_syscall_print_funcs;
1689|extern struct trace_event_functions exit_syscall_print_funcs;
1690| long sys_time(time_t *tloc);
1691| long sys_stime(time_t *tptr);
1692| long sys_gettimeofday(struct timeval *tv,
1693| struct timezone *tz);
1694| long sys_settimeofday(struct timeval *tv,
1695| struct timezone *tz);
1696| long sys_adjtimex(struct timex *txc_p);
1697|
1698| long sys_times(struct tms *tbuf);
1699|
1700| long sys_gettid(void);
1701| long sys_nanosleep(struct timespec *rqtp, struct timespec *rmtp);
1702| long sys_alarm(unsigned int seconds);
1703| long sys_getpid(void);
1704| long sys_getppid(void);
1705| long sys_getuid(void);
1706| long sys_geteuid(void);
1707| long sys_getgid(void);
1708| long sys_getegid(void);
1709| long sys_getresuid(uid_t *ruid, uid_t *euid, uid_t *suid);
1710| long sys_getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid);
1711| long sys_getpgid(pid_t pid);
1712| long sys_getpgrp(void);
1713| long sys_getsid(pid_t pid);
1714| long sys_getgroups(int gidsetsize, gid_t *grouplist);
1715|
1716| long sys_setregid(gid_t rgid, gid_t egid);
1717| long sys_setgid(gid_t gid);
1718| long sys_setreuid(uid_t ruid, uid_t euid);
1719| long sys_setuid(uid_t uid);
1720| long sys_setresuid(uid_t ruid, uid_t euid, uid_t suid);
1721| long sys_setresgid(gid_t rgid, gid_t egid, gid_t sgid);
1722| long sys_setfsuid(uid_t uid);
1723| long sys_setfsgid(gid_t gid);
1724| long sys_setpgid(pid_t pid, pid_t pgid);
1725| long sys_setsid(void);
1726| long sys_setgroups(int gidsetsize, gid_t *grouplist);
1727|
1728| long sys_acct(const char *name);
1729| long sys_capget(cap_user_header_t header,
1730| cap_user_data_t dataptr);
1731| long sys_capset(cap_user_header_t header,
1732| const cap_user_data_t data);
1733| long sys_personality(unsigned int personality);
1734|
1735| long sys_sigpending(old_sigset_t *set);
1736| long sys_sigprocmask(int how, old_sigset_t *set,
1737| old_sigset_t *oset);
1738| long sys_getitimer(int which, struct itimerval *value);
1739| long sys_setitimer(int which,
1740| struct itimerval *value,
1741| struct itimerval *ovalue);
1742| long sys_timer_create(clockid_t which_clock,
1743| struct sigevent *timer_event_spec,
1744| timer_t * created_timer_id);
1745| long sys_timer_gettime(timer_t timer_id,
1746| struct itimerspec *setting);
1747| long sys_timer_getoverrun(timer_t timer_id);
1748| long sys_timer_settime(timer_t timer_id, int flags,
1749| const struct itimerspec *new_setting,
1750| struct itimerspec *old_setting);
1751| long sys_timer_delete(timer_t timer_id);
1752| long sys_clock_settime(clockid_t which_clock,
1753| const struct timespec *tp);
1754| long sys_clock_gettime(clockid_t which_clock,
1755| struct timespec *tp);
1756| long sys_clock_getres(clockid_t which_clock,
1757| struct timespec *tp);
1758| long sys_clock_nanosleep(clockid_t which_clock, int flags,
1759| const struct timespec *rqtp,
1760| struct timespec *rmtp);
1761|
1762| long sys_nice(int increment);
1763| long sys_sched_setscheduler(pid_t pid, int policy,
1764| struct sched_param *param);
1765| long sys_sched_setparam(pid_t pid,
1766| struct sched_param *param);
1767| long sys_sched_getscheduler(pid_t pid);
1768| long sys_sched_getparam(pid_t pid,
1769| struct sched_param *param);
1770| long sys_sched_setaffinity(pid_t pid, unsigned int len,
1771| unsigned long *user_mask_ptr);
1772| long sys_sched_getaffinity(pid_t pid, unsigned int len,
1773| unsigned long *user_mask_ptr);
1774| long sys_sched_yield(void);
1775| long sys_sched_get_priority_max(int policy);
1776| long sys_sched_get_priority_min(int policy);
1777| long sys_sched_rr_get_interval(pid_t pid,
1778| struct timespec *interval);
1779| long sys_setpriority(int which, int who, int niceval);
1780| long sys_getpriority(int which, int who);
1781|
1782| long sys_shutdown(int, int);
1783| long sys_reboot(int magic1, int magic2, unsigned int cmd,
1784| void *arg);
1785| long sys_restart_syscall(void);
1786| long sys_kexec_load(unsigned long entry, unsigned long nr_segments,
1787| struct kexec_segment *segments,
1788| unsigned long flags);
1789|
1790| long sys_exit(int error_code);
1791| long sys_exit_group(int error_code);
1792| long sys_wait4(pid_t pid, int *stat_addr,
1793| int options, struct rusage *ru);
1794| long sys_waitid(int which, pid_t pid,
1795| struct siginfo *infop,
1796| int options, struct rusage *ru);
1797| long sys_waitpid(pid_t pid, int *stat_addr, int options);
1798| long sys_set_tid_address(int *tidptr);
1799| long sys_futex(u32 *uaddr, int op, u32 val,
1800| struct timespec *utime, u32 *uaddr2,
1801| u32 val3);
1802|
1803| long sys_init_module(void *umod, unsigned long len,
1804| const char *uargs);
1805| long sys_delete_module(const char *name_user,
1806| unsigned int flags);
1807|
1808| long sys_rt_sigprocmask(int how, sigset_t *set,
1809| sigset_t *oset, size_t sigsetsize);
1810| long sys_rt_sigpending(sigset_t *set, size_t sigsetsize);
1811| long sys_rt_sigtimedwait(const sigset_t *uthese,
1812| siginfo_t *uinfo,
1813| const struct timespec *uts,
1814| size_t sigsetsize);
1815| long sys_rt_tgsigqueueinfo(pid_t tgid, pid_t pid, int sig,
1816| siginfo_t *uinfo);
1817| long sys_kill(int pid, int sig);
1818| long sys_tgkill(int tgid, int pid, int sig);
1819| long sys_tkill(int pid, int sig);
1820| long sys_rt_sigqueueinfo(int pid, int sig, siginfo_t *uinfo);
1821| long sys_sgetmask(void);
1822| long sys_ssetmask(int newmask);
1823| long sys_signal(int sig, __sighandler_t handler);
1824| long sys_pause(void);
1825|
1826| long sys_sync(void);
1827| long sys_fsync(unsigned int fd);
1828| long sys_fdatasync(unsigned int fd);
1829| long sys_bdflush(int func, long data);
1830| long sys_mount(char *dev_name, char *dir_name,
1831| char *type, unsigned long flags,
1832| void *data);
1833| long sys_umount(char *name, int flags);
1834| long sys_oldumount(char *name);
1835| long sys_truncate(const char *path, long length);
1836| long sys_ftruncate(unsigned int fd, unsigned long length);
1837| long sys_stat(const char *filename,
1838| struct __old_kernel_stat *statbuf);
1839| long sys_statfs(const char * path,
1840| struct statfs *buf);
1841| long sys_statfs64(const char *path, size_t sz,
1842| struct statfs64 *buf);
1843| long sys_fstatfs(unsigned int fd, struct statfs *buf);
1844| long sys_fstatfs64(unsigned int fd, size_t sz,
1845| struct statfs64 *buf);
1846| long sys_lstat(const char *filename,
1847| struct __old_kernel_stat *statbuf);
1848| long sys_fstat(unsigned int fd,
1849| struct __old_kernel_stat *statbuf);
1850| long sys_newstat(const char *filename,
1851| struct stat *statbuf);
1852| long sys_newlstat(const char *filename,
1853| struct stat *statbuf);
1854| long sys_newfstat(unsigned int fd, struct stat *statbuf);
1855| long sys_ustat(unsigned dev, struct ustat *ubuf);
1856| long sys_setxattr(const char *path, const char *name,
1857| const void *value, size_t size, int flags);
1858| long sys_lsetxattr(const char *path, const char *name,
1859| const void *value, size_t size, int flags);
1860| long sys_fsetxattr(int fd, const char *name,
1861| const void *value, size_t size, int flags);
1862| long sys_getxattr(const char *path, const char *name,
1863| void *value, size_t size);
1864| long sys_lgetxattr(const char *path, const char *name,
1865| void *value, size_t size);
1866| long sys_fgetxattr(int fd, const char *name,
1867| void *value, size_t size);
1868| long sys_listxattr(const char *path, char *list,
1869| size_t size);
1870| long sys_llistxattr(const char *path, char *list,
1871| size_t size);
1872| long sys_flistxattr(int fd, char *list, size_t size);
1873| long sys_removexattr(const char *path,
1874| const char *name);
1875| long sys_lremovexattr(const char *path,
1876| const char *name);
1877| long sys_fremovexattr(int fd, const char *name);
1878|
1879| long sys_brk(unsigned long brk);
1880| long sys_mprotect(unsigned long start, size_t len,
1881| unsigned long prot);
1882| long sys_mremap(unsigned long addr,
1883| unsigned long old_len, unsigned long new_len,
1884| unsigned long flags, unsigned long new_addr);
1885| long sys_remap_file_pages(unsigned long start, unsigned long size,
1886| unsigned long prot, unsigned long pgoff,
1887| unsigned long flags);
1888| long sys_msync(unsigned long start, size_t len, int flags);
1889| long sys_fadvise64(int fd, loff_t offset, size_t len, int advice);
1890| long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice);
1891| long sys_munmap(unsigned long addr, size_t len);
1892| long sys_mlock(unsigned long start, size_t len);
1893| long sys_munlock(unsigned long start, size_t len);
1894| long sys_mlockall(int flags);
1895| long sys_munlockall(void);
1896| long sys_madvise(unsigned long start, size_t len, int behavior);
1897| long sys_mincore(unsigned long start, size_t len,
1898| unsigned char * vec);
1899|
1900| long sys_pivot_root(const char *new_root,
1901| const char *put_old);
1902| long sys_chroot(const char *filename);
1903| long sys_mknod(const char *filename, int mode,
1904| unsigned dev);
1905| long sys_link(const char *oldname,
1906| const char *newname);
1907| long sys_symlink(const char *old, const char *new);
1908| long sys_unlink(const char *pathname);
1909| long sys_rename(const char *oldname,
1910| const char *newname);
1911| long sys_chmod(const char *filename, mode_t mode);
1912| long sys_fchmod(unsigned int fd, mode_t mode);
1913|
1914| long sys_fcntl(unsigned int fd, unsigned int cmd, unsigned long arg);
1915|
1916|
1917|
1918|
1919| long sys_pipe(int *fildes);
1920| long sys_pipe2(int *fildes, int flags);
1921| long sys_dup(unsigned int fildes);
1922| long sys_dup2(unsigned int oldfd, unsigned int newfd);
1923| long sys_dup3(unsigned int oldfd, unsigned int newfd, int flags);
1924| long sys_ioperm(unsigned long from, unsigned long num, int on);
1925| long sys_ioctl(unsigned int fd, unsigned int cmd,
1926| unsigned long arg);
1927| long sys_flock(unsigned int fd, unsigned int cmd);
1928| long sys_io_setup(unsigned nr_reqs, aio_context_t *ctx);
1929| long sys_io_destroy(aio_context_t ctx);
1930| long sys_io_getevents(aio_context_t ctx_id,
1931| long min_nr,
1932| long nr,
1933| struct io_event *events,
1934| struct timespec *timeout);
1935| long sys_io_submit(aio_context_t, long,
1936| struct iocb * *);
1937| long sys_io_cancel(aio_context_t ctx_id, struct iocb *iocb,
1938| struct io_event *result);
1939| long sys_sendfile(int out_fd, int in_fd,
1940| off_t *offset, size_t count);
1941| long sys_sendfile64(int out_fd, int in_fd,
1942| loff_t *offset, size_t count);
1943| long sys_readlink(const char *path,
1944| char *buf, int bufsiz);
1945| long sys_creat(const char *pathname, int mode);
1946| long sys_open(const char *filename,
1947| int flags, int mode);
1948| long sys_close(unsigned int fd);
1949| long sys_access(const char *filename, int mode);
1950| long sys_vhangup(void);
1951| long sys_chown(const char *filename,
1952| uid_t user, gid_t group);
1953| long sys_lchown(const char *filename,
1954| uid_t user, gid_t group);
1955| long sys_fchown(unsigned int fd, uid_t user, gid_t group);
1956|
1957| long sys_chown16(const char *filename,
1958| old_uid_t user, old_gid_t group);
1959| long sys_lchown16(const char *filename,
1960| old_uid_t user, old_gid_t group);
1961| long sys_fchown16(unsigned int fd, old_uid_t user, old_gid_t group);
1962| long sys_setregid16(old_gid_t rgid, old_gid_t egid);
1963| long sys_setgid16(old_gid_t gid);
1964| long sys_setreuid16(old_uid_t ruid, old_uid_t euid);
1965| long sys_setuid16(old_uid_t uid);
1966| long sys_setresuid16(old_uid_t ruid, old_uid_t euid, old_uid_t suid);
1967| long sys_getresuid16(old_uid_t *ruid,
1968| old_uid_t *euid, old_uid_t *suid);
1969| long sys_setresgid16(old_gid_t rgid, old_gid_t egid, old_gid_t sgid);
1970| long sys_getresgid16(old_gid_t *rgid,
1971| old_gid_t *egid, old_gid_t *sgid);
1972| long sys_setfsuid16(old_uid_t uid);
1973| long sys_setfsgid16(old_gid_t gid);
1974| long sys_getgroups16(int gidsetsize, old_gid_t *grouplist);
1975| long sys_setgroups16(int gidsetsize, old_gid_t *grouplist);
1976| long sys_getuid16(void);
1977| long sys_geteuid16(void);
1978| long sys_getgid16(void);
1979| long sys_getegid16(void);
1980|
1981|
1982| long sys_utime(char *filename,
1983| struct utimbuf *times);
1984| long sys_utimes(char *filename,
1985| struct timeval *utimes);
1986| long sys_lseek(unsigned int fd, off_t offset,
1987| unsigned int origin);
1988| long sys_llseek(unsigned int fd, unsigned long offset_high,
1989| unsigned long offset_low, loff_t *result,
1990| unsigned int origin);
1991| long sys_read(unsigned int fd, char *buf, size_t count);
1992| long sys_readahead(int fd, loff_t offset, size_t count);
1993| long sys_readv(unsigned long fd,
1994| const struct iovec *vec,
1995| unsigned long vlen);
1996| long sys_write(unsigned int fd, const char *buf,
1997| size_t count);
1998| long sys_writev(unsigned long fd,
1999| const struct iovec *vec,
2000| unsigned long vlen);
2001| long sys_pread64(unsigned int fd, char *buf,
2002| size_t count, loff_t pos);
2003| long sys_pwrite64(unsigned int fd, const char *buf,
2004| size_t count, loff_t pos);
2005| long sys_preadv(unsigned long fd, const struct iovec *vec,
2006| unsigned long vlen, unsigned long pos_l, unsigned long pos_h);
2007| long sys_pwritev(unsigned long fd, const struct iovec *vec,
2008| unsigned long vlen, unsigned long pos_l, unsigned long pos_h);
2009| long sys_getcwd(char *buf, unsigned long size);
2010| long sys_mkdir(const char *pathname, int mode);
2011| long sys_chdir(const char *filename);
2012| long sys_fchdir(unsigned int fd);
2013| long sys_rmdir(const char *pathname);
2014| long sys_lookup_dcookie(u64 cookie64, char *buf, size_t len);
2015| long sys_quotactl(unsigned int cmd, const char *special,
2016| qid_t id, void *addr);
2017| long sys_getdents(unsigned int fd,
2018| struct linux_dirent *dirent,
2019| unsigned int count);
2020| long sys_getdents64(unsigned int fd,
2021| struct linux_dirent64 *dirent,
2022| unsigned int count);
2023|
2024| long sys_setsockopt(int fd, int level, int optname,
2025| char *optval, int optlen);
2026| long sys_getsockopt(int fd, int level, int optname,
2027| char *optval, int *optlen);
2028| long sys_bind(int, struct sockaddr *, int);
2029| long sys_connect(int, struct sockaddr *, int);
2030| long sys_accept(int, struct sockaddr *, int *);
2031| long sys_accept4(int, struct sockaddr *, int *, int);
2032| long sys_getsockname(int, struct sockaddr *, int *);
2033| long sys_getpeername(int, struct sockaddr *, int *);
2034| long sys_send(int, void *, size_t, unsigned);
2035| long sys_sendto(int, void *, size_t, unsigned,
2036| struct sockaddr *, int);
2037| long sys_sendmsg(int fd, struct msghdr *msg, unsigned flags);
2038| long sys_recv(int, void *, size_t, unsigned);
2039| long sys_recvfrom(int, void *, size_t, unsigned,
2040| struct sockaddr *, int *);
2041| long sys_recvmsg(int fd, struct msghdr *msg, unsigned flags);
2042| long sys_recvmmsg(int fd, struct mmsghdr *msg,
2043| unsigned int vlen, unsigned flags,
2044| struct timespec *timeout);
2045| long sys_socket(int, int, int);
2046| long sys_socketpair(int, int, int, int *);
2047| long sys_socketcall(int call, unsigned long *args);
2048| long sys_listen(int, int);
2049| long sys_poll(struct pollfd *ufds, unsigned int nfds,
2050| long timeout);
2051| long sys_select(int n, fd_set *inp, fd_set *outp,
2052| fd_set *exp, struct timeval *tvp);
2053| long sys_old_select(struct sel_arg_struct *arg);
2054| long sys_epoll_create(int size);
2055| long sys_epoll_create1(int flags);
2056| long sys_epoll_ctl(int epfd, int op, int fd,
2057| struct epoll_event *event);
2058| long sys_epoll_wait(int epfd, struct epoll_event *events,
2059| int maxevents, int timeout);
2060| long sys_epoll_pwait(int epfd, struct epoll_event *events,
2061| int maxevents, int timeout,
2062| const sigset_t *sigmask,
2063| size_t sigsetsize);
2064| long sys_gethostname(char *name, int len);
2065| long sys_sethostname(char *name, int len);
2066| long sys_setdomainname(char *name, int len);
2067| long sys_newuname(struct new_utsname *name);
2068| long sys_uname(struct old_utsname *);
2069| long sys_olduname(struct oldold_utsname *);
2070|
2071| long sys_getrlimit(unsigned int resource,
2072| struct rlimit *rlim);
2073|
2074| long sys_old_getrlimit(unsigned int resource, struct rlimit *rlim);
2075|
2076| long sys_setrlimit(unsigned int resource,
2077| struct rlimit *rlim);
2078| long sys_prlimit64(pid_t pid, unsigned int resource,
2079| const struct rlimit64 *new_rlim,
2080| struct rlimit64 *old_rlim);
2081| long sys_getrusage(int who, struct rusage *ru);
2082| long sys_umask(int mask);
2083|
2084| long sys_msgget(key_t key, int msgflg);
2085| long sys_msgsnd(int msqid, struct msgbuf *msgp,
2086| size_t msgsz, int msgflg);
2087| long sys_msgrcv(int msqid, struct msgbuf *msgp,
2088| size_t msgsz, long msgtyp, int msgflg);
2089| long sys_msgctl(int msqid, int cmd, struct msqid_ds *buf);
2090|
2091| long sys_semget(key_t key, int nsems, int semflg);
2092| long sys_semop(int semid, struct sembuf *sops,
2093| unsigned nsops);
2094| long sys_semctl(int semid, int semnum, int cmd, union semun arg);
2095| long sys_semtimedop(int semid, struct sembuf *sops,
2096| unsigned nsops,
2097| const struct timespec *timeout);
2098| long sys_shmat(int shmid, char *shmaddr, int shmflg);
2099| long sys_shmget(key_t key, size_t size, int flag);
2100| long sys_shmdt(char *shmaddr);
2101| long sys_shmctl(int shmid, int cmd, struct shmid_ds *buf);
2102| long sys_ipc(unsigned int call, int first, unsigned long second,
2103| unsigned long third, void *ptr, long fifth);
2104|
2105| long sys_mq_open(const char *name, int oflag, mode_t mode, struct mq_attr *attr);
2106| long sys_mq_unlink(const char *name);
2107| long sys_mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout);
2108| long sys_mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout);
2109| long sys_mq_notify(mqd_t mqdes, const struct sigevent *notification);
2110| long sys_mq_getsetattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat);
2111|
2112| long sys_pciconfig_iobase(long which, unsigned long bus, unsigned long devfn);
2113| long sys_pciconfig_read(unsigned long bus, unsigned long dfn,
2114| unsigned long off, unsigned long len,
2115| void *buf);
2116| long sys_pciconfig_write(unsigned long bus, unsigned long dfn,
2117| unsigned long off, unsigned long len,
2118| void *buf);
2119|
2120| long sys_prctl(int option, unsigned long arg2, unsigned long arg3,
2121| unsigned long arg4, unsigned long arg5);
2122| long sys_swapon(const char *specialfile, int swap_flags);
2123| long sys_swapoff(const char *specialfile);
2124| long sys_sysctl(struct __sysctl_args *args);
2125| long sys_sysinfo(struct sysinfo *info);
2126| long sys_sysfs(int option,
2127| unsigned long arg1, unsigned long arg2);
2128| long sys_nfsservctl(int cmd,
2129| struct nfsctl_arg *arg,
2130| void *res);
2131| long sys_syslog(int type, char *buf, int len);
2132| long sys_uselib(const char *library);
2133| long sys_ni_syscall(void);
2134| long sys_ptrace(long request, long pid, unsigned long addr,
2135| unsigned long data);
2136|
2137| long sys_add_key(const char *_type,
2138| const char *_description,
2139| const void *_payload,
2140| size_t plen,
2141| key_serial_t destringid);
2142|
2143| long sys_request_key(const char *_type,
2144| const char *_description,
2145| const char *_callout_info,
2146| key_serial_t destringid);
2147|
2148| long sys_keyctl(int cmd, unsigned long arg2, unsigned long arg3,
2149| unsigned long arg4, unsigned long arg5);
2150|
2151| long sys_ioprio_set(int which, int who, int ioprio);
2152| long sys_ioprio_get(int which, int who);
2153| long sys_set_mempolicy(int mode, unsigned long *nmask,
2154| unsigned long maxnode);
2155| long sys_migrate_pages(pid_t pid, unsigned long maxnode,
2156| const unsigned long *from,
2157| const unsigned long *to);
2158| long sys_move_pages(pid_t pid, unsigned long nr_pages,
2159| const void * *pages,
2160| const int *nodes,
2161| int *status,
2162| int flags);
2163| long sys_mbind(unsigned long start, unsigned long len,
2164| unsigned long mode,
2165| unsigned long *nmask,
2166| unsigned long maxnode,
2167| unsigned flags);
2168| long sys_get_mempolicy(int *policy,
2169| unsigned long *nmask,
2170| unsigned long maxnode,
2171| unsigned long addr, unsigned long flags);
2172|
2173| long sys_inotify_init(void);
2174| long sys_inotify_init1(int flags);
2175| long sys_inotify_add_watch(int fd, const char *path,
2176| u32 mask);
2177| long sys_inotify_rm_watch(int fd, __s32 wd);
2178|
2179| long sys_spu_run(int fd, __u32 *unpc,
2180| __u32 *ustatus);
2181| long sys_spu_create(const char *name,
2182| unsigned int flags, mode_t mode, int fd);
2183|
2184| long sys_mknodat(int dfd, const char * filename, int mode,
2185| unsigned dev);
2186| long sys_mkdirat(int dfd, const char * pathname, int mode);
2187| long sys_unlinkat(int dfd, const char * pathname, int flag);
2188| long sys_symlinkat(const char * oldname,
2189| int newdfd, const char * newname);
2190| long sys_linkat(int olddfd, const char *oldname,
2191| int newdfd, const char *newname, int flags);
2192| long sys_renameat(int olddfd, const char * oldname,
2193| int newdfd, const char * newname);
2194| long sys_futimesat(int dfd, const char *filename,
2195| struct timeval *utimes);
2196| long sys_faccessat(int dfd, const char *filename, int mode);
2197| long sys_fchmodat(int dfd, const char * filename,
2198| mode_t mode);
2199| long sys_fchownat(int dfd, const char *filename, uid_t user,
2200| gid_t group, int flag);
2201| long sys_openat(int dfd, const char *filename, int flags,
2202| int mode);
2203| long sys_newfstatat(int dfd, const char *filename,
2204| struct stat *statbuf, int flag);
2205| long sys_fstatat64(int dfd, const char *filename,
2206| struct stat64 *statbuf, int flag);
2207| long sys_readlinkat(int dfd, const char *path, char *buf,
2208| int bufsiz);
2209| long sys_utimensat(int dfd, const char *filename,
2210| struct timespec *utimes, int flags);
2211| long sys_unshare(unsigned long unshare_flags);
2212|
2213| long sys_splice(int fd_in, loff_t *off_in,
2214| int fd_out, loff_t *off_out,
2215| size_t len, unsigned int flags);
2216|
2217| long sys_vmsplice(int fd, const struct iovec *iov,
2218| unsigned long nr_segs, unsigned int flags);
2219|
2220| long sys_tee(int fdin, int fdout, size_t len, unsigned int flags);
2221|
2222| long sys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
2223| unsigned int flags);
2224| long sys_sync_file_range2(int fd, unsigned int flags,
2225| loff_t offset, loff_t nbytes);
2226| long sys_get_robust_list(int pid,
2227| struct robust_list_head * *head_ptr,
2228| size_t *len_ptr);
2229| long sys_set_robust_list(struct robust_list_head *head,
2230| size_t len);
2231| long sys_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *cache);
2232| long sys_signalfd(int ufd, sigset_t *user_mask, size_t sizemask);
2233| long sys_signalfd4(int ufd, sigset_t *user_mask, size_t sizemask, int flags);
2234| long sys_timerfd_create(int clockid, int flags);
2235| long sys_timerfd_settime(int ufd, int flags,
2236| const struct itimerspec *utmr,
2237| struct itimerspec *otmr);
2238| long sys_timerfd_gettime(int ufd, struct itimerspec *otmr);
2239| long sys_eventfd(unsigned int count);
2240| long sys_eventfd2(unsigned int count, int flags);
2241| long sys_fallocate(int fd, int mode, loff_t offset, loff_t len);
2242| long sys_old_readdir(unsigned int, struct old_linux_dirent *, unsigned int);
2243| long sys_pselect6(int, fd_set *, fd_set *,
2244| fd_set *, struct timespec *,
2245| void *);
2246| long sys_ppoll(struct pollfd *, unsigned int,
2247| struct timespec *, const sigset_t *,
2248| size_t);
2249| long sys_fanotify_init(unsigned int flags, unsigned int event_f_flags);
2250| long sys_fanotify_mark(int fanotify_fd, unsigned int flags,
2251| u64 mask, int fd,
2252| const char *pathname);
2253|
2254|int kernel_execve(const char *filename, const char *const argv[], const char *const envp[]);
2255|
2256|
2257| long sys_perf_event_open(
2258| struct perf_event_attr *attr_uptr,
2259| pid_t pid, int cpu, int group_fd, unsigned long flags);
2260|
2261| long sys_mmap_pgoff(unsigned long addr, unsigned long len,
2262| unsigned long prot, unsigned long flags,
2263| unsigned long fd, unsigned long pgoff);
2264| long sys_old_mmap(struct mmap_arg_struct *arg);
2265|struct _fpreg {
2266| unsigned short significand[4];
2267| unsigned short exponent;
2268|};
2269|
2270|struct _fpxreg {
2271| unsigned short significand[4];
2272| unsigned short exponent;
2273| unsigned short padding[3];
2274|};
2275|
2276|struct _xmmreg {
2277| __u32 element[4];
2278|};
2279|
2280|
2281|struct _fpstate_ia32 {
2282|
2283| __u32 cw;
2284| __u32 sw;
2285| __u32 tag;
2286| __u32 ipoff;
2287| __u32 cssel;
2288| __u32 dataoff;
2289| __u32 datasel;
2290| struct _fpreg _st[8];
2291| unsigned short status;
2292| unsigned short magic;
2293|
2294|
2295| __u32 _fxsr_env[6];
2296| __u32 mxcsr;
2297| __u32 reserved;
2298| struct _fpxreg _fxsr_st[8];
2299| struct _xmmreg _xmm[8];
2300| __u32 padding[44];
2301| union {
2302| __u32 padding2[12];
2303| struct _fpx_sw_bytes sw_reserved;
2304| };
2305|};
2306|
2307|struct sigcontext_ia32 {
2308| unsigned short gs, __gsh;
2309| unsigned short fs, __fsh;
2310| unsigned short es, __esh;
2311| unsigned short ds, __dsh;
2312| unsigned int di;
2313| unsigned int si;
2314| unsigned int bp;
2315| unsigned int sp;
2316| unsigned int bx;
2317| unsigned int dx;
2318| unsigned int cx;
2319| unsigned int ax;
2320| unsigned int trapno;
2321| unsigned int err;
2322| unsigned int ip;
2323| unsigned short cs, __csh;
2324| unsigned int flags;
2325| unsigned int sp_at_signal;
2326| unsigned short ss, __ssh;
2327| unsigned int fpstate;
2328| unsigned int oldmask;
2329| unsigned int cr2;
2330|};
2331|
2332|
2333|struct sigaction32 {
2334| unsigned int sa_handler;
2335|
2336| unsigned int sa_flags;
2337| unsigned int sa_restorer;
2338| compat_sigset_t sa_mask;
2339|};
2340|
2341|struct old_sigaction32 {
2342| unsigned int sa_handler;
2343|
2344| compat_old_sigset_t sa_mask;
2345| unsigned int sa_flags;
2346| unsigned int sa_restorer;
2347|};
2348|
2349|typedef struct sigaltstack_ia32 {
2350| unsigned int ss_sp;
2351| int ss_flags;
2352| unsigned int ss_size;
2353|} stack_ia32_t;
2354|
2355|struct ucontext_ia32 {
2356| unsigned int uc_flags;
2357| unsigned int uc_link;
2358| stack_ia32_t uc_stack;
2359| struct sigcontext_ia32 uc_mcontext;
2360| compat_sigset_t uc_sigmask;
2361|};
2362|
2363|
2364|
2365|
2366|struct stat64 {
2367| unsigned long long st_dev;
2368| unsigned char __pad0[4];
2369|
2370|
2371| unsigned int __st_ino;
2372|
2373| unsigned int st_mode;
2374| unsigned int st_nlink;
2375|
2376| unsigned int st_uid;
2377| unsigned int st_gid;
2378|
2379| unsigned long long st_rdev;
2380| unsigned char __pad3[4];
2381|
2382| long long st_size;
2383| unsigned int st_blksize;
2384|
2385| long long st_blocks;
2386|
2387| unsigned st_atime;
2388| unsigned st_atime_nsec;
2389| unsigned st_mtime;
2390| unsigned st_mtime_nsec;
2391| unsigned st_ctime;
2392| unsigned st_ctime_nsec;
2393|
2394| unsigned long long st_ino;
2395|} ;
2396|
2397|typedef struct compat_siginfo {
2398| int si_signo;
2399| int si_errno;
2400| int si_code;
2401|
2402| union {
2403| int _pad[((128 / sizeof(int)) - 3)];
2404|
2405|
2406| struct {
2407| unsigned int _pid;
2408| unsigned int _uid;
2409| } _kill;
2410|
2411|
2412| struct {
2413| compat_timer_t _tid;
2414| int _overrun;
2415| compat_sigval_t _sigval;
2416| int _sys_private;
2417| int _overrun_incr;
2418| } _timer;
2419|
2420|
2421| struct {
2422| unsigned int _pid;
2423| unsigned int _uid;
2424| compat_sigval_t _sigval;
2425| } _rt;
2426|
2427|
2428| struct {
2429| unsigned int _pid;
2430| unsigned int _uid;
2431| int _status;
2432| compat_clock_t _utime;
2433| compat_clock_t _stime;
2434| } _sigchld;
2435|
2436|
2437| struct {
2438| unsigned int _addr;
2439| } _sigfault;
2440|
2441|
2442| struct {
2443| int _band;
2444| int _fd;
2445| } _sigpoll;
2446| } _sifields;
2447|} compat_siginfo_t;
2448|
2449|
2450|
2451|
2452|struct linux_binprm;
2453|extern int ia32_setup_arg_pages(struct linux_binprm *bprm,
2454| unsigned long stack_top, int exec_stack);
2455|struct mm_struct;
2456|extern void ia32_pick_mmap_layout(struct mm_struct *mm);
2457|static int putreg32(struct task_struct *child, unsigned regno, u32 value)
2458|{
2459| struct pt_regs *regs = ((struct pt_regs *)(child)->thread.sp0 - 1);
2460|
2461| switch (regno) {
2462|
2463| case 1: return set_segment_reg(child, 1, value); break;
|This node is unreachable prev next
2464| case 1: return set_segment_reg(child, 1, value); break;
2465| case 1: return set_segment_reg(child, 1, value); break;
2466| case 1: return set_segment_reg(child, 1, value); break;
2467| case 1: return set_segment_reg(child, 1, value); break;
2468| case 1: return set_segment_reg(child, 1, value); break;
2469|
2470| case 1: regs->bx = value; break;
2471| case 1: regs->cx = value; break;
2472| case 1: regs->dx = value; break;
2473| case 1: regs->di = value; break;
2474| case 1: regs->si = value; break;
2475| case 1: regs->bp = value; break;
2476| case 1: regs->ax = value; break;
2477| case 1: regs->ip = value; break;
2478| case 1: regs->sp = value; break;
2479|
2480| case 1:
2481|
2482|
2483|
2484|
2485|
2486|
2487|
2488| regs->orig_ax = value;
2489| if (syscall_get_nr(child, regs) >= 0)
2490| ((struct thread_info *)(child)->stack)->status |= 0x0002;
2491| break;
2492|
2493| case 1:
2494| return set_flags(child, value);
2495|
2496| case 1 ...
2497| 1:
2498| regno -= 1;
2499| return ptrace_set_debugreg(child, regno / 4, value);
2500|
2501| default:
2502| if (regno > sizeof(struct user32) || (regno & 3))
2503| return -5;
2504|
2505|
2506|
2507|
2508|
2509| break;
2510| }
2511| return 0;
2512|}
2513|static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
2514|{
2515| struct pt_regs *regs = ((struct pt_regs *)(child)->thread.sp0 - 1);
2516|
2517| switch (regno) {
2518|
2519| case 1: *val = get_segment_reg(child, 1); break;
2520| case 1: *val = get_segment_reg(child, 1); break;
2521| case 1: *val = get_segment_reg(child, 1); break;
2522| case 1: *val = get_segment_reg(child, 1); break;
2523|
2524| case 1: *val = regs->cs; break;
2525| case 1: *val = regs->ss; break;
2526| case 1: *val = regs->bx; break;
2527| case 1: *val = regs->cx; break;
2528| case 1: *val = regs->dx; break;
2529| case 1: *val = regs->di; break;
2530| case 1: *val = regs->si; break;
2531| case 1: *val = regs->bp; break;
2532| case 1: *val = regs->ax; break;
2533| case 1: *val = regs->orig_ax; break;
2534| case 1: *val = regs->ip; break;
2535| case 1: *val = regs->sp; break;
2536|
2537| case 1:
2538| *val = get_flags(child);
2539| break;
2540|
2541| case 1 ...
2542| 1:
2543| regno -= 1;
2544| *val = ptrace_get_debugreg(child, regno / 4);
2545| break;
2546|
2547| default:
2548| if (regno > sizeof(struct user32) || (regno & 3))
2549| return -5;
2550|
2551|
2552|
2553|
2554|
2555| *val = 0;
2556| break;
2557| }
2558| return 0;
2559|}
2560|
2561|
2562|
2563|
2564|static int genregs32_get(struct task_struct *target,
2565| const struct user_regset *regset,
2566| unsigned int pos, unsigned int count,
2567| void *kbuf, void *ubuf)
2568|{
2569| if (kbuf) {
2570| compat_ulong_t *k = kbuf;
2571| while (count >= sizeof(*k)) {
2572| getreg32(target, pos, k++);
2573| count -= sizeof(*k);
2574| pos += sizeof(*k);
2575| }
2576| } else {
2577| compat_ulong_t *u = ubuf;
2578| while (count >= sizeof(*u)) {
2579| compat_ulong_t word;
2580| getreg32(target, pos, &word);
2581| if (({ int __pu_err; do { __pu_err = 0; (void)0; switch ((sizeof(*(u++)))) { case 1: asm volatile("1: mov""b"" %""b""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "iq"(((__typeof__(*(u++)))(word))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; case 2: asm volatile("1: mov""w"" %""w""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "ir"(((__typeof__(*(u++)))(word))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; case 4: asm volatile("1: mov""l"" %""k""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "ir"(((__typeof__(*(u++)))(word))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; case 8: asm volatile("1: mov""q"" %""""1,%2\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r"(__pu_err) : "er"((__typeof__(*((u++))))(((__typeof__(*(u++)))(word)))), "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__pu_err)); break; default: __put_user_bad(); } } while (0); __pu_err; }))
2582| return -14;
2583| count -= sizeof(*u);
2584| pos += sizeof(*u);
2585| }
2586| }
2587|
2588| return 0;
2589|}
2590|
2591|static int genregs32_set(struct task_struct *target,
2592| const struct user_regset *regset,
2593| unsigned int pos, unsigned int count,
2594| const void *kbuf, const void *ubuf)
2595|{
2596| int ret = 0;
2597| if (kbuf) {
2598| const compat_ulong_t *k = kbuf;
2599| while (count >= sizeof(*k) && !ret) {
2600| ret = putreg32(target, pos, *k++);
2601| count -= sizeof(*k);
2602| pos += sizeof(*k);
2603| }
2604| } else {
2605| const compat_ulong_t *u = ubuf;
2606| while (count >= sizeof(*u) && !ret) {
2607| compat_ulong_t word;
2608| ret = ({ int __gu_err; unsigned long __gu_val; do { __gu_err = 0; (void)0; switch ((sizeof(*(u++)))) { case 1: asm volatile("1: mov""b"" %2,%""b""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""b"" %""b""1,%""b""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=q"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; case 2: asm volatile("1: mov""w"" %2,%""w""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""w"" %""w""1,%""w""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=r"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; case 4: asm volatile("1: mov""l"" %2,%""k""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""l"" %""k""1,%""k""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=r"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; case 8: asm volatile("1: mov""q"" %2,%""""1\n" "2:\n" ".section .fixup,\"ax\"\n" "3: mov %3,%0\n" " xor""q"" %""""1,%""""1\n" " jmp 2b\n" ".previous\n" " .section __ex_table,\"a\"\n" " " ".balign 8" " " "\n" " " ".quad" " " "1b" "," "3b" "\n" " .previous\n" : "=r" (__gu_err), "=r"(__gu_val) : "m" ((*(struct __large_struct *)(((u++))))), "i" (-14), "0" (__gu_err)); break; default: (__gu_val) = __get_user_bad(); } } while (0); ((word)) = ( __typeof__(*((u++))))__gu_val; __gu_err; });
2609| if (ret)
2610| break;
2611| ret = putreg32(target, pos, word);
2612| count -= sizeof(*u);
2613| pos += sizeof(*u);
2614| }
2615| }
2616| return ret;
2617|}
2618|
2619|long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
2620| compat_ulong_t caddr, compat_ulong_t cdata)
2621|{
2622| unsigned long addr = caddr;
2623| unsigned long data = cdata;
2624| void *datap = compat_ptr(data);
2625| int ret;
2626| __u32 val;
2627|
2628| switch (request) {
2629| case 3:
2630| ret = getreg32(child, addr, &val);
2631| if (ret == 0)
2632| ret = __st_put_user_st__(val, (__u32 *)datap);
2633| break;
2634|
2635| case 6:
2636| ret = putreg32(child, addr, data);
2637| break;
2638|
2639| case 12:
2640| return copy_regset_to_user(child, &user_x86_32_view,
2641| REGSET_GENERAL,
2642| 0, sizeof(struct user_regs_struct32),
2643| datap);
2644|
2645| case 13:
2646| return copy_regset_from_user(child, &user_x86_32_view,
2647| REGSET_GENERAL, 0,
2648| sizeof(struct user_regs_struct32),
2649| datap);
2650|
2651| case 14:
2652| return copy_regset_to_user(child, &user_x86_32_view,
2653| REGSET_FP, 0,
2654| sizeof(struct user_i387_ia32_struct),
2655| datap);
2656|
2657| case 15:
2658| return copy_regset_from_user(
2659| child, &user_x86_32_view, REGSET_FP,
2660| 0, sizeof(struct user_i387_ia32_struct), datap);
2661|
2662| case 18:
2663| return copy_regset_to_user(child, &user_x86_32_view,
2664| REGSET_XFP, 0,
2665| sizeof(struct user32_fxsr_struct),
2666| datap);
2667|
2668| case 19:
2669| return copy_regset_from_user(child, &user_x86_32_view,
2670| REGSET_XFP, 0,
2671| sizeof(struct user32_fxsr_struct),
2672| datap);
2673|
2674| case 25:
2675| case 26:
2676| return arch_ptrace(child, request, addr, data);
2677|
2678| default:
2679| return compat_ptrace_request(child, request, addr, data);
2680| }
2681|
2682| return ret;
2683|}
2684|
2685|
2686|
2687|
2688|
2689|static struct user_regset x86_64_regsets[] = {
2690| [REGSET_GENERAL] = {
2691| .core_note_type = 1,
2692| .n = sizeof(struct user_regs_struct) / sizeof(long),
2693| .size = sizeof(long), .align = sizeof(long),
2694| .get = genregs_get, .set = genregs_set
2695| },
2696| [REGSET_FP] = {
2697| .core_note_type = 2,
2698| .n = sizeof(struct user_i387_struct) / sizeof(long),
2699| .size = sizeof(long), .align = sizeof(long),
2700| .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
2701| },
2702| [REGSET_XSTATE] = {
2703| .core_note_type = 0x202,
2704| .size = sizeof(u64), .align = sizeof(u64),
2705| .active = fpregs_active, .get = xstateregs_get,
2706| .set = xstateregs_set
2707| },
2708| [REGSET_IOPERM64] = {
2709| .core_note_type = 0x201,
2710| .n = ((65536/8)/sizeof(long)),
2711| .size = sizeof(long), .align = sizeof(long),
2712| .active = ioperm_active, .get = ioperm_get
2713| },
2714|};
2715|
2716|static const struct user_regset_view user_x86_64_view = {
2717| .name = "x86_64", .e_machine = 62,
2718| .regsets = x86_64_regsets, .n = (sizeof(x86_64_regsets) / sizeof((x86_64_regsets)[0]) + (sizeof(struct { int:-!!(0); })))
2719|};
2720|static struct user_regset x86_32_regsets[] = {
2721| [REGSET_GENERAL] = {
2722| .core_note_type = 1,
2723| .n = sizeof(struct user_regs_struct32) / sizeof(u32),
2724| .size = sizeof(u32), .align = sizeof(u32),
2725| .get = genregs32_get, .set = genregs32_set
2726| },
2727| [REGSET_FP] = {
2728| .core_note_type = 2,
2729| .n = sizeof(struct user_i387_ia32_struct) / sizeof(u32),
2730| .size = sizeof(u32), .align = sizeof(u32),
2731| .active = fpregs_active, .get = fpregs_get, .set = fpregs_set
2732| },
2733| [REGSET_XFP] = {
2734| .core_note_type = 0x46e62b7f,
2735| .n = sizeof(struct user32_fxsr_struct) / sizeof(u32),
2736| .size = sizeof(u32), .align = sizeof(u32),
2737| .active = xfpregs_active, .get = xfpregs_get, .set = xfpregs_set
2738| },
2739| [REGSET_XSTATE] = {
2740| .core_note_type = 0x202,
2741| .size = sizeof(u64), .align = sizeof(u64),
2742| .active = fpregs_active, .get = xstateregs_get,
2743| .set = xstateregs_set
2744| },
2745| [REGSET_TLS] = {
2746| .core_note_type = 0x200,
2747| .n = 3, .bias = 12,
2748| .size = sizeof(struct user_desc),
2749| .align = sizeof(struct user_desc),
2750| .active = regset_tls_active,
2751| .get = regset_tls_get, .set = regset_tls_set
2752| },
2753| [REGSET_IOPERM32] = {
2754| .core_note_type = 0x201,
2755| .n = (65536/8) / sizeof(u32),
2756| .size = sizeof(u32), .align = sizeof(u32),
2757| .active = ioperm_active, .get = ioperm_get
2758| },
2759|};
2760|
2761|static const struct user_regset_view user_x86_32_view = {
2762| .name = "i386", .e_machine = 3,
2763| .regsets = x86_32_regsets, .n = (sizeof(x86_32_regsets) / sizeof((x86_32_regsets)[0]) + (sizeof(struct { int:-!!(0); })))
2764|};
2765|
2766|
2767|
2768|
2769|
2770|
2771|u64 xstate_fx_sw_bytes[6];
2772|
2773|void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
2774|{
2775|
2776| x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
2777|
2778|
2779| x86_32_regsets[REGSET_XSTATE].n = size / sizeof(u64);
2780|
2781| xstate_fx_sw_bytes[0] = xstate_mask;
2782|}
2783|
2784|const struct user_regset_view *task_user_regset_view(struct task_struct *task)
2785|{
2786|
2787| if (test_tsk_thread_flag(task, 17))
2788|
2789|
2790| return &user_x86_32_view;
2791|
2792|
2793| return &user_x86_64_view;
2794|
2795|}
2796|
2797|static void fill_sigtrap_info(struct task_struct *tsk,
2798| struct pt_regs *regs,
2799| int error_code, int si_code,
2800| struct siginfo *info)
2801|{
2802| tsk->thread.trap_no = 1;
2803| tsk->thread.error_code = error_code;
2804|
2805| __st_memset_st__(info, 0, sizeof(*info));
2806| info->si_signo = 5;
2807| info->si_code = si_code;
2808| info->_sifields._sigfault._addr = user_mode_vm(regs) ? (void *)regs->ip : ((void *)0);
2809|}
2810|
2811|void user_single_step_siginfo(struct task_struct *tsk,
2812| struct pt_regs *regs,
2813| struct siginfo *info)
2814|{
2815| fill_sigtrap_info(tsk, regs, 0, ((3 << 16)|1), info);
2816|}
2817|
2818|void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
2819| int error_code, int si_code)
2820|{
2821| struct siginfo info;
2822|
2823| fill_sigtrap_info(tsk, regs, error_code, si_code, &info);
2824|
2825| force_sig_info(5, &info, tsk);
2826|}
2827| long syscall_trace_enter(struct pt_regs *regs)
2828|{
2829| long ret = 0;
2830| if (test_ti_thread_flag(current_thread_info(), 4))
2831| regs->flags |= 0x00000100;
2832|
2833|
2834| secure_computing(regs->orig_ax);
2835|
2836| if (test_ti_thread_flag(current_thread_info(), 6))
2837| ret = -1L;
2838|
2839| if ((ret || test_ti_thread_flag(current_thread_info(), 0)) &&
2840| tracehook_report_syscall_entry(regs))
2841| ret = -1L;
2842|
2843| if (test_ti_thread_flag(current_thread_info(), 28))
2844| trace_sys_enter(regs, regs->orig_ax);
2845|
2846| if (get_current()->audit_context) {
2847| if (is_compat_task())
2848| audit_syscall_entry((3|0x40000000),
2849| regs->orig_ax,
2850| regs->bx, regs->cx,
2851| regs->dx, regs->si);
2852|
2853| else
2854| audit_syscall_entry((62|0x80000000|0x40000000),
2855| regs->orig_ax,
2856| regs->di, regs->si,
2857| regs->dx, regs->r10);
2858|
2859| }
2860|
2861| return ret ?: regs->orig_ax;
2862|}
2863|
2864| void syscall_trace_leave(struct pt_regs *regs)
2865|{
2866| bool step;
2867|
2868| if (get_current()->audit_context)
2869| audit_syscall_exit(( ((long)(regs->ax))<0?2:1 ), regs->ax);
2870|
2871| if (test_ti_thread_flag(current_thread_info(), 28))
2872| trace_sys_exit(regs, regs->ax);
2873|
2874|
2875|
2876|
2877|
2878|
2879|
2880| step = test_ti_thread_flag(current_thread_info(), 4) &&
2881| !test_ti_thread_flag(current_thread_info(), 6);
2882| if (step || test_ti_thread_flag(current_thread_info(), 0))
2883| tracehook_report_syscall_exit(regs, step);
2884|}