diff options
author | rwatson <rwatson@FreeBSD.org> | 2005-07-14 10:22:09 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2005-07-14 10:22:09 +0000 |
commit | 79690d711b47ea3433f60ffea399d4d3e2f6c0a7 (patch) | |
tree | 67b10b3695790c746aa019b58c9526b34efb79ac /sys/fs | |
parent | 2976fcbe9269d2863b0e38be815f58a4182b4110 (diff) | |
download | FreeBSD-src-79690d711b47ea3433f60ffea399d4d3e2f6c0a7.zip FreeBSD-src-79690d711b47ea3433f60ffea399d4d3e2f6c0a7.tar.gz |
When devfs cloning takes place, provide access to the credential of the
process that caused the clone event to take place for the device driver
creating the device. This allows cloned device drivers to adapt the
device node based on security aspects of the process, such as the uid,
gid, and MAC label.
- Add a cred reference to struct cdev, so that when a device node is
instantiated as a vnode, the cloning credential can be exposed to
MAC.
- Add make_dev_cred(), a version of make_dev() that additionally
accepts the credential to stick in the struct cdev. Implement it and
make_dev() in terms of a back-end make_dev_credv().
- Add a new event handler, dev_clone_cred, which can be registered to
receive the credential instead of dev_clone, if desired.
- Modify the MAC entry point mac_create_devfs_device() to accept an
optional credential pointer (may be NULL), so that MAC policies can
inspect and act on the label or other elements of the credential
when initializing the skeleton device protections.
- Modify tty_pty.c to register clone_dev_cred and invoke make_dev_cred(),
so that the pty clone credential is exposed to the MAC Framework.
While currently primarily focussed on MAC policies, this change is also
a prerequisite for changes to allow ptys to be instantiated with the UID
of the process looking up the pty. This requires further changes to the
pty driver -- in particular, to immediately recycle pty nodes on last
close so that the credential-related state can be recreated on next
lookup.
Submitted by: Andrew Reisse <andrew.reisse@sparta.com>
Obtained from: TrustedBSD Project
Sponsored by: SPAWAR, SPARTA
MFC after: 1 week
MFC note: Merge to 6.x, but not 5.x for ABI reasons
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/devfs/devfs_devs.c | 3 | ||||
-rw-r--r-- | sys/fs/devfs/devfs_vnops.c | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c index 761caa5..172a63c 100644 --- a/sys/fs/devfs/devfs_devs.c +++ b/sys/fs/devfs/devfs_devs.c @@ -324,7 +324,8 @@ devfs_populate(struct devfs_mount *dm) de->de_dirent->d_type = DT_CHR; } #ifdef MAC - mac_create_devfs_device(dm->dm_mount, dev, de); + mac_create_devfs_device(dev->si_cred, dm->dm_mount, + dev, de); #endif *dep = de; de->de_dir = dd; diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index e0ceef2..b03498f 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -705,9 +705,13 @@ devfs_lookupx(ap) goto notfound; cdev = NULL; - EVENTHANDLER_INVOKE(dev_clone, pname, strlen(pname), &cdev); - if (cdev == NULL) - goto notfound; + EVENTHANDLER_INVOKE(dev_clone_cred, td->td_ucred, pname, + strlen(pname), &cdev); + if (cdev == NULL) { + EVENTHANDLER_INVOKE(dev_clone, pname, strlen(pname), &cdev); + if (cdev == NULL) + goto notfound; + } devfs_populate(dmp); |