History log of /openbsd-current/usr.bin/kdump/ktrstruct.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.31 29-Dec-2022 guenther

Add ktrace struct tracepoints for siginfo_t to the kernel side of
waitid(2) and __thrsigdivert(2) and teach kdump(1) to handle them.
Also report more from the siginfo_t inside PSIG tracepoints.

ok mpi@


Revision tags: OPENBSD_7_2_BASE
# 1.30 08-Sep-2022 mbuhl

Support the sendmmsg and recvmmsg system calls.
Input guenther@
OK bluhm@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.29 21-Dec-2020 otto

Show scope id when set; ok florian@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.28 17-Nov-2018 claudio

Be more careful when dumping cmsghdr struct. In the SCM_RIGHTS case an
extra check for a truncated cmsghdr needs to be done since the embeded
lenght may be longer than the supplied buffer (MSG_CTRUNC case).
OK deraadt@


# 1.27 08-Nov-2018 otto

Peldge and unveil can have struct data size 0. While there, fix "fds"
handler; ok guenther@


# 1.26 05-Nov-2018 anton

trace struct flock; ok visa@


Revision tags: OPENBSD_6_4_BASE
# 1.25 13-Jul-2018 beck

Unveiling unveil(2).
This brings unveil into the tree, disabled by default - Currently
this will return EPERM on all attempts to use it until we are
fully certain it is ready for people to start using, but this
now allows for others to do more tweaking and experimentation.

Still needs to send the unveil's across forks and execs before
fully enabling.

Many thanks to robert@ and deraadt@ for extensive testing.
ok deraadt@


Revision tags: OPENBSD_6_3_BASE
# 1.24 12-Dec-2017 deraadt

pledge()'s 2nd argument becomes char *execpromises, which becomes the
pledge for a new execve image immediately upon start. Also introduces
"error" which makes violations return -1 ENOSYS instead of killing the
program ("error" may not be handed to a setuid/setgid program, which
may be missing/ignoring syscall return values and would continue with
inconsistant state)
Discussion with many
florian has used this to improve the strictness of a daemon


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 08-Oct-2016 guenther

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@


# 1.22 26-Aug-2016 guenther

Pull in <sys/select.h> for fd_set

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.21 07-Jun-2016 deraadt

ktrace support for pollfd[] arrays
ok guenther


# 1.20 07-Jun-2016 tedu

add a hack to avoid printing the long string format for times in the 70s.
this is usually a result of a timestamp which hasn't been identified as
"relative" and decoding them to precise dates long in the past is a
distraction. (eagerly awaiting a cleaner, better diff to do the same.)


# 1.19 22-May-2016 guenther

On hppa, function pointer comparison can require dereferencing them.
kdump can't do that for a sigaction sa_handler pointer from the trace,
so cast to void* to suppress it.

ok deraadt@


# 1.18 24-Mar-2016 guenther

Display NAMI records and AF_UNIX socket paths with vis, using
VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL; add the latter three flags
to the existing vis encoding of exec argv/environ and pledge
requests/paths.
Delete local variables left unused when showbuf() and showbufc() were split

ok otto@ millert@


# 1.17 05-Mar-2016 guenther

Make the fd_set* passed to FD_ISSET() non-const: the non-macro version is
stricter (per POSIX, dang it)


Revision tags: OPENBSD_5_9_BASE
# 1.16 14-Jan-2016 guenther

Display struct event more like other structs: show all members and use cpp
define names. Use the mksubr infrastructure for EVFILT_*,
EV_*, and (with some kludging) NOTE_* values. If EV_ERROR is set,
include the errno string for the data member.

Also, do MSG_* parsing on the msg_flags member of struct msghdr.

ok millert@


# 1.15 06-Jan-2016 tedu

print more info about kevent


# 1.14 25-Dec-2015 tedu

very basic kevent printing


# 1.13 18-Oct-2015 guenther

Use offsetof() instead of adding the sizes of the preceeding struct members

ok millert@


# 1.12 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.11 03-Oct-2015 guenther

Add ktracing of tame()'s arguments' values

"every tool helps" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.10 28-Jul-2015 guenther

Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.

ok millert@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.9 16-Dec-2014 jsg

Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer.
ok guenther@


# 1.8 15-Dec-2014 guenther

Eliminate the -r option and always do sysctl OID, username, groupname,
and ctime presentation, but combined with the numeric form ala 0<"root">.
Do username and groupname presentation on syscall arguments and retvals.

ok millert@ otto@


# 1.7 20-Nov-2014 krw

