On 13.07.2020 20:43, Ted Unangst wrote:
On 2020-07-09, Theo de Raadt wrote:
Added a -T option to ktrace for transparency. I got ambitious here and made
it take suboptions, anticipating that other transparency modifications may
be desired.
Please don't do that.
Here is a simpler version.
OK.
Index: lib/libc/dlfcn/init.c
===================================================================
RCS file: /home/cvs/src/lib/libc/dlfcn/init.c,v
retrieving revision 1.8
diff -u -p -r1.8 init.c
--- lib/libc/dlfcn/init.c 6 Jul 2020 13:33:05 -0000 1.8
+++ lib/libc/dlfcn/init.c 13 Jul 2020 17:36:04 -0000
@@ -114,6 +114,8 @@ _libc_preinit(int argc, char **argv, cha
_timekeep->tk_version != TK_VERSION)
_timekeep = NULL;
}
+ if (issetugid() == 0 && getenv("LIBC_NOUSERTC"))
+ _timekeep = NULL;
break;
}
}
Index: usr.bin/ktrace/ktrace.1
===================================================================
RCS file: /home/cvs/src/usr.bin/ktrace/ktrace.1,v
retrieving revision 1.30
diff -u -p -r1.30 ktrace.1
--- usr.bin/ktrace/ktrace.1 15 May 2019 15:36:59 -0000 1.30
+++ usr.bin/ktrace/ktrace.1 13 Jul 2020 17:38:22 -0000
@@ -37,13 +37,13 @@
.Nd enable kernel process tracing
.Sh SYNOPSIS
.Nm ktrace
-.Op Fl aBCcdi
+.Op Fl aCcdi
.Op Fl f Ar trfile
.Op Fl g Ar pgid
.Op Fl p Ar pid
.Op Fl t Ar trstr
.Nm ktrace
-.Op Fl adi
+.Op Fl aBdiT
.Op Fl f Ar trfile
.Op Fl t Ar trstr
.Ar command
@@ -109,6 +109,8 @@ processes.
Enable (disable) tracing on the indicated process ID (only one
.Fl p
flag is permitted).
+.It Fl T
+Disable userland timekeeping, making time related system calls more prevalent.
.It Fl t Ar trstr
Select which information to put into the dump file.
The argument can contain one or more of the following letters.
Index: usr.bin/ktrace/ktrace.c
===================================================================
RCS file: /home/cvs/src/usr.bin/ktrace/ktrace.c,v
retrieving revision 1.36
diff -u -p -r1.36 ktrace.c
--- usr.bin/ktrace/ktrace.c 28 Jun 2019 13:35:01 -0000 1.36
+++ usr.bin/ktrace/ktrace.c 13 Jul 2020 17:37:06 -0000
@@ -100,7 +100,7 @@ main(int argc, char *argv[])
usage();
}
} else {
- while ((ch = getopt(argc, argv, "aBCcdf:g:ip:t:")) != -1)
+ while ((ch = getopt(argc, argv, "aBCcdf:g:ip:t:T")) != -1)
switch ((char)ch) {
case 'a':
append = 1;
@@ -140,6 +140,9 @@ main(int argc, char *argv[])
usage();
}
break;
+ case 'T':
+ putenv("LIBC_NOUSERTC=");
+ break;
default:
usage();
}
@@ -240,9 +243,9 @@ usage(void)
" [-u trspec] command\n",
__progname);
else
- fprintf(stderr, "usage: %s [-aBCcdi] [-f trfile] [-g pgid]"
+ fprintf(stderr, "usage: %s [-aCcdi] [-f trfile] [-g pgid]"
" [-p pid] [-t trstr]\n"
- " %s [-adi] [-f trfile] [-t trstr] command\n",
+ " %s [-aBdiT] [-f trfile] [-t trstr] command\n",
__progname, __progname);
exit(1);
}