diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-10-26 14:38:24 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-10-26 14:38:24 +0000 |
commit | 312cab0dee67b902f2b3c5b4d8873b978e5f0191 (patch) | |
tree | c8fd3cabfa2bfa5d30b618f0bd199b68acdff307 /sys/security/mac_test/mac_test.c | |
parent | 5de667a68d9bb17cb2a9a6df00a724b91d053f12 (diff) | |
download | FreeBSD-src-312cab0dee67b902f2b3c5b4d8873b978e5f0191.zip FreeBSD-src-312cab0dee67b902f2b3c5b4d8873b978e5f0191.tar.gz |
Slightly change the semantics of vnode labels for MAC: rather than
"refreshing" the label on the vnode before use, just get the label
right from inception. For single-label file systems, set the label
in the generic VFS getnewvnode() code; for multi-label file systems,
leave the labeling up to the file system. With UFS1/2, this means
reading the extended attribute during vfs_vget() as the inode is
pulled off disk, rather than hitting the extended attributes
frequently during operations later, improving performance. This
also corrects sematics for shared vnode locks, which were not
previously present in the system. This chances the cache
coherrency properties WRT out-of-band access to label data, but in
an acceptable form. With UFS1, there is a small race condition
during automatic extended attribute start -- this is not present
with UFS2, and occurs because EAs aren't available at vnode
inception. We'll introduce a work around for this shortly.
Approved by: re
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'sys/security/mac_test/mac_test.c')
-rw-r--r-- | sys/security/mac_test/mac_test.c | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/sys/security/mac_test/mac_test.c b/sys/security/mac_test/mac_test.c index b4b18a3..6a2cf76 100644 --- a/sys/security/mac_test/mac_test.c +++ b/sys/security/mac_test/mac_test.c @@ -46,6 +46,7 @@ #include <sys/param.h> #include <sys/acl.h> #include <sys/conf.h> +#include <sys/extattr.h> #include <sys/kernel.h> #include <sys/mac.h> #include <sys/mount.h> @@ -483,15 +484,6 @@ mac_test_externalize_label(struct label *label, char *element_name, } static int -mac_test_externalize_vnode_oldmac(struct label *label, struct oldmac *extmac) -{ - - atomic_add_int(&externalize_count, 1); - - return (0); -} - -static int mac_test_internalize_label(struct label *label, struct mac *mac, char *element_name, char *element_data, int *claimed) { @@ -506,6 +498,29 @@ mac_test_internalize_label(struct label *label, struct mac *mac, * a lot like file system objects. */ static void +mac_test_associate_vnode_devfs(struct mount *mp, struct label *fslabel, + struct devfs_dirent *de, struct label *delabel, struct vnode *vp, + struct label *vlabel) +{ + +} + +static int +mac_test_associate_vnode_extattr(struct mount *mp, struct label *fslabel, + struct vnode *vp, struct label *vlabel) +{ + + return (0); +} + +static void +mac_test_associate_vnode_singlelabel(struct mount *mp, + struct label *fslabel, struct vnode *vp, struct label *vlabel) +{ + +} + +static void mac_test_create_devfs_device(dev_t dev, struct devfs_dirent *devfs_dirent, struct label *label) { @@ -533,11 +548,13 @@ mac_test_create_devfs_vnode(struct devfs_dirent *devfs_dirent, } -static void -mac_test_create_vnode(struct ucred *cred, struct vnode *parent, - struct label *parentlabel, struct vnode *child, struct label *childlabel) +static int +mac_test_create_vnode_extattr(struct ucred *cred, struct mount *mp, + struct label *fslabel, struct vnode *dvp, struct label *dlabel, + struct vnode *vp, struct label *vlabel, struct componentname *cnp) { + return (0); } static void @@ -561,31 +578,17 @@ mac_test_relabel_vnode(struct ucred *cred, struct vnode *vp, } -static void -mac_test_update_devfsdirent(struct devfs_dirent *devfs_dirent, - struct vnode *vp) -{ - -} - -static void -mac_test_update_procfsvnode(struct vnode *vp, struct label *vnodelabel, - struct ucred *cred) -{ - -} - static int -mac_test_update_vnode_from_externalized(struct vnode *vp, - struct label *vnodelabel, struct mac *extmac) +mac_test_setlabel_vnode_extattr(struct ucred *cred, struct vnode *vp, + struct label *vlabel, struct label *intlabel) { return (0); } static void -mac_test_update_vnode_from_mount(struct vnode *vp, struct label *vnodelabel, - struct mount *mp, struct label *fslabel) +mac_test_update_devfsdirent(struct devfs_dirent *devfs_dirent, + struct label *direntlabel, struct vnode *vp, struct label *vnodelabel) { } @@ -1275,8 +1278,6 @@ static struct mac_policy_op_entry mac_test_ops[] = (macop_t)mac_test_externalize_label }, { MAC_EXTERNALIZE_VNODE_LABEL, (macop_t)mac_test_externalize_label }, - { MAC_EXTERNALIZE_VNODE_OLDMAC, - (macop_t)mac_test_externalize_vnode_oldmac }, { MAC_INTERNALIZE_CRED_LABEL, (macop_t)mac_test_internalize_label }, { MAC_INTERNALIZE_IFNET_LABEL, @@ -1287,6 +1288,12 @@ static struct mac_policy_op_entry mac_test_ops[] = (macop_t)mac_test_internalize_label }, { MAC_INTERNALIZE_VNODE_LABEL, (macop_t)mac_test_internalize_label }, + { MAC_ASSOCIATE_VNODE_DEVFS, + (macop_t)mac_test_associate_vnode_devfs }, + { MAC_ASSOCIATE_VNODE_EXTATTR, + (macop_t)mac_test_associate_vnode_extattr }, + { MAC_ASSOCIATE_VNODE_SINGLELABEL, + (macop_t)mac_test_associate_vnode_singlelabel }, { MAC_CREATE_DEVFS_DEVICE, (macop_t)mac_test_create_devfs_device }, { MAC_CREATE_DEVFS_DIRECTORY, @@ -1295,22 +1302,18 @@ static struct mac_policy_op_entry mac_test_ops[] = (macop_t)mac_test_create_devfs_symlink }, { MAC_CREATE_DEVFS_VNODE, (macop_t)mac_test_create_devfs_vnode }, - { MAC_CREATE_VNODE, - (macop_t)mac_test_create_vnode }, + { MAC_CREATE_VNODE_EXTATTR, + (macop_t)mac_test_create_vnode_extattr }, { MAC_CREATE_MOUNT, (macop_t)mac_test_create_mount }, { MAC_CREATE_ROOT_MOUNT, (macop_t)mac_test_create_root_mount }, { MAC_RELABEL_VNODE, (macop_t)mac_test_relabel_vnode }, + { MAC_SETLABEL_VNODE_EXTATTR, + (macop_t)mac_test_setlabel_vnode_extattr }, { MAC_UPDATE_DEVFSDIRENT, (macop_t)mac_test_update_devfsdirent }, - { MAC_UPDATE_PROCFSVNODE, - (macop_t)mac_test_update_procfsvnode }, - { MAC_UPDATE_VNODE_FROM_EXTERNALIZED, - (macop_t)mac_test_update_vnode_from_externalized }, - { MAC_UPDATE_VNODE_FROM_MOUNT, - (macop_t)mac_test_update_vnode_from_mount }, { MAC_CREATE_MBUF_FROM_SOCKET, (macop_t)mac_test_create_mbuf_from_socket }, { MAC_CREATE_PIPE, |