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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/dtrace/dtrace.c
          +++ new/usr/src/uts/common/dtrace/dtrace.c
↓ open down ↓ 1292 lines elided ↑ open up ↑
1293 1293          dtrace_provider_t *prov = probe->dtpr_provider;
1294 1294          dtrace_pops_t *pops = &prov->dtpv_pops;
1295 1295          int mode = DTRACE_MODE_NOPRIV_DROP;
1296 1296  
1297 1297          ASSERT(ecb->dte_cond);
1298 1298  
1299 1299          if (pops->dtps_mode != NULL) {
1300 1300                  mode = pops->dtps_mode(prov->dtpv_arg,
1301 1301                      probe->dtpr_id, probe->dtpr_arg);
1302 1302  
1303      -                ASSERT((mode & DTRACE_MODE_USER) ||
1304      -                    (mode & DTRACE_MODE_KERNEL));
1305      -                ASSERT((mode & DTRACE_MODE_NOPRIV_RESTRICT) ||
1306      -                    (mode & DTRACE_MODE_NOPRIV_DROP));
     1303 +                ASSERT(mode & (DTRACE_MODE_USER | DTRACE_MODE_KERNEL));
     1304 +                ASSERT(mode & (DTRACE_MODE_NOPRIV_RESTRICT |
     1305 +                    DTRACE_MODE_NOPRIV_DROP));
1307 1306          }
1308 1307  
1309 1308          /*
1310 1309           * If the dte_cond bits indicate that this consumer is only allowed to
1311      -         * see user-mode firings of this probe, call the provider's dtps_mode()
1312      -         * entry point to check that the probe was fired while in a user
1313      -         * context.  If that's not the case, use the policy specified by the
1314      -         * provider to determine if we drop the probe or merely restrict
1315      -         * operation.
     1310 +         * see user-mode firings of this probe, check that the probe was fired
     1311 +         * while in a user context.  If that's not the case, use the policy
     1312 +         * specified by the provider to determine if we drop the probe or
     1313 +         * merely restrict operation.
1316 1314           */
1317 1315          if (ecb->dte_cond & DTRACE_COND_USERMODE) {
1318 1316                  ASSERT(mode != DTRACE_MODE_NOPRIV_DROP);
1319 1317  
1320 1318                  if (!(mode & DTRACE_MODE_USER)) {
1321 1319                          if (mode & DTRACE_MODE_NOPRIV_DROP)
1322 1320                                  return (0);
1323 1321  
1324 1322                          mstate->dtms_access &= ~DTRACE_ACCESS_ARGS;
1325 1323                  }
↓ open down ↓ 46 lines elided ↑ open up ↑
1372 1370                  if ((cr = CRED()) == NULL ||
1373 1371                      s_cr->cr_zone->zone_id != cr->cr_zone->zone_id) {
1374 1372                          if (mode & DTRACE_MODE_NOPRIV_DROP)
1375 1373                                  return (0);
1376 1374  
1377 1375                          mstate->dtms_access &=
1378 1376                              ~(DTRACE_ACCESS_PROC | DTRACE_ACCESS_ARGS);
1379 1377                  }
1380 1378          }
1381 1379  
     1380 +        /*
     1381 +         * By merits of being in this code path at all, we have limited
     1382 +         * privileges.  If the provider has indicated that limited privileges
     1383 +         * are to denote restricted operation, strip off the ability to access
     1384 +         * arguments.
     1385 +         */
     1386 +        if (mode & DTRACE_MODE_LIMITEDPRIV_RESTRICT)
     1387 +                mstate->dtms_access &= ~DTRACE_ACCESS_ARGS;
     1388 +
1382 1389          return (1);
1383 1390  }
1384 1391  
1385 1392  /*
1386 1393   * Note:  not called from probe context.  This function is called
1387 1394   * asynchronously (and at a regular interval) from outside of probe context to
1388 1395   * clean the dirty dynamic variable lists on all CPUs.  Dynamic variable
1389 1396   * cleaning is explained in detail in <sys/dtrace_impl.h>.
1390 1397   */
1391 1398  void
↓ open down ↓ 14822 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX