summaryrefslogtreecommitdiffstats
path: root/sys/gnu
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-08-15 20:55:08 +0000
committerrwatson <rwatson@FreeBSD.org>2002-08-15 20:55:08 +0000
commit44404e4547aee87b255582d4e6395551869e29b1 (patch)
tree09f20587d6bc57d661c96f87771a6081e65d834f /sys/gnu
parent54a3d67ad2855b152e05f56266188e6214dbcfa1 (diff)
downloadFreeBSD-src-44404e4547aee87b255582d4e6395551869e29b1.zip
FreeBSD-src-44404e4547aee87b255582d4e6395551869e29b1.tar.gz
In order to better support flexible and extensible access control,
make a series of modifications to the credential arguments relating to file read and write operations to cliarfy which credential is used for what: - Change fo_read() and fo_write() to accept "active_cred" instead of "cred", and change the semantics of consumers of fo_read() and fo_write() to pass the active credential of the thread requesting an operation rather than the cached file cred. The cached file cred is still available in fo_read() and fo_write() consumers via fp->f_cred. These changes largely in sys_generic.c. For each implementation of fo_read() and fo_write(), update cred usage to reflect this change and maintain current semantics: - badfo_readwrite() unchanged - kqueue_read/write() unchanged pipe_read/write() now authorize MAC using active_cred rather than td->td_ucred - soo_read/write() unchanged - vn_read/write() now authorize MAC using active_cred but VOP_READ/WRITE() with fp->f_cred Modify vn_rdwr() to accept two credential arguments instead of a single credential: active_cred and file_cred. Use active_cred for MAC authorization, and select a credential for use in VOP_READ/WRITE() based on whether file_cred is NULL or not. If file_cred is provided, authorize the VOP using that cred, otherwise the active credential, matching current semantics. Modify current vn_rdwr() consumers to pass a file_cred if used in the context of a struct file, and to always pass active_cred. When vn_rdwr() is used without a file_cred, pass NOCRED. These changes should maintain current semantics for read/write, but avoid a redundant passing of fp->f_cred, as well as making it more clear what the origin of each credential is in file descriptor read/write operations. Follow-up commits will make similar changes to other file descriptor operations, and modify the MAC framework to pass both credentials to MAC policy modules so they can implement either semantic for revocation. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
Diffstat (limited to 'sys/gnu')
-rw-r--r--sys/gnu/ext2fs/ext2_lookup.c4
-rw-r--r--sys/gnu/ext2fs/ext2_vnops.c12
-rw-r--r--sys/gnu/fs/ext2fs/ext2_lookup.c4
-rw-r--r--sys/gnu/fs/ext2fs/ext2_vnops.c12
4 files changed, 18 insertions, 14 deletions
diff --git a/sys/gnu/ext2fs/ext2_lookup.c b/sys/gnu/ext2fs/ext2_lookup.c
index b550540..bddc3bb 100644
--- a/sys/gnu/ext2fs/ext2_lookup.c
+++ b/sys/gnu/ext2fs/ext2_lookup.c
@@ -1011,7 +1011,7 @@ ext2_dirempty(ip, parentino, cred)
for (off = 0; off < ip->i_size; off += dp->rec_len) {
error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ,
off, UIO_SYSSPACE, IO_NODELOCKED | IO_NOMACCHECK, cred,
- &count, (struct thread *)0);
+ NOCRED, &count, (struct thread *)0);
/*
* Since we read MINDIRSIZ, residual must
* be 0 unless we're at end of file.
@@ -1075,7 +1075,7 @@ ext2_checkpath(source, target, cred)
}
error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf,
sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE,
- IO_NODELOCKED | IO_NOMACCHECK, cred, (int *)0,
+ IO_NODELOCKED | IO_NOMACCHECK, cred, NOCRED, (int *)0,
(struct thread *)0);
if (error != 0)
break;
diff --git a/sys/gnu/ext2fs/ext2_vnops.c b/sys/gnu/ext2fs/ext2_vnops.c
index 915276d..8c93c07 100644
--- a/sys/gnu/ext2fs/ext2_vnops.c
+++ b/sys/gnu/ext2fs/ext2_vnops.c
@@ -1224,7 +1224,8 @@ abortit:
error = vn_rdwr(UIO_READ, fvp, (caddr_t)&dirbuf,
sizeof (struct dirtemplate), (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED | IO_NOMACCHECK,
- tcnp->cn_cred, (int *)0, (struct thread *)0);
+ tcnp->cn_cred, NOCRED, (int *)0,
+ (struct thread *)0);
if (error == 0) {
/* Like ufs little-endian: */
namlen = dirbuf.dotdot_type;
@@ -1241,7 +1242,8 @@ abortit:
(off_t)0, UIO_SYSSPACE,
IO_NODELOCKED | IO_SYNC |
IO_NOMACCHECK, tcnp->cn_cred,
- (int *)0, (struct thread *)0);
+ NOCRED, (int *)0,
+ (struct thread *)0);
cache_purge(fdvp);
}
}
@@ -1376,8 +1378,8 @@ ext2_mkdir(ap)
dirtemplate.dotdot_reclen = DIRBLKSIZ - 12;
error = vn_rdwr(UIO_WRITE, tvp, (caddr_t)&dirtemplate,
sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
- IO_NODELOCKED | IO_SYNC | IO_NOMACCHECK, cnp->cn_cred, (int *)0,
- (struct thread *)0);
+ IO_NODELOCKED | IO_SYNC | IO_NOMACCHECK, cnp->cn_cred, NOCRED,
+ (int *)0, (struct thread *)0);
if (error) {
dp->i_nlink--;
dp->i_flag |= IN_CHANGE;
@@ -1514,7 +1516,7 @@ ext2_symlink(ap)
} else
error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED | IO_NOMACCHECK,
- ap->a_cnp->cn_cred, (int *)0, (struct thread *)0);
+ ap->a_cnp->cn_cred, NOCRED, (int *)0, (struct thread *)0);
if (error)
vput(vp);
return (error);
diff --git a/sys/gnu/fs/ext2fs/ext2_lookup.c b/sys/gnu/fs/ext2fs/ext2_lookup.c
index b550540..bddc3bb 100644
--- a/sys/gnu/fs/ext2fs/ext2_lookup.c
+++ b/sys/gnu/fs/ext2fs/ext2_lookup.c
@@ -1011,7 +1011,7 @@ ext2_dirempty(ip, parentino, cred)
for (off = 0; off < ip->i_size; off += dp->rec_len) {
error = vn_rdwr(UIO_READ, ITOV(ip), (caddr_t)dp, MINDIRSIZ,
off, UIO_SYSSPACE, IO_NODELOCKED | IO_NOMACCHECK, cred,
- &count, (struct thread *)0);
+ NOCRED, &count, (struct thread *)0);
/*
* Since we read MINDIRSIZ, residual must
* be 0 unless we're at end of file.
@@ -1075,7 +1075,7 @@ ext2_checkpath(source, target, cred)
}
error = vn_rdwr(UIO_READ, vp, (caddr_t)&dirbuf,
sizeof (struct dirtemplate), (off_t)0, UIO_SYSSPACE,
- IO_NODELOCKED | IO_NOMACCHECK, cred, (int *)0,
+ IO_NODELOCKED | IO_NOMACCHECK, cred, NOCRED, (int *)0,
(struct thread *)0);
if (error != 0)
break;
diff --git a/sys/gnu/fs/ext2fs/ext2_vnops.c b/sys/gnu/fs/ext2fs/ext2_vnops.c
index 915276d..8c93c07 100644
--- a/sys/gnu/fs/ext2fs/ext2_vnops.c
+++ b/sys/gnu/fs/ext2fs/ext2_vnops.c
@@ -1224,7 +1224,8 @@ abortit:
error = vn_rdwr(UIO_READ, fvp, (caddr_t)&dirbuf,
sizeof (struct dirtemplate), (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED | IO_NOMACCHECK,
- tcnp->cn_cred, (int *)0, (struct thread *)0);
+ tcnp->cn_cred, NOCRED, (int *)0,
+ (struct thread *)0);
if (error == 0) {
/* Like ufs little-endian: */
namlen = dirbuf.dotdot_type;
@@ -1241,7 +1242,8 @@ abortit:
(off_t)0, UIO_SYSSPACE,
IO_NODELOCKED | IO_SYNC |
IO_NOMACCHECK, tcnp->cn_cred,
- (int *)0, (struct thread *)0);
+ NOCRED, (int *)0,
+ (struct thread *)0);
cache_purge(fdvp);
}
}
@@ -1376,8 +1378,8 @@ ext2_mkdir(ap)
dirtemplate.dotdot_reclen = DIRBLKSIZ - 12;
error = vn_rdwr(UIO_WRITE, tvp, (caddr_t)&dirtemplate,
sizeof (dirtemplate), (off_t)0, UIO_SYSSPACE,
- IO_NODELOCKED | IO_SYNC | IO_NOMACCHECK, cnp->cn_cred, (int *)0,
- (struct thread *)0);
+ IO_NODELOCKED | IO_SYNC | IO_NOMACCHECK, cnp->cn_cred, NOCRED,
+ (int *)0, (struct thread *)0);
if (error) {
dp->i_nlink--;
dp->i_flag |= IN_CHANGE;
@@ -1514,7 +1516,7 @@ ext2_symlink(ap)
} else
error = vn_rdwr(UIO_WRITE, vp, ap->a_target, len, (off_t)0,
UIO_SYSSPACE, IO_NODELOCKED | IO_NOMACCHECK,
- ap->a_cnp->cn_cred, (int *)0, (struct thread *)0);
+ ap->a_cnp->cn_cred, NOCRED, (int *)0, (struct thread *)0);
if (error)
vput(vp);
return (error);
OpenPOWER on IntegriCloud