Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F149148029
D50758.1789594527.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D50758.1789594527.diff
View Options
diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c
--- a/sys/compat/freebsd32/freebsd32_misc.c
+++ b/sys/compat/freebsd32/freebsd32_misc.c
@@ -1177,6 +1177,9 @@
pscr_args[i] = pscr_args32[i];
r.sr.pscr_args = pscr_args;
break;
+ case PT_FIRSTLINUX ... PT_LASTLINUX:
+ error = EINVAL;
+ break;
default:
addr = uap->addr;
break;
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
@@ -386,21 +386,11 @@
if (lwpinfo.pl_flags & PL_FLAG_SCE) {
si.op = LINUX_PTRACE_SYSCALL_INFO_ENTRY;
si.entry.nr = lwpinfo.pl_syscall_code;
- /*
- * The use of PT_GET_SC_ARGS there is special,
- * implementation of PT_GET_SC_ARGS for Linux-ABI
- * callers emulates Linux bug which strace(1) depends
- * on: at initialization it tests whether ptrace works
- * by calling close(2), or some other single-argument
- * syscall, _with six arguments_, and then verifies
- * whether it can fetch them all using this API;
- * otherwise it bails out.
- */
- error = kern_ptrace(td, PT_GET_SC_ARGS, pid,
- &si.entry.args, sizeof(si.entry.args));
+ error = kern_ptrace(td, PT_LINUX_GET_SC_ARGS, pid,
+ si.entry.args, sizeof(si.entry.args));
if (error != 0) {
- linux_msg(td, "PT_GET_SC_ARGS failed with error %d",
- error);
+ linux_msg(td,
+ "PT_LINUX_GET_SC_ARGS failed with error %d", error);
return (error);
}
} else if (lwpinfo.pl_flags & PL_FLAG_SCX) {
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -690,6 +690,9 @@
break;
r.sr.pscr_args = pscr_args;
break;
+ case PT_FIRSTLINUX ... PT_LASTLINUX:
+ error = EINVAL;
+ break;
default:
addr = uap->addr;
break;
@@ -1166,7 +1169,9 @@
break;
case PT_GET_SC_ARGS:
- CTR1(KTR_PTRACE, "PT_GET_SC_ARGS: pid %d", p->p_pid);
+ case PT_LINUX_GET_SC_ARGS:
+ CTR2(KTR_PTRACE, "%s: pid %d", req == PT_GET_SC_ARGS ?
+ "PT_GET_SC_ARGS" : "PT_LINUX_GET_SC_ARGS", p->p_pid);
if (((td2->td_dbgflags & (TDB_SCE | TDB_SCX)) == 0 &&
td2->td_sa.code == 0)
#ifdef COMPAT_FREEBSD32
@@ -1176,11 +1181,21 @@
error = EINVAL;
break;
}
- bzero(addr, sizeof(td2->td_sa.args));
- /* See the explanation in linux_ptrace_get_syscall_info(). */
- bcopy(td2->td_sa.args, addr, SV_PROC_ABI(td->td_proc) ==
- SV_ABI_LINUX ? sizeof(td2->td_sa.args) :
- td2->td_sa.callp->sy_narg * sizeof(syscallarg_t));
+ if (req == PT_GET_SC_ARGS) {
+ bzero(addr, sizeof(td2->td_sa.args));
+ bcopy(td2->td_sa.args, addr, td2->td_sa.callp->sy_narg *
+ sizeof(syscallarg_t));
+ } else {
+ /*
+ * Emulate a Linux bug which which strace(1) depends on:
+ * at initialization it tests whether ptrace works by
+ * calling close(2), or some other single-argument
+ * syscall, _with six arguments_, and then verifies
+ * whether it can fetch them all using this API;
+ * otherwise it bails out.
+ */
+ bcopy(td2->td_sa.args, addr, 6 * sizeof(syscallarg_t));
+ }
break;
case PT_GET_SC_RET:
diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h
--- a/sys/sys/ptrace.h
+++ b/sys/sys/ptrace.h
@@ -87,8 +87,16 @@
#define PT_SC_REMOTE 44 /* Execute a syscall */
#define PT_FIRSTMACH 64 /* for machine-specific requests */
+#define PT_LASTMACH 127
#include <machine/ptrace.h> /* machine-specific requests, if any */
+#ifdef _KERNEL
+/* Space for Linux ptrace emulation. */
+#define PT_FIRSTLINUX 128
+#define PT_LASTLINUX 191
+#define PT_LINUX_GET_SC_ARGS (PT_FIRSTLINUX + 0)
+#endif
+
/* Events used with PT_GET_EVENT_MASK and PT_SET_EVENT_MASK */
#define PTRACE_EXEC 0x0001
#define PTRACE_SCE 0x0002
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Sep 16, 9:35 PM (7 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29707762
Default Alt Text
D50758.1789594527.diff (3 KB)
Attached To
Mode
D50758: linux: Fix usage of ptrace(PT_GET_SC_ARGS)
Attached
Detach File
Event Timeline
Log In to Comment