Be more POSIXy by using blksize_t (a.k.a. int32) for st_blksize, rather than the current uint32_t.

ok guenther@ deraadt@


# 1.6 13-Oct-2014 guenther

Add dumping of struct dqblk done by quotactl(2)

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.5 11-Jul-2014 tedu

remove (commented) bluetooth reference


# 1.4 22-Jun-2014 guenther

Negative time{spec,val}s with non-zero subsecond parts require extra
handling. E.g., a timeval of { -1, 1 } is -0.999999, as the subsecond
part is always positive.

Also, update the list of sockaddr_* types that we might add support for


Revision tags: OPENBSD_5_5_BASE
# 1.3 24-Jan-2014 guenther

exit1() needs to do a final aggregation of the thread's [us]ticks
and runtime to the process totals. Also, add ktracing of struct
rusage in wait4() and getrusage().

problem pointed out by tedu@
ok deraadt@


# 1.2 09-Sep-2013 guenther

Recognize the UTIME_OMIT and UTIME_NOW values when printing timespecs

ok otto@


# 1.1 22-Aug-2013 guenther

Split out from kdump.c the ktrstruct.c bits into ktrstruct.c
Reduce the #includes to take advantage of that.

ok millert@ otto@


# 1.30 08-Sep-2022 mbuhl

Support the sendmmsg and recvmmsg system calls.
Input guenther@
OK bluhm@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.29 21-Dec-2020 otto

Show scope id when set; ok florian@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.28 17-Nov-2018 claudio

Be more careful when dumping cmsghdr struct. In the SCM_RIGHTS case an
extra check for a truncated cmsghdr needs to be done since the embeded
lenght may be longer than the supplied buffer (MSG_CTRUNC case).
OK deraadt@


# 1.27 08-Nov-2018 otto

Peldge and unveil can have struct data size 0. While there, fix "fds"
handler; ok guenther@


# 1.26 05-Nov-2018 anton

trace struct flock; ok visa@


Revision tags: OPENBSD_6_4_BASE
# 1.25 13-Jul-2018 beck

Unveiling unveil(2).
This brings unveil into the tree, disabled by default - Currently
this will return EPERM on all attempts to use it until we are
fully certain it is ready for people to start using, but this
now allows for others to do more tweaking and experimentation.

Still needs to send the unveil's across forks and execs before
fully enabling.

Many thanks to robert@ and deraadt@ for extensive testing.
ok deraadt@


Revision tags: OPENBSD_6_3_BASE
# 1.24 12-Dec-2017 deraadt

pledge()'s 2nd argument becomes char *execpromises, which becomes the
pledge for a new execve image immediately upon start. Also introduces
"error" which makes violations return -1 ENOSYS instead of killing the
program ("error" may not be handed to a setuid/setgid program, which
may be missing/ignoring syscall return values and would continue with
inconsistant state)
Discussion with many
florian has used this to improve the strictness of a daemon


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 08-Oct-2016 guenther

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@


# 1.22 26-Aug-2016 guenther

Pull in <sys/select.h> for fd_set

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.21 07-Jun-2016 deraadt

ktrace support for pollfd[] arrays
ok guenther


# 1.20 07-Jun-2016 tedu

add a hack to avoid printing the long string format for times in the 70s.
this is usually a result of a timestamp which hasn't been identified as
"relative" and decoding them to precise dates long in the past is a
distraction. (eagerly awaiting a cleaner, better diff to do the same.)


# 1.19 22-May-2016 guenther

On hppa, function pointer comparison can require dereferencing them.
kdump can't do that for a sigaction sa_handler pointer from the trace,
so cast to void* to suppress it.

ok deraadt@


# 1.18 24-Mar-2016 guenther

Display NAMI records and AF_UNIX socket paths with vis, using
VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL; add the latter three flags
to the existing vis encoding of exec argv/environ and pledge
requests/paths.
Delete local variables left unused when showbuf() and showbufc() were split

ok otto@ millert@


# 1.17 05-Mar-2016 guenther

Make the fd_set* passed to FD_ISSET() non-const: the non-macro version is
stricter (per POSIX, dang it)


Revision tags: OPENBSD_5_9_BASE
# 1.16 14-Jan-2016 guenther

Display struct event more like other structs: show all members and use cpp
define names. Use the mksubr infrastructure for EVFILT_*,
EV_*, and (with some kludging) NOTE_* values. If EV_ERROR is set,
include the errno string for the data member.

Also, do MSG_* parsing on the msg_flags member of struct msghdr.

