Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146751135
D40095.id122076.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D40095.id122076.diff
View Options
diff --git a/sys/amd64/linux/linux.h b/sys/amd64/linux/linux.h
--- a/sys/amd64/linux/linux.h
+++ b/sys/amd64/linux/linux.h
@@ -277,6 +277,8 @@
struct syscall_info *si);
int linux_ptrace_getregs_machdep(struct thread *td, pid_t pid,
struct linux_pt_regset *l_regset);
+int linux_ptrace_peekuser(struct thread *td, pid_t pid,
+ void *addr, void *data);
#endif /* _KERNEL */
#endif /* !_AMD64_LINUX_H_ */
diff --git a/sys/amd64/linux/linux_machdep.c b/sys/amd64/linux/linux_machdep.c
--- a/sys/amd64/linux/linux_machdep.c
+++ b/sys/amd64/linux/linux_machdep.c
@@ -367,3 +367,34 @@
return (0);
}
+
+#define LINUX_URO(a,m) ((uintptr_t)a == offsetof(struct linux_pt_regset, m))
+
+int
+linux_ptrace_peekuser(struct thread *td, pid_t pid, void *addr, void *data)
+{
+ struct linux_pt_regset reg;
+ struct reg b_reg;
+ uint64_t val;
+ int error;
+
+ if ((uintptr_t)addr & (sizeof(data) -1) || (uintptr_t)addr < 0)
+ return (EIO);
+ if ((uintptr_t)addr >= sizeof(struct linux_pt_regset)) {
+ LINUX_RATELIMIT_MSG_OPT1("PTRACE_PEEKUSER offset %ld "
+ "not implemented; returning EINVAL", (uintptr_t)addr);
+ return (EINVAL);
+ }
+
+ if (LINUX_URO(addr, fs_base))
+ return (kern_ptrace(td, PT_GETFSBASE, pid, data, 0));
+ if (LINUX_URO(addr, gs_base))
+ return (kern_ptrace(td, PT_GETGSBASE, pid, data, 0));
+ if ((error = kern_ptrace(td, PT_GETREGS, pid, &b_reg, 0)) != 0)
+ return (error);
+ bsd_to_linux_regset(&b_reg, ®);
+ val = *(®.r15 + ((uintptr_t)addr / sizeof(reg.r15)));
+ return (copyout(&val, data, sizeof(val)));
+}
+
+#undef LINUX_URO
diff --git a/sys/amd64/linux32/linux.h b/sys/amd64/linux32/linux.h
--- a/sys/amd64/linux32/linux.h
+++ b/sys/amd64/linux32/linux.h
@@ -431,6 +431,8 @@
void bsd_to_linux_regset32(const struct reg32 *b_reg,
struct linux_pt_regset32 *l_regset);
+int linux_ptrace_peekuser(struct thread *td, pid_t pid,
+ void *addr, void *data);
extern bool linux32_emulate_i386;
#endif /* _KERNEL */
diff --git a/sys/amd64/linux32/linux32_machdep.c b/sys/amd64/linux32/linux32_machdep.c
--- a/sys/amd64/linux32/linux32_machdep.c
+++ b/sys/amd64/linux32/linux32_machdep.c
@@ -742,3 +742,12 @@
return ((cpu_stdext_feature & CPUID_STDEXT_SMAP) != 0 ?
futex_xorl_smap : futex_xorl_nosmap);
}
+
+int
+linux_ptrace_peekuser(struct thread *td, pid_t pid, void *addr, void *data)
+{
+
+ LINUX_RATELIMIT_MSG_OPT1("PTRACE_PEEKUSER offset %ld not implemented; "
+ "returning EINVAL", (uintptr_t)addr);
+ return (EINVAL);
+}
diff --git a/sys/arm64/linux/linux.h b/sys/arm64/linux/linux.h
--- a/sys/arm64/linux/linux.h
+++ b/sys/arm64/linux/linux.h
@@ -204,6 +204,8 @@
struct syscall_info *si);
int linux_ptrace_getregs_machdep(struct thread *td, pid_t pid,
struct linux_pt_regset *l_regset);
+int linux_ptrace_peekuser(struct thread *td, pid_t pid,
+ void *addr, void *data);
#endif /* _KERNEL */
#endif /* _ARM64_LINUX_H_ */
diff --git a/sys/arm64/linux/linux_machdep.c b/sys/arm64/linux/linux_machdep.c
--- a/sys/arm64/linux/linux_machdep.c
+++ b/sys/arm64/linux/linux_machdep.c
@@ -152,3 +152,11 @@
return (0);
}
+int
+linux_ptrace_peekuser(struct thread *td, pid_t pid, void *addr, void *data)
+{
+
+ LINUX_RATELIMIT_MSG_OPT1("PTRACE_PEEKUSER offset %ld not implemented; "
+ "returning EINVAL", (uintptr_t)addr);
+ return (EINVAL);
+}
diff --git a/sys/compat/linux/linux_ptrace.c b/sys/compat/linux/linux_ptrace.c
--- a/sys/compat/linux/linux_ptrace.c
+++ b/sys/compat/linux/linux_ptrace.c
@@ -100,11 +100,6 @@
#define LINUX_PTRACE_SYSCALL_INFO_ENTRY 1
#define LINUX_PTRACE_SYSCALL_INFO_EXIT 2
-#define LINUX_PTRACE_PEEKUSER_ORIG_RAX 120
-#define LINUX_PTRACE_PEEKUSER_RIP 128
-#define LINUX_PTRACE_PEEKUSER_CS 136
-#define LINUX_PTRACE_PEEKUSER_DS 184
-
static int
map_signum(int lsig, int *bsigp)
{
@@ -179,44 +174,6 @@
return (error);
}
-static int
-linux_ptrace_peekuser(struct thread *td, pid_t pid, void *addr, void *data)
-{
- struct reg b_reg;
- uint64_t val;
- int error;
-
- error = kern_ptrace(td, PT_GETREGS, pid, &b_reg, 0);
- if (error != 0)
- return (error);
-
- switch ((uintptr_t)addr) {
-#ifdef __amd64__
- case LINUX_PTRACE_PEEKUSER_ORIG_RAX:
- val = b_reg.r_rax;
- break;
- case LINUX_PTRACE_PEEKUSER_RIP:
- val = b_reg.r_rip;
- break;
- case LINUX_PTRACE_PEEKUSER_CS:
- val = b_reg.r_cs;
- break;
- case LINUX_PTRACE_PEEKUSER_DS:
- val = b_reg.r_ds;
- break;
-#endif /* __amd64__ */
- default:
- linux_msg(td, "PTRACE_PEEKUSER offset %ld not implemented; "
- "returning EINVAL", (uintptr_t)addr);
- return (EINVAL);
- }
-
- error = copyout(&val, data, sizeof(val));
- td->td_retval[0] = error;
-
- return (error);
-}
-
static int
linux_ptrace_pokeuser(struct thread *td, pid_t pid, void *addr, void *data)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 6, 7:12 AM (5 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29317043
Default Alt Text
D40095.id122076.diff (4 KB)
Attached To
Mode
D40095: linux(4): Make ptrace_peekusr machine dependend
Attached
Detach File
Event Timeline
Log In to Comment