1 /* Copyright (C) 1995-1998,2000,2003,2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #include <sys/types.h>
21 #include <sys/ptrace.h>
27 #include <sys/syscall.h>
28 #include <bp-checks.h>
31 ptrace (enum __ptrace_request request, ...)
38 va_start (ap, request);
39 pid = va_arg (ap, pid_t);
40 addr = va_arg (ap, void *);
41 data = va_arg (ap, void *);
44 if (request > 0 && request < 4)
47 #if __BOUNDED_POINTERS__
56 (void) CHECK_1 ((int *) addr);
57 (void) CHECK_1 ((int *) data);
63 (void) CHECK_1 ((struct user_regs_struct *) data);
65 /* We don't know the size of data, so the best we can do is ensure
66 that `data' is valid for at least one word. */
67 (void) CHECK_1 ((int *) data);
71 case PTRACE_GETFPREGS:
72 case PTRACE_SETFPREGS:
74 (void) CHECK_1 ((struct user_fpregs_struct *) data);
76 /* We don't know the size of data, so the best we can do is ensure
77 that `data' is valid for at least one word. */
78 (void) CHECK_1 ((int *) data);
82 case PTRACE_GETFPXREGS:
83 case PTRACE_SETFPXREGS:
85 (void) CHECK_1 ((struct user_fpxregs_struct *) data);
87 /* We don't know the size of data, so the best we can do is ensure
88 that `data' is valid for at least one word. */
89 (void) CHECK_1 ((int *) data);
93 case PTRACE_GETSIGINFO:
94 case PTRACE_SETSIGINFO:
95 (void) CHECK_1 ((siginfo_t *) data);
98 case PTRACE_GETEVENTMSG:
99 (void) CHECK_1 ((unsigned long *) data);
102 case PTRACE_SETOPTIONS:
103 (void) CHECK_1 ((long *) data);
109 case PTRACE_SINGLESTEP:
113 /* Neither `data' nor `addr' needs any checks. */
118 res = INLINE_SYSCALL (ptrace, 4, request, pid,
119 __ptrvalue (addr), __ptrvalue (data));
120 if (res >= 0 && request > 0 && request < 4)