ok millert@


# 1.15 06-Jan-2016 tedu

print more info about kevent


# 1.14 25-Dec-2015 tedu

very basic kevent printing


# 1.13 18-Oct-2015 guenther

Use offsetof() instead of adding the sizes of the preceeding struct members

ok millert@


# 1.12 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.11 03-Oct-2015 guenther

Add ktracing of tame()'s arguments' values

"every tool helps" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.10 28-Jul-2015 guenther

Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.

ok millert@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.9 16-Dec-2014 jsg

Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer.
ok guenther@


# 1.8 15-Dec-2014 guenther

Eliminate the -r option and always do sysctl OID, username, groupname,
and ctime presentation, but combined with the numeric form ala 0<"root">.
Do username and groupname presentation on syscall arguments and retvals.

ok millert@ otto@


# 1.7 20-Nov-2014 krw

Be more POSIXy by using blksize_t (a.k.a. int32) for st_blksize, rather than the current uint32_t.

ok guenther@ deraadt@


# 1.6 13-Oct-2014 guenther

Add dumping of struct dqblk done by quotactl(2)

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.5 11-Jul-2014 tedu

remove (commented) bluetooth reference


# 1.4 22-Jun-2014 guenther

Negative time{spec,val}s with non-zero subsecond parts require extra
handling. E.g., a timeval of { -1, 1 } is -0.999999, as the subsecond
part is always positive.

Also, update the list of sockaddr_* types that we might add support for


Revision tags: OPENBSD_5_5_BASE
# 1.3 24-Jan-2014 guenther

exit1() needs to do a final aggregation of the thread's [us]ticks
and runtime to the process totals. Also, add ktracing of struct
rusage in wait4() and getrusage().

problem pointed out by tedu@
ok deraadt@


# 1.2 09-Sep-2013 guenther

Recognize the UTIME_OMIT and UTIME_NOW values when printing timespecs

ok otto@


# 1.1 22-Aug-2013 guenther

Split out from kdump.c the ktrstruct.c bits into ktrstruct.c
Reduce the #includes to take advantage of that.

ok millert@ otto@


# 1.29 21-Dec-2020 otto

Show scope id when set; ok florian@


Revision tags: OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE OPENBSD_6_8_BASE
# 1.28 17-Nov-2018 claudio

Be more careful when dumping cmsghdr struct. In the SCM_RIGHTS case an
extra check for a truncated cmsghdr needs to be done since the embeded
lenght may be longer than the supplied buffer (MSG_CTRUNC case).
OK deraadt@


# 1.27 08-Nov-2018 otto

Peldge and unveil can have struct data size 0. While there, fix "fds"
handler; ok guenther@


# 1.26 05-Nov-2018 anton

trace struct flock; ok visa@


Revision tags: OPENBSD_6_4_BASE
# 1.25 13-Jul-2018 beck

Unveiling unveil(2).
This brings unveil into the tree, disabled by default - Currently
this will return EPERM on all attempts to use it until we are
fully certain it is ready for people to start using, but this
now allows for others to do more tweaking and experimentation.

Still needs to send the unveil's across forks and execs before
fully enabling.

Many thanks to robert@ and deraadt@ for extensive testing.
ok deraadt@


Revision tags: OPENBSD_6_3_BASE
# 1.24 12-Dec-2017 deraadt

pledge()'s 2nd argument becomes char *execpromises, which becomes the
pledge for a new execve image immediately upon start. Also introduces
"error" which makes violations return -1 ENOSYS instead of killing the
program ("error" may not be handed to a setuid/setgid program, which
may be missing/ignoring syscall return values and would continue with
inconsistant state)
Discussion with many
florian has used this to improve the strictness of a daemon


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 08-Oct-2016 guenther

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@


# 1.22 26-Aug-2016 guenther

Pull in <sys/select.h> for fd_set

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.21 07-Jun-2016 deraadt

ktrace support for pollfd[] arrays
ok guenther


# 1.20 07-Jun-2016 tedu

add a hack to avoid printing the long string format for times in the 70s.
this is usually a result of a timestamp which hasn't been identified as
"relative" and decoding them to precise dates long in the past is a
distraction. (eagerly awaiting a cleaner, better diff to do the same.)


# 1.19 22-May-2016 guenther

On hppa, function pointer comparison can require dereferencing them.
kdump can't do that for a sigaction sa_handler pointer from the trace,
so cast to void* to suppress it.

ok deraadt@


# 1.18 24-Mar-2016 guenther

