Add tunable to disable destructive dtrace

Submitted by:	Joerg Pernfuss <code.jpe@gmail.com>
Reviewed by:	rstone, markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D8624
This commit is contained in:
George V. Neville-Neil 2016-11-23 22:50:20 +00:00
parent 6a368d16c8
commit cdaa8777f7
3 changed files with 18 additions and 0 deletions

View file

@ -157,6 +157,10 @@
* /etc/system.
*/
int dtrace_destructive_disallow = 0;
#ifndef illumos
/* Positive logic version of dtrace_destructive_disallow for loader tunable */
int dtrace_allow_destructive = 1;
#endif
dtrace_optval_t dtrace_nonroot_maxsize = (16 * 1024 * 1024);
size_t dtrace_difo_maxsize = (256 * 1024);
dtrace_optval_t dtrace_dof_maxsize = (8 * 1024 * 1024);

View file

@ -52,6 +52,17 @@ dtrace_load(void *dummy)
int i;
#endif
#ifndef illumos
/*
* DTrace uses negative logic for the destructive mode switch, so it
* is required to translate from the sysctl which uses positive logic.
*/
if (dtrace_allow_destructive)
dtrace_destructive_disallow = 0;
else
dtrace_destructive_disallow = 1;
#endif
/* Hook into the trap handler. */
dtrace_trap_func = dtrace_trap;

View file

@ -92,3 +92,6 @@ SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW,
SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW,
&dtrace_helper_actions_max, 0, "maximum number of allowed helper actions");
SYSCTL_INT(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN,
&dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts");