summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-08-20 14:51:11 +0000
committerjhb <jhb@FreeBSD.org>2015-08-20 14:51:11 +0000
commitf335dbe91a1629a81fea4b13ca8833035511c4d0 (patch)
tree896e831b4318d4d968b07de02aaeb1b08498d600
parentedef59ae5270c40a1bc788aecacfae56ae788cd2 (diff)
downloadFreeBSD-src-f335dbe91a1629a81fea4b13ca8833035511c4d0.zip
FreeBSD-src-f335dbe91a1629a81fea4b13ca8833035511c4d0.tar.gz
Handle the conditional decoding of execve() argument and environment
arrays generically rather than duplicating a hack in all of the backends. - Add two new system call argument types and use them instead of StringArray for the argument and environment arguments execve and linux_execve. - Honor the -a/-e flags in the handling of these new types. - Instead of printing "<missing argument>" when the decoding is disabled, print the raw pointer value.
-rw-r--r--usr.bin/truss/amd64-fbsd.c22
-rw-r--r--usr.bin/truss/amd64-fbsd32.c22
-rw-r--r--usr.bin/truss/amd64-linux32.c22
-rw-r--r--usr.bin/truss/arm-fbsd.c22
-rw-r--r--usr.bin/truss/i386-fbsd.c22
-rw-r--r--usr.bin/truss/i386-linux.c22
-rw-r--r--usr.bin/truss/mips-fbsd.c22
-rw-r--r--usr.bin/truss/powerpc-fbsd.c22
-rw-r--r--usr.bin/truss/powerpc64-fbsd.c22
-rw-r--r--usr.bin/truss/sparc64-fbsd.c22
-rw-r--r--usr.bin/truss/syscall.h2
-rw-r--r--usr.bin/truss/syscalls.c22
12 files changed, 19 insertions, 225 deletions
diff --git a/usr.bin/truss/amd64-fbsd.c b/usr.bin/truss/amd64-fbsd.c
index 4a70a83..eeea8db 100644
--- a/usr.bin/truss/amd64-fbsd.c
+++ b/usr.bin/truss/amd64-fbsd.c
@@ -233,28 +233,6 @@ amd64_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/amd64-fbsd32.c b/usr.bin/truss/amd64-fbsd32.c
index 9b827f1..40aa152 100644
--- a/usr.bin/truss/amd64-fbsd32.c
+++ b/usr.bin/truss/amd64-fbsd32.c
@@ -233,28 +233,6 @@ amd64_fbsd32_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "freebsd32_execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "freebsd32_execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/amd64-linux32.c b/usr.bin/truss/amd64-linux32.c
index 77cacdb..b2d0d04 100644
--- a/usr.bin/truss/amd64-linux32.c
+++ b/usr.bin/truss/amd64-linux32.c
@@ -206,28 +206,6 @@ amd64_linux32_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "linux_execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "linux_execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/arm-fbsd.c b/usr.bin/truss/arm-fbsd.c
index 9de6162..8dc4d5b 100644
--- a/usr.bin/truss/arm-fbsd.c
+++ b/usr.bin/truss/arm-fbsd.c
@@ -264,28 +264,6 @@ arm_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/i386-fbsd.c b/usr.bin/truss/i386-fbsd.c
index ec6b8d6..ef326f0 100644
--- a/usr.bin/truss/i386-fbsd.c
+++ b/usr.bin/truss/i386-fbsd.c
@@ -227,28 +227,6 @@ i386_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c
index 2dd672e..6bd9309 100644
--- a/usr.bin/truss/i386-linux.c
+++ b/usr.bin/truss/i386-linux.c
@@ -206,28 +206,6 @@ i386_linux_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "linux_execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "linux_execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/mips-fbsd.c b/usr.bin/truss/mips-fbsd.c
index 7d064ba..d45241a 100644
--- a/usr.bin/truss/mips-fbsd.c
+++ b/usr.bin/truss/mips-fbsd.c
@@ -261,28 +261,6 @@ mips_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/powerpc-fbsd.c b/usr.bin/truss/powerpc-fbsd.c
index 2bfaf45..cdbd133 100644
--- a/usr.bin/truss/powerpc-fbsd.c
+++ b/usr.bin/truss/powerpc-fbsd.c
@@ -238,28 +238,6 @@ powerpc_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/powerpc64-fbsd.c b/usr.bin/truss/powerpc64-fbsd.c
index f02e04d..1f50429 100644
--- a/usr.bin/truss/powerpc64-fbsd.c
+++ b/usr.bin/truss/powerpc64-fbsd.c
@@ -226,28 +226,6 @@ powerpc64_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/sparc64-fbsd.c b/usr.bin/truss/sparc64-fbsd.c
index a5e9276..4e64c70 100644
--- a/usr.bin/truss/sparc64-fbsd.c
+++ b/usr.bin/truss/sparc64-fbsd.c
@@ -255,28 +255,6 @@ sparc64_syscall_entry(struct trussinfo *trussinfo, int nargs)
fprintf(trussinfo->outfile, "\n");
#endif
- if (fsc->name != NULL && (strcmp(fsc->name, "execve") == 0 ||
- strcmp(fsc->name, "exit") == 0)) {
- /*
- * XXX
- * This could be done in a more general
- * manner but it still wouldn't be very pretty.
- */
- if (strcmp(fsc->name, "execve") == 0) {
- if ((trussinfo->flags & EXECVEARGS) == 0) {
- if (fsc->s_args[1]) {
- free(fsc->s_args[1]);
- fsc->s_args[1] = NULL;
- }
- }
- if ((trussinfo->flags & EXECVEENVS) == 0) {
- if (fsc->s_args[2]) {
- free(fsc->s_args[2]);
- fsc->s_args[2] = NULL;
- }
- }
- }
- }
trussinfo->curthread->fsc = fsc;
}
diff --git a/usr.bin/truss/syscall.h b/usr.bin/truss/syscall.h
index db79fef..6f4d9a3 100644
--- a/usr.bin/truss/syscall.h
+++ b/usr.bin/truss/syscall.h
@@ -42,7 +42,7 @@ enum Argtype { None = 1, Hex, Octal, Int, LongHex, Name, Ptr, Stat, Ioctl, Quad,
Fcntlflag, Rusage, BinString, Shutdown, Resource, Rlimit, Timeval2,
Pathconf, Rforkflags, ExitStatus, Waitoptions, Idtype, Procctl,
LinuxSockArgs, Umtxop, Atfd, Atflags, Timespec2, Accessmode, Long,
- Sysarch };
+ Sysarch, ExecArgs, ExecEnv };
#define ARG_MASK 0xff
#define OUT 0x100
diff --git a/usr.bin/truss/syscalls.c b/usr.bin/truss/syscalls.c
index 91769fb..fac47f4 100644
--- a/usr.bin/truss/syscalls.c
+++ b/usr.bin/truss/syscalls.c
@@ -245,11 +245,11 @@ static struct syscall syscalls[] = {
.args = { { Int, 0 }, { BinString | IN, 1 }, { Int, 2 }, { Hex, 3 },
{ Sockaddr | IN, 4 }, { Ptr | IN, 5 } } },
{ .name = "execve", .ret_type = 1, .nargs = 3,
- .args = { { Name | IN, 0 }, { StringArray | IN, 1 },
- { StringArray | IN, 2 } } },
+ .args = { { Name | IN, 0 }, { ExecArgs | IN, 1 },
+ { ExecEnv | IN, 2 } } },
{ .name = "linux_execve", .ret_type = 1, .nargs = 3,
- .args = { { Name | IN, 0 }, { StringArray | IN, 1 },
- { StringArray | IN, 2 } } },
+ .args = { { Name | IN, 0 }, { ExecArgs | IN, 1 },
+ { ExecEnv | IN, 2 } } },
{ .name = "kldload", .ret_type = 0, .nargs = 1,
.args = { { Name | IN, 0 } } },
{ .name = "kldunload", .ret_type = 0, .nargs = 1,
@@ -912,6 +912,8 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
}
break;
}
+ case ExecArgs:
+ case ExecEnv:
case StringArray: {
uintptr_t addr;
union {
@@ -923,6 +925,18 @@ print_arg(struct syscall_args *sc, unsigned long *args, long retval,
int first, i;
/*
+ * Only parse argv[] and environment arrays from exec calls
+ * if requested.
+ */
+ if (((sc->type & ARG_MASK) == ExecArgs &&
+ (trussinfo->flags & EXECVEARGS) == 0) ||
+ ((sc->type & ARG_MASK) == ExecEnv &&
+ (trussinfo->flags & EXECVEENVS) == 0)) {
+ fprintf(fp, "0x%lx", args[sc->offset]);
+ break;
+ }
+
+ /*
* Read a page of pointers at a time. Punt if the top-level
* pointer is not aligned. Note that the first read is of
* a partial page.
OpenPOWER on IntegriCloud