Display NAMI records and AF_UNIX socket paths with vis, using
VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL; add the latter three flags
to the existing vis encoding of exec argv/environ and pledge
requests/paths.
Delete local variables left unused when showbuf() and showbufc() were split

ok otto@ millert@


# 1.17 05-Mar-2016 guenther

Make the fd_set* passed to FD_ISSET() non-const: the non-macro version is
stricter (per POSIX, dang it)


Revision tags: OPENBSD_5_9_BASE
# 1.16 14-Jan-2016 guenther

Display struct event more like other structs: show all members and use cpp
define names. Use the mksubr infrastructure for EVFILT_*,
EV_*, and (with some kludging) NOTE_* values. If EV_ERROR is set,
include the errno string for the data member.

Also, do MSG_* parsing on the msg_flags member of struct msghdr.

ok millert@


# 1.15 06-Jan-2016 tedu

print more info about kevent


# 1.14 25-Dec-2015 tedu

very basic kevent printing


# 1.13 18-Oct-2015 guenther

Use offsetof() instead of adding the sizes of the preceeding struct members

ok millert@


# 1.12 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.11 03-Oct-2015 guenther

Add ktracing of tame()'s arguments' values

"every tool helps" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.10 28-Jul-2015 guenther

Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.

ok millert@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.9 16-Dec-2014 jsg

Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer.
ok guenther@


# 1.8 15-Dec-2014 guenther

Eliminate the -r option and always do sysctl OID, username, groupname,
and ctime presentation, but combined with the numeric form ala 0<"root">.
Do username and groupname presentation on syscall arguments and retvals.

ok millert@ otto@


# 1.7 20-Nov-2014 krw

Be more POSIXy by using blksize_t (a.k.a. int32) for st_blksize, rather than the current uint32_t.

ok guenther@ deraadt@


# 1.6 13-Oct-2014 guenther

Add dumping of struct dqblk done by quotactl(2)

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.5 11-Jul-2014 tedu

remove (commented) bluetooth reference


# 1.4 22-Jun-2014 guenther

Negative time{spec,val}s with non-zero subsecond parts require extra
handling. E.g., a timeval of { -1, 1 } is -0.999999, as the subsecond
part is always positive.

Also, update the list of sockaddr_* types that we might add support for


Revision tags: OPENBSD_5_5_BASE
# 1.3 24-Jan-2014 guenther

exit1() needs to do a final aggregation of the thread's [us]ticks
and runtime to the process totals. Also, add ktracing of struct
rusage in wait4() and getrusage().

problem pointed out by tedu@
ok deraadt@


# 1.2 09-Sep-2013 guenther

Recognize the UTIME_OMIT and UTIME_NOW values when printing timespecs

ok otto@


# 1.1 22-Aug-2013 guenther

Split out from kdump.c the ktrstruct.c bits into ktrstruct.c
Reduce the #includes to take advantage of that.

ok millert@ otto@


# 1.28 17-Nov-2018 claudio

Be more careful when dumping cmsghdr struct. In the SCM_RIGHTS case an
extra check for a truncated cmsghdr needs to be done since the embeded
lenght may be longer than the supplied buffer (MSG_CTRUNC case).
OK deraadt@


# 1.27 08-Nov-2018 otto

Peldge and unveil can have struct data size 0. While there, fix "fds"
handler; ok guenther@


# 1.26 05-Nov-2018 anton

trace struct flock; ok visa@


Revision tags: OPENBSD_6_4_BASE
# 1.25 13-Jul-2018 beck

Unveiling unveil(2).
This brings unveil into the tree, disabled by default - Currently
this will return EPERM on all attempts to use it until we are
fully certain it is ready for people to start using, but this
now allows for others to do more tweaking and experimentation.

Still needs to send the unveil's across forks and execs before
fully enabling.

Many thanks to robert@ and deraadt@ for extensive testing.
ok deraadt@


Revision tags: OPENBSD_6_3_BASE
# 1.24 12-Dec-2017 deraadt

pledge()'s 2nd argument becomes char *execpromises, which becomes the
pledge for a new execve image immediately upon start. Also introduces
"error" which makes violations return -1 ENOSYS instead of killing the
program ("error" may not be handed to a setuid/setgid program, which
may be missing/ignoring syscall return values and would continue with
inconsistant state)
Discussion with many
florian has used this to improve the strictness of a daemon


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 08-Oct-2016 guenther

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@


# 1.22 26-Aug-2016 guenther

Pull in <sys/select.h> for fd_set

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.21 07-Jun-2016 deraadt

ktrace support for pollfd[] arrays
ok guenther


# 1.20 07-Jun-2016 tedu

add a hack to avoid printing the long string format for times in the 70s.
this is usually a result of a timestamp which hasn't been identified as
"relative" and decoding them to precise dates long in the past is a
distraction. (eagerly awaiting a cleaner, better diff to do the same.)


# 1.19 22-May-2016 guenther

On hppa, function pointer comparison can require dereferencing them.
kdump can't do that for a sigaction sa_handler pointer from the trace,
so cast to void* to suppress it.

ok deraadt@


# 1.18 24-Mar-2016 guenther

Display NAMI records and AF_UNIX socket paths with vis, using
VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL; add the latter three flags
to the existing vis encoding of exec argv/environ and pledge
requests/paths.
Delete local variables left unused when showbuf() and showbufc() were split

ok otto@ millert@


# 1.17 05-Mar-2016 guenther

Make the fd_set* passed to FD_ISSET() non-const: the non-macro version is
stricter (per POSIX, dang it)


Revision tags: OPENBSD_5_9_BASE
# 1.16 14-Jan-2016 guenther

Display struct event more like other structs: show all members and use cpp
define names. Use the mksubr infrastructure for EVFILT_*,
EV_*, and (with some kludging) NOTE_* values. If EV_ERROR is set,
include the errno string for the data member.

Also, do MSG_* parsing on the msg_flags member of struct msghdr.

ok millert@


# 1.15 06-Jan-2016 tedu

print more info about kevent


# 1.14 25-Dec-2015 tedu

very basic kevent printing


# 1.13 18-Oct-2015 guenther

Use offsetof() instead of adding the sizes of the preceeding struct members

ok millert@


# 1.12 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.11 03-Oct-2015 guenther

Add ktracing of tame()'s arguments' values

"every tool helps" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.10 28-Jul-2015 guenther

Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.

ok millert@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.9 16-Dec-2014 jsg

Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer.
ok guenther@


# 1.8 15-Dec-2014 guenther

Eliminate the -r option and always do sysctl OID, username, groupname,
and ctime presentation, but combined with the numeric form ala 0<"root">.
Do username and groupname presentation on syscall arguments and retvals.

ok millert@ otto@


# 1.7 20-Nov-2014 krw

Be more POSIXy by using blksize_t (a.k.a. int32) for st_blksize, rather than the current uint32_t.

ok guenther@ deraadt@


# 1.6 13-Oct-2014 guenther

Add dumping of struct dqblk done by quotactl(2)

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.5 11-Jul-2014 tedu

remove (commented) bluetooth reference


# 1.4 22-Jun-2014 guenther

Negative time{spec,val}s with non-zero subsecond parts require extra
handling. E.g., a timeval of { -1, 1 } is -0.999999, as the subsecond
part is always positive.

Also, update the list of sockaddr_* types that we might add support for


Revision tags: OPENBSD_5_5_BASE
# 1.3 24-Jan-2014 guenther

exit1() needs to do a final aggregation of the thread's [us]ticks
and runtime to the process totals. Also, add ktracing of struct
rusage in wait4() and getrusage().

problem pointed out by tedu@
ok deraadt@


# 1.2 09-Sep-2013 guenther

Recognize the UTIME_OMIT and UTIME_NOW values when printing timespecs

ok otto@


# 1.1 22-Aug-2013 guenther

Split out from kdump.c the ktrstruct.c bits into ktrstruct.c
Reduce the #includes to take advantage of that.

ok millert@ otto@


# 1.27 08-Nov-2018 otto

Peldge and unveil can have struct data size 0. While there, fix "fds"
handler; ok guenther@


# 1.26 05-Nov-2018 anton

trace struct flock; ok visa@


Revision tags: OPENBSD_6_4_BASE
# 1.25 13-Jul-2018 beck

Unveiling unveil(2).
This brings unveil into the tree, disabled by default - Currently
this will return EPERM on all attempts to use it until we are
fully certain it is ready for people to start using, but this
now allows for others to do more tweaking and experimentation.

Still needs to send the unveil's across forks and execs before
fully enabling.

Many thanks to robert@ and deraadt@ for extensive testing.
ok deraadt@


Revision tags: OPENBSD_6_3_BASE
# 1.24 12-Dec-2017 deraadt

pledge()'s 2nd argument becomes char *execpromises, which becomes the
pledge for a new execve image immediately upon start. Also introduces
"error" which makes violations return -1 ENOSYS instead of killing the
program ("error" may not be handed to a setuid/setgid program, which
may be missing/ignoring syscall return values and would continue with
inconsistant state)
Discussion with many
florian has used this to improve the strictness of a daemon


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 08-Oct-2016 guenther

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@


# 1.22 26-Aug-2016 guenther

Pull in <sys/select.h> for fd_set

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.21 07-Jun-2016 deraadt

ktrace support for pollfd[] arrays
ok guenther


# 1.20 07-Jun-2016 tedu

add a hack to avoid printing the long string format for times in the 70s.
this is usually a result of a timestamp which hasn't been identified as
"relative" and decoding them to precise dates long in the past is a
distraction. (eagerly awaiting a cleaner, better diff to do the same.)


# 1.19 22-May-2016 guenther

On hppa, function pointer comparison can require dereferencing them.
kdump can't do that for a sigaction sa_handler pointer from the trace,
so cast to void* to suppress it.

ok deraadt@


# 1.18 24-Mar-2016 guenther

Display NAMI records and AF_UNIX socket paths with vis, using
VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL; add the latter three flags
to the existing vis encoding of exec argv/environ and pledge
requests/paths.
Delete local variables left unused when showbuf() and showbufc() were split

ok otto@ millert@


# 1.17 05-Mar-2016 guenther

Make the fd_set* passed to FD_ISSET() non-const: the non-macro version is
stricter (per POSIX, dang it)


Revision tags: OPENBSD_5_9_BASE
# 1.16 14-Jan-2016 guenther

Display struct event more like other structs: show all members and use cpp
define names. Use the mksubr infrastructure for EVFILT_*,
EV_*, and (with some kludging) NOTE_* values. If EV_ERROR is set,
include the errno string for the data member.

Also, do MSG_* parsing on the msg_flags member of struct msghdr.

ok millert@


# 1.15 06-Jan-2016 tedu

print more info about kevent


# 1.14 25-Dec-2015 tedu

very basic kevent printing


# 1.13 18-Oct-2015 guenther

Use offsetof() instead of adding the sizes of the preceeding struct members

ok millert@


# 1.12 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.11 03-Oct-2015 guenther

Add ktracing of tame()'s arguments' values

"every tool helps" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.10 28-Jul-2015 guenther

Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.

ok millert@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.9 16-Dec-2014 jsg

Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer.
ok guenther@


# 1.8 15-Dec-2014 guenther

Eliminate the -r option and always do sysctl OID, username, groupname,
and ctime presentation, but combined with the numeric form ala 0<"root">.
Do username and groupname presentation on syscall arguments and retvals.

ok millert@ otto@


# 1.7 20-Nov-2014 krw

Be more POSIXy by using blksize_t (a.k.a. int32) for st_blksize, rather than the current uint32_t.

ok guenther@ deraadt@


# 1.6 13-Oct-2014 guenther

Add dumping of struct dqblk done by quotactl(2)

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.5 11-Jul-2014 tedu

remove (commented) bluetooth reference


# 1.4 22-Jun-2014 guenther

Negative time{spec,val}s with non-zero subsecond parts require extra
handling. E.g., a timeval of { -1, 1 } is -0.999999, as the subsecond
part is always positive.

Also, update the list of sockaddr_* types that we might add support for


Revision tags: OPENBSD_5_5_BASE
# 1.3 24-Jan-2014 guenther

exit1() needs to do a final aggregation of the thread's [us]ticks
and runtime to the process totals. Also, add ktracing of struct
rusage in wait4() and getrusage().

problem pointed out by tedu@
ok deraadt@


# 1.2 09-Sep-2013 guenther

Recognize the UTIME_OMIT and UTIME_NOW values when printing timespecs

ok otto@


# 1.1 22-Aug-2013 guenther

Split out from kdump.c the ktrstruct.c bits into ktrstruct.c
Reduce the #includes to take advantage of that.

ok millert@ otto@


# 1.25 13-Jul-2018 beck

Unveiling unveil(2).
This brings unveil into the tree, disabled by default - Currently
this will return EPERM on all attempts to use it until we are
fully certain it is ready for people to start using, but this
now allows for others to do more tweaking and experimentation.

Still needs to send the unveil's across forks and execs before
fully enabling.

Many thanks to robert@ and deraadt@ for extensive testing.
ok deraadt@


Revision tags: OPENBSD_6_3_BASE
# 1.24 12-Dec-2017 deraadt

