Print this page
2917 DTrace in a zone should have limited provider access


   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  29  */
  30 
  31 #ifndef _SYS_DTRACE_H
  32 #define _SYS_DTRACE_H
  33 
  34 #ifdef  __cplusplus
  35 extern "C" {
  36 #endif
  37 
  38 /*
  39  * DTrace Dynamic Tracing Software: Kernel Interfaces
  40  *
  41  * Note: The contents of this file are private to the implementation of the
  42  * Solaris system and DTrace subsystem and are subject to change at any time
  43  * without notice.  Applications and drivers using these interfaces will fail
  44  * to run on future releases.  These interfaces should not be used for any
  45  * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
  46  * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
  47  */
  48 


1608  *
1609  * 1.10  int dtps_mode(void *arg, dtrace_id_t id, void *parg)
1610  *
1611  * 1.10.1  Overview
1612  *
1613  *   Called to determine the mode of a fired probe.
1614  *
1615  * 1.10.2  Arguments and notes
1616  *
1617  *   The first argument is the cookie as passed to dtrace_register(). The
1618  *   second argument is the identifier of the current probe.  The third
1619  *   argument is the probe argument as passed to dtrace_probe_create().  This
1620  *   entry point must not be left NULL for providers whose probes allow for
1621  *   mixed mode tracing, that is to say those unanchored probes that can fire
1622  *   during kernel- or user-mode execution.
1623  *
1624  * 1.10.3  Return value
1625  *
1626  *   A bitwise OR that encapsulates both the mode (either DTRACE_MODE_KERNEL
1627  *   or DTRACE_MODE_USER) and the policy when the privilege of the enabling
1628  *   is insufficient for that mode (either DTRACE_MODE_NOPRIV_DROP or
1629  *   DTRACE_MODE_NOPRIV_RESTRICT).  If the policy is DTRACE_MODE_NOPRIV_DROP,
1630  *   insufficient privilege will result in the probe firing being silently
1631  *   ignored for the enabling; if the policy is DTRACE_NODE_NOPRIV_RESTRICT,
1632  *   insufficient privilege will not prevent probe processing for the
1633  *   enabling, but restrictions will be in place that induce a UPRIV fault
1634  *   upon attempt to examine probe arguments or current process state.







1635  *
1636  * 1.10.4  Caller's context
1637  *
1638  *   This is called from within dtrace_probe() meaning that interrupts
1639  *   are disabled. No locks should be taken within this entry point.
1640  *
1641  * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg)
1642  *
1643  * 1.11.1 Overview
1644  *
1645  *   Called to destroy the specified probe.
1646  *
1647  * 1.11.2 Arguments and notes
1648  *
1649  *   The first argument is the cookie as passed to dtrace_register().  The
1650  *   second argument is the identifier of the probe to be destroyed.  The third
1651  *   argument is the probe argument as passed to dtrace_probe_create().  The
1652  *   provider should free all state associated with the probe.  The framework
1653  *   guarantees that dtps_destroy() is only called for probes that have either
1654  *   been disabled via dtps_disable() or were never enabled via dtps_enable().


2013  */
2014 typedef struct dtrace_pops {
2015         void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec);
2016         void (*dtps_provide_module)(void *arg, struct modctl *mp);
2017         int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
2018         void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
2019         void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
2020         void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg);
2021         void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg,
2022             dtrace_argdesc_t *desc);
2023         uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg,
2024             int argno, int aframes);
2025         int (*dtps_mode)(void *arg, dtrace_id_t id, void *parg);
2026         void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg);
2027 } dtrace_pops_t;
2028 
2029 #define DTRACE_MODE_KERNEL                      0x01
2030 #define DTRACE_MODE_USER                        0x02
2031 #define DTRACE_MODE_NOPRIV_DROP                 0x10
2032 #define DTRACE_MODE_NOPRIV_RESTRICT             0x20

