Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151530105
D50758.id156991.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D50758.id156991.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 PTLINUX_FIRST ... PTLINUX_LAST:
+ 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, PTLINUX_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 PTLINUX_FIRST ... PTLINUX_LAST:
+ 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 PTLINUX_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 PTLINUX_FIRST 128
+#define PTLINUX_LAST 191
+#define PTLINUX_GET_SC_ARGS (PTLINUX_FIRST + 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
Fri, Apr 10, 1:16 AM (16 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31166383
Default Alt Text
D50758.id156991.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