pledge()'s 2nd argument becomes char *execpromises, which becomes the
pledge for a new execve image immediately upon start. Also introduces
"error" which makes violations return -1 ENOSYS instead of killing the
program ("error" may not be handed to a setuid/setgid program, which
may be missing/ignoring syscall return values and would continue with
inconsistant state)
Discussion with many
florian has used this to improve the strictness of a daemon


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 08-Oct-2016 guenther

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@


# 1.22 26-Aug-2016 guenther

Pull in <sys/select.h> for fd_set

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.21 07-Jun-2016 deraadt

ktrace support for pollfd[] arrays
ok guenther


# 1.20 07-Jun-2016 tedu

add a hack to avoid printing the long string format for times in the 70s.
this is usually a result of a timestamp which hasn't been identified as
"relative" and decoding them to precise dates long in the past is a
distraction. (eagerly awaiting a cleaner, better diff to do the same.)


# 1.19 22-May-2016 guenther

On hppa, function pointer comparison can require dereferencing them.
kdump can't do that for a sigaction sa_handler pointer from the trace,
so cast to void* to suppress it.

ok deraadt@


# 1.18 24-Mar-2016 guenther

Display NAMI records and AF_UNIX socket paths with vis, using
VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL; add the latter three flags
to the existing vis encoding of exec argv/environ and pledge
requests/paths.
Delete local variables left unused when showbuf() and showbufc() were split

ok otto@ millert@


# 1.17 05-Mar-2016 guenther

Make the fd_set* passed to FD_ISSET() non-const: the non-macro version is
stricter (per POSIX, dang it)


Revision tags: OPENBSD_5_9_BASE
# 1.16 14-Jan-2016 guenther

Display struct event more like other structs: show all members and use cpp
define names. Use the mksubr infrastructure for EVFILT_*,
EV_*, and (with some kludging) NOTE_* values. If EV_ERROR is set,
include the errno string for the data member.

Also, do MSG_* parsing on the msg_flags member of struct msghdr.

ok millert@


# 1.15 06-Jan-2016 tedu

print more info about kevent


# 1.14 25-Dec-2015 tedu

very basic kevent printing


# 1.13 18-Oct-2015 guenther

Use offsetof() instead of adding the sizes of the preceeding struct members

ok millert@


# 1.12 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.11 03-Oct-2015 guenther

Add ktracing of tame()'s arguments' values

"every tool helps" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.10 28-Jul-2015 guenther

Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.

ok millert@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.9 16-Dec-2014 jsg

Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer.
ok guenther@


# 1.8 15-Dec-2014 guenther

Eliminate the -r option and always do sysctl OID, username, groupname,
and ctime presentation, but combined with the numeric form ala 0<"root">.
Do username and groupname presentation on syscall arguments and retvals.

ok millert@ otto@


# 1.7 20-Nov-2014 krw

Be more POSIXy by using blksize_t (a.k.a. int32) for st_blksize, rather than the current uint32_t.

ok guenther@ deraadt@


# 1.6 13-Oct-2014 guenther

Add dumping of struct dqblk done by quotactl(2)

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.5 11-Jul-2014 tedu

remove (commented) bluetooth reference


# 1.4 22-Jun-2014 guenther

Negative time{spec,val}s with non-zero subsecond parts require extra
handling. E.g., a timeval of { -1, 1 } is -0.999999, as the subsecond
part is always positive.

Also, update the list of sockaddr_* types that we might add support for


Revision tags: OPENBSD_5_5_BASE
# 1.3 24-Jan-2014 guenther

exit1() needs to do a final aggregation of the thread's [us]ticks
and runtime to the process totals. Also, add ktracing of struct
rusage in wait4() and getrusage().

problem pointed out by tedu@
ok deraadt@


# 1.2 09-Sep-2013 guenther

Recognize the UTIME_OMIT and UTIME_NOW values when printing timespecs

ok otto@


# 1.1 22-Aug-2013 guenther

Split out from kdump.c the ktrstruct.c bits into ktrstruct.c
Reduce the #includes to take advantage of that.

ok millert@ otto@


# 1.24 12-Dec-2017 deraadt

pledge()'s 2nd argument becomes char *execpromises, which becomes the
pledge for a new execve image immediately upon start. Also introduces
"error" which makes violations return -1 ENOSYS instead of killing the
program ("error" may not be handed to a setuid/setgid program, which
may be missing/ignoring syscall return values and would continue with
inconsistant state)
Discussion with many
florian has used this to improve the strictness of a daemon


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.23 08-Oct-2016 guenther

Add ktracing of the fds returned by pipe() and socketpair()

ok deraadt@


# 1.22 26-Aug-2016 guenther

Pull in <sys/select.h> for fd_set

ok deraadt@


Revision tags: OPENBSD_6_0_BASE
# 1.21 07-Jun-2016 deraadt

ktrace support for pollfd[] arrays
ok guenther


# 1.20 07-Jun-2016 tedu

add a hack to avoid printing the long string format for times in the 70s.
this is usually a result of a timestamp which hasn't been identified as
"relative" and decoding them to precise dates long in the past is a
distraction. (eagerly awaiting a cleaner, better diff to do the same.)


# 1.19 22-May-2016 guenther

On hppa, function pointer comparison can require dereferencing them.
kdump can't do that for a sigaction sa_handler pointer from the trace,
so cast to void* to suppress it.

ok deraadt@


# 1.18 24-Mar-2016 guenther

Display NAMI records and AF_UNIX socket paths with vis, using
VIS_CSTYLE | VIS_DQ | VIS_TAB | VIS_NL; add the latter three flags
to the existing vis encoding of exec argv/environ and pledge
requests/paths.
Delete local variables left unused when showbuf() and showbufc() were split

ok otto@ millert@


# 1.17 05-Mar-2016 guenther

Make the fd_set* passed to FD_ISSET() non-const: the non-macro version is
stricter (per POSIX, dang it)


Revision tags: OPENBSD_5_9_BASE
# 1.16 14-Jan-2016 guenther

Display struct event more like other structs: show all members and use cpp
define names. Use the mksubr infrastructure for EVFILT_*,
EV_*, and (with some kludging) NOTE_* values. If EV_ERROR is set,
include the errno string for the data member.

Also, do MSG_* parsing on the msg_flags member of struct msghdr.

ok millert@


# 1.15 06-Jan-2016 tedu

print more info about kevent


# 1.14 25-Dec-2015 tedu

very basic kevent printing


# 1.13 18-Oct-2015 guenther

Use offsetof() instead of adding the sizes of the preceeding struct members

ok millert@


# 1.12 09-Oct-2015 deraadt

Change all tame callers to namechange to pledge(2).


# 1.11 03-Oct-2015 guenther

Add ktracing of tame()'s arguments' values

"every tool helps" deraadt@


Revision tags: OPENBSD_5_8_BASE
# 1.10 28-Jul-2015 guenther

Add ktracing of structs iovec, msghdr, and cmsghdr for {,p}{read,write}v(),
sendmsg(), and recvmsg(). For cmsghdr, the len, level, and type are always
shown, and for SOL_SOCKET,SCM_RIGHTS the fd numbers being passed are shown.

ok millert@ deraadt@


Revision tags: OPENBSD_5_7_BASE
# 1.9 16-Dec-2014 jsg

Don't display formatted time if localtime() fails.
Avoids a crash in strftime() found with the afl fuzzer.
ok guenther@


# 1.8 15-Dec-2014 guenther

Eliminate the -r option and always do sysctl OID, username, groupname,
and ctime presentation, but combined with the numeric form ala 0<"root">.
Do username and groupname presentation on syscall arguments and retvals.

ok millert@ otto@


# 1.7 20-Nov-2014 krw

Be more POSIXy by using blksize_t (a.k.a. int32) for st_blksize, rather than the current uint32_t.

ok guenther@ deraadt@


# 1.6 13-Oct-2014 guenther

Add dumping of struct dqblk done by quotactl(2)

ok millert@


Revision tags: OPENBSD_5_6_BASE
# 1.5 11-Jul-2014 tedu

remove (commented) bluetooth reference


# 1.4 22-Jun-2014 guenther

Negative time{spec,val}s with non-zero subsecond parts require extra
handling. E.g., a timeval of { -1, 1 } is -0.999999, as the subsecond
part is always positive.

Also, update the list of sockaddr_* types that we might add support for


Revision tags: OPENBSD_5_5_BASE
# 1.3 24-Jan-2014 guenther

exit1() needs to do a final aggregation of the thread's [us]ticks
and runtime to the process totals. Also, add ktracing of struct
rusage in wait4() and getrusage().

problem pointed out by tedu@
ok deraadt@


# 1.2 09-Sep-2013 guenther

Recognize the UTIME_OMIT and UTIME_NOW values when printing timespecs

ok otto@


# 1.1 22-Aug-2013 guenther

Split out from kdump.c the ktrstruct.c bits into ktrstruct.c
Reduce the #includes to take advantage of that.

ok millert@ otto@