diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-03-08 00:50:37 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-03-08 00:50:37 +0000 |
commit | 25330cae2048ae0818bc8d87e0c28a34b32d019b (patch) | |
tree | 39df90aae9f5c08bbe24ec8be9340cd061aadfb7 /sys/security/mac/mac_posix_shm.c | |
parent | f18c279752d888c46c564f2adf466f19b9d17ed9 (diff) | |
download | FreeBSD-src-25330cae2048ae0818bc8d87e0c28a34b32d019b.zip FreeBSD-src-25330cae2048ae0818bc8d87e0c28a34b32d019b.tar.gz |
Add static DTrace probes for MAC Framework access control checks and
privilege grants so that dtrace can be more easily used to monitor
the security decisions being generated by the MAC Framework following
policy invocation.
Successful access control checks will be reported by:
mac_framework:kernel:<entrypoint>:mac_check_ok
Failed access control checks will be reported by:
mac_framework:kernel:<entrypoint>:mac_check_err
Successful privilege grants will be reported by:
mac_framework:kernel:priv_grant:mac_grant_ok
Failed privilege grants will be reported by:
mac_framework:kernel:priv_grant:mac_grant_err
In all cases, the return value (always 0 for _ok, otherwise an errno
for _err) will be reported via arg0 on the probe, and subsequent
arguments will hold entrypoint-specific data, in a style similar to
privilege tracing.
Obtained from: TrustedBSD Project
Sponsored by: Google, Inc.
Diffstat (limited to 'sys/security/mac/mac_posix_shm.c')
-rw-r--r-- | sys/security/mac/mac_posix_shm.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/sys/security/mac/mac_posix_shm.c b/sys/security/mac/mac_posix_shm.c index 97587ad..913cb43 100644 --- a/sys/security/mac/mac_posix_shm.c +++ b/sys/security/mac/mac_posix_shm.c @@ -1,5 +1,6 @@ /*- * Copyright (c) 2003-2006 SPARTA, Inc. + * Copyright (c) 2009 Robert N. M. Watson * All rights reserved. * * This software was developed for the FreeBSD Project in part by Network @@ -8,7 +9,10 @@ * as part of the DARPA CHATS research program. * * This software was enhanced by SPARTA ISSO under SPAWAR contract - * N66001-04-C-6019 ("SEFOS"). + * N66001-04-C-6019 ("SEFOS"). * + * + * This software was developed at the University of Cambridge Computer + * Laboratory with support from a grant from Google, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -35,6 +39,7 @@ #include <sys/cdefs.h> __FBSDID("$FreeBSD$"); +#include "opt_kdtrace.h" #include "opt_mac.h" #include <sys/param.h> @@ -42,6 +47,7 @@ __FBSDID("$FreeBSD$"); #include <sys/mman.h> #include <sys/malloc.h> #include <sys/module.h> +#include <sys/sdt.h> #include <sys/systm.h> #include <sys/sysctl.h> @@ -94,6 +100,9 @@ mac_posixshm_create(struct ucred *cred, struct shmfd *shmfd) MAC_PERFORM(posixshm_create, cred, shmfd, shmfd->shm_label); } +MAC_CHECK_PROBE_DEFINE4(posixshm_check_mmap, "struct ucred *", + "struct shmfd *", "int", "int"); + int mac_posixshm_check_mmap(struct ucred *cred, struct shmfd *shmfd, int prot, int flags) @@ -102,20 +111,29 @@ mac_posixshm_check_mmap(struct ucred *cred, struct shmfd *shmfd, int prot, MAC_CHECK(posixshm_check_mmap, cred, shmfd, shmfd->shm_label, prot, flags); + MAC_CHECK_PROBE4(posixshm_check_mmap, error, cred, shmfd, prot, + flags); return (error); } +MAC_CHECK_PROBE_DEFINE2(posixshm_check_open, "struct ucred *", + "struct shmfd *"); + int mac_posixshm_check_open(struct ucred *cred, struct shmfd *shmfd) { int error; MAC_CHECK(posixshm_check_open, cred, shmfd, shmfd->shm_label); + MAC_CHECK_PROBE2(posixshm_check_open, error, cred, shmfd); return (error); } +MAC_CHECK_PROBE_DEFINE3(posixshm_check_stat, "struct ucred *", + "struct ucred *", "struct shmfd *"); + int mac_posixshm_check_stat(struct ucred *active_cred, struct ucred *file_cred, struct shmfd *shmfd) @@ -124,10 +142,15 @@ mac_posixshm_check_stat(struct ucred *active_cred, struct ucred *file_cred, MAC_CHECK(posixshm_check_stat, active_cred, file_cred, shmfd, shmfd->shm_label); + MAC_CHECK_PROBE3(posixshm_check_stat, error, active_cred, file_cred, + shmfd); return (error); } +MAC_CHECK_PROBE_DEFINE3(posixshm_check_truncate, "struct ucred *", + "struct ucred *", "struct shmfd *"); + int mac_posixshm_check_truncate(struct ucred *active_cred, struct ucred *file_cred, struct shmfd *shmfd) @@ -136,16 +159,22 @@ mac_posixshm_check_truncate(struct ucred *active_cred, struct ucred *file_cred, MAC_CHECK(posixshm_check_truncate, active_cred, file_cred, shmfd, shmfd->shm_label); + MAC_CHECK_PROBE3(posixshm_check_truncate, error, active_cred, + file_cred, shmfd); return (error); } +MAC_CHECK_PROBE_DEFINE2(posixshm_check_unlink, "struct ucred *", + "struct shmfd *"); + int mac_posixshm_check_unlink(struct ucred *cred, struct shmfd *shmfd) { int error; MAC_CHECK(posixshm_check_unlink, cred, shmfd, shmfd->shm_label); + MAC_CHECK_PROBE2(posixshm_check_unlink, error, cred, shmfd); return (error); } |