2033 
2034 typedef uintptr_t       dtrace_provider_id_t;
2035 
2036 extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t,
2037     cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *);
2038 extern int dtrace_unregister(dtrace_provider_id_t);
2039 extern int dtrace_condense(dtrace_provider_id_t);
2040 extern void dtrace_invalidate(dtrace_provider_id_t);
2041 extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *,
2042     const char *, const char *);
2043 extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *,
2044     const char *, const char *, int, void *);
2045 extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t);
2046 extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
2047     uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
2048 
2049 /*
2050  * DTrace Meta Provider API
2051  *
2052  * The following functions are implemented by the DTrace framework and are




   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*
  28  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  29  */
  30 
  31 #ifndef _SYS_DTRACE_H
  32 #define _SYS_DTRACE_H
  33 
  34 #ifdef  __cplusplus
  35 extern "C" {
  36 #endif
  37 
  38 /*
  39  * DTrace Dynamic Tracing Software: Kernel Interfaces
  40  *
  41  * Note: The contents of this file are private to the implementation of the
  42  * Solaris system and DTrace subsystem and are subject to change at any time
  43  * without notice.  Applications and drivers using these interfaces will fail
  44  * to run on future releases.  These interfaces should not be used for any
  45  * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
  46  * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
  47  */
  48 


1608  *
1609  * 1.10  int dtps_mode(void *arg, dtrace_id_t id, void *parg)
1610  *
1611  * 1.10.1  Overview
1612  *
1613  *   Called to determine the mode of a fired probe.
1614  *
1615  * 1.10.2  Arguments and notes
1616  *
1617  *   The first argument is the cookie as passed to dtrace_register(). The
1618  *   second argument is the identifier of the current probe.  The third
1619  *   argument is the probe argument as passed to dtrace_probe_create().  This
1620  *   entry point must not be left NULL for providers whose probes allow for
1621  *   mixed mode tracing, that is to say those unanchored probes that can fire
1622  *   during kernel- or user-mode execution.
1623  *
1624  * 1.10.3  Return value
1625  *
1626  *   A bitwise OR that encapsulates both the mode (either DTRACE_MODE_KERNEL
1627  *   or DTRACE_MODE_USER) and the policy when the privilege of the enabling
1628  *   is insufficient for that mode (a combination of DTRACE_MODE_NOPRIV_DROP,
1629  *   DTRACE_MODE_NOPRIV_RESTRICT, and DTRACE_MODE_LIMITEDPRIV_RESTRICT).  If
1630  *   DTRACE_MODE_NOPRIV_DROP bit is set, insufficient privilege will result
1631  *   in the probe firing being silently ignored for the enabling; if the
1632  *   DTRACE_NODE_NOPRIV_RESTRICT bit is set, insufficient privilege will not
1633  *   prevent probe processing for the enabling, but restrictions will be in
1634  *   place that induce a UPRIV fault upon attempt to examine probe arguments
1635  *   or current process state.  If the DTRACE_MODE_LIMITEDPRIV_RESTRICT bit
1636  *   is set, similar restrictions will be placed upon operation if the
1637  *   privilege is sufficient to process the enabling, but does not otherwise
1638  *   entitle the enabling to all zones.  The DTRACE_MODE_NOPRIV_DROP and
1639  *   DTRACE_MODE_NOPRIV_RESTRICT are mutually exclusive (and one of these
1640  *   two policies must be specified), but either may be combined (or not)
1641  *   with DTRACE_MODE_LIMITEDPRIV_RESTRICT.
1642  *
1643  * 1.10.4  Caller's context
1644  *
1645  *   This is called from within dtrace_probe() meaning that interrupts
1646  *   are disabled. No locks should be taken within this entry point.
1647  *
1648  * 1.11 void dtps_destroy(void *arg, dtrace_id_t id, void *parg)
1649  *
1650  * 1.11.1 Overview
1651  *
1652  *   Called to destroy the specified probe.
1653  *
1654  * 1.11.2 Arguments and notes
1655  *
1656  *   The first argument is the cookie as passed to dtrace_register().  The
1657  *   second argument is the identifier of the probe to be destroyed.  The third
1658  *   argument is the probe argument as passed to dtrace_probe_create().  The
1659  *   provider should free all state associated with the probe.  The framework
1660  *   guarantees that dtps_destroy() is only called for probes that have either
1661  *   been disabled via dtps_disable() or were never enabled via dtps_enable().


2020  */
2021 typedef struct dtrace_pops {
2022         void (*dtps_provide)(void *arg, const dtrace_probedesc_t *spec);
2023         void (*dtps_provide_module)(void *arg, struct modctl *mp);
2024         int (*dtps_enable)(void *arg, dtrace_id_t id, void *parg);
2025         void (*dtps_disable)(void *arg, dtrace_id_t id, void *parg);
2026         void (*dtps_suspend)(void *arg, dtrace_id_t id, void *parg);
2027         void (*dtps_resume)(void *arg, dtrace_id_t id, void *parg);
2028         void (*dtps_getargdesc)(void *arg, dtrace_id_t id, void *parg,
2029             dtrace_argdesc_t *desc);
2030         uint64_t (*dtps_getargval)(void *arg, dtrace_id_t id, void *parg,
2031             int argno, int aframes);
2032         int (*dtps_mode)(void *arg, dtrace_id_t id, void *parg);
2033         void (*dtps_destroy)(void *arg, dtrace_id_t id, void *parg);
2034 } dtrace_pops_t;
2035 
2036 #define DTRACE_MODE_KERNEL                      0x01
2037 #define DTRACE_MODE_USER                        0x02
2038 #define DTRACE_MODE_NOPRIV_DROP                 0x10
2039 #define DTRACE_MODE_NOPRIV_RESTRICT             0x20
2040 #define DTRACE_MODE_LIMITEDPRIV_RESTRICT        0x40
2041 
2042 typedef uintptr_t       dtrace_provider_id_t;
2043 
2044 extern int dtrace_register(const char *, const dtrace_pattr_t *, uint32_t,
2045     cred_t *, const dtrace_pops_t *, void *, dtrace_provider_id_t *);
2046 extern int dtrace_unregister(dtrace_provider_id_t);
2047 extern int dtrace_condense(dtrace_provider_id_t);
2048 extern void dtrace_invalidate(dtrace_provider_id_t);
2049 extern dtrace_id_t dtrace_probe_lookup(dtrace_provider_id_t, const char *,
2050     const char *, const char *);
2051 extern dtrace_id_t dtrace_probe_create(dtrace_provider_id_t, const char *,
2052     const char *, const char *, int, void *);
2053 extern void *dtrace_probe_arg(dtrace_provider_id_t, dtrace_id_t);
2054 extern void dtrace_probe(dtrace_id_t, uintptr_t arg0, uintptr_t arg1,
2055     uintptr_t arg2, uintptr_t arg3, uintptr_t arg4);
2056 
2057 /*
2058  * DTrace Meta Provider API
2059  *
2060  * The following functions are implemented by the DTrace framework and are