Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108591998
D47127.id144912.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
D47127.id144912.diff
View Options
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -354,7 +354,11 @@
exec_args_get_begin_envv(args) - args->begin_argv);
AUDIT_ARG_ENVV(exec_args_get_begin_envv(args), args->envc,
args->endp - exec_args_get_begin_envv(args));
-
+#ifdef KTRACE
+ if (KTRPOINT(td, KTR_ARGS)) {
+ ktrargs(args);
+ }
+#endif
/* Must have at least one argument. */
if (args->argc == 0) {
exec_free_args(args);
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -559,6 +559,33 @@
ktr_submitrequest(curthread, req);
}
+void
+ktrargs(struct image_args *args)
+{
+ struct ktr_request *req;
+ int argc = exec_args_get_begin_envv(args) - args->begin_argv;
+ char* argv = malloc(argc + 1, M_KTRACE, M_WAITOK);
+ bcopy(args->begin_argv, argv, argc);
+ bcopy("\0", argv + argc, 1);
+ int envc = args->endp - exec_args_get_begin_envv(args);
+ char* envv = malloc(envc + 1, M_KTRACE, M_WAITOK);
+ bcopy(exec_args_get_begin_envv(args), envv, envc);
+ bcopy("\0", envv + envc, 1);
+ char* buf = malloc(argc + envc + 2, M_KTRACE, M_WAITOK);
+ bcopy(argv, buf, argc + 1);
+ bcopy(envv, buf + argc + 2, envc + 1);
+ req = ktr_getrequest(KTR_ARGS);
+ if (req == NULL) {
+ if (buf != NULL)
+ free(buf, M_KTRACE);
+ return;
+ }
+ req->ktr_header.ktr_len = argc + envc + 2;
+ req->ktr_buffer = buf;
+ ktr_submitrequest(curthread, req);
+}
+
+
void
ktrsysret(int code, int error, register_t retval)
{
diff --git a/sys/sys/ktrace.h b/sys/sys/ktrace.h
--- a/sys/sys/ktrace.h
+++ b/sys/sys/ktrace.h
@@ -37,6 +37,12 @@
#include <sys/signal.h>
#include <sys/socket.h>
#include <sys/_uio.h>
+#ifndef _KERNEL
+// for imgact to compile in userland, we need to include this
+#include <stdbool.h>
+#endif
+#include <sys/imgact.h>
+
/*
* operations to ktrace system call (KTROP(op))
@@ -263,6 +269,8 @@
*/
};
+#define KTR_ARGS 16
+
/*
* KTR_DROP - If this bit is set in ktr_type, then at least one event
* between the previous record and this record was dropped.
@@ -335,6 +343,7 @@
void ktrstruct_error(const char *, const void *, size_t, int);
void ktrstructarray(const char *, enum uio_seg, const void *, int, size_t);
void ktrcapfail(enum ktr_cap_violation, const void *);
+void ktrargs(struct image_args*);
#define ktrcaprights(s) \
ktrstruct("caprights", (s), sizeof(cap_rights_t))
#define ktritimerval(s) \
diff --git a/usr.bin/kdump/kdump.c b/usr.bin/kdump/kdump.c
--- a/usr.bin/kdump/kdump.c
+++ b/usr.bin/kdump/kdump.c
@@ -117,6 +117,7 @@
void ktrbitset(char *, struct bitset *, size_t);
void ktrsyscall_freebsd(struct ktr_syscall *ktr, register_t **resip,
int *resnarg, char *resc, u_int sv_flags);
+void ktrargs(struct image_args* args, int num);
void usage(void);
#define TIMESTAMP_NONE 0x0
@@ -259,6 +260,12 @@
printf("<invalid>%u", rem);
}
+static void
+ktrargs(struct image_args* args, int len)
+{
+ printf("Entered ktrargs in userspace, beginning of argv is %s and len is %d\n", args->begin_argv, len);
+}
+
static void
decode_fileflags(fflags_t value)
{
@@ -515,6 +522,9 @@
case KTR_STRUCT_ARRAY:
ktrstructarray((struct ktr_struct_array *)m, ktrlen);
break;
+ case KTR_ARGS:
+ ktrargs((struct image_args*)m, ktrlen);
+ break;
default:
printf("\n");
break;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 27, 5:55 PM (3 h, 53 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16202317
Default Alt Text
D47127.id144912.diff (3 KB)
Attached To
Mode
D47127: Add kernelspace and userspace parts of ktrargs()
Attached
Detach File
Event Timeline
Log In to Comment