From d292b1940c9cc327810627c486cbcfa7e12ce8ad Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Wed, 5 Aug 2020 09:27:03 +0000 Subject: [PATCH] vfs: remove the obsolete privused argument from vaccess This brings argument count down to 6, which is passable without the stack on amd64. --- .../opensolaris/uts/common/fs/zfs/zfs_vnops.c | 2 +- sys/fs/cd9660/cd9660_vnops.c | 2 +- sys/fs/devfs/devfs_vnops.c | 2 +- sys/fs/ext2fs/ext2_vnops.c | 2 +- sys/fs/fuse/fuse_internal.c | 2 +- sys/fs/msdosfs/msdosfs_vnops.c | 2 +- sys/fs/nfsclient/nfs_clvnops.c | 4 ++-- sys/fs/pseudofs/pseudofs_vnops.c | 4 ++-- sys/fs/smbfs/smbfs_vnops.c | 2 +- sys/fs/tmpfs/tmpfs_vnops.c | 4 ++-- sys/fs/udf/udf_vnops.c | 2 +- sys/kern/subr_acl_nfs4.c | 8 +------- sys/kern/subr_acl_posix1e.c | 14 +------------- sys/kern/uipc_mqueue.c | 8 ++++---- sys/kern/uipc_sem.c | 4 ++-- sys/kern/uipc_shm.c | 6 +++--- sys/kern/vfs_subr.c | 14 +++----------- sys/sys/vnode.h | 8 +++----- sys/ufs/ufs/ufs_vnops.c | 10 +++++----- 19 files changed, 36 insertions(+), 64 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c index 13f3412e96f5..9ac9503d2f77 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vnops.c @@ -4941,7 +4941,7 @@ zfs_freebsd_access(ap) accmode = ap->a_accmode & ~(VREAD|VWRITE|VEXEC|VAPPEND); if (accmode != 0) { error = vaccess(vp->v_type, zp->z_mode, zp->z_uid, - zp->z_gid, accmode, ap->a_cred, NULL); + zp->z_gid, accmode, ap->a_cred); } } diff --git a/sys/fs/cd9660/cd9660_vnops.c b/sys/fs/cd9660/cd9660_vnops.c index 43bb900efff8..92af83db0abb 100644 --- a/sys/fs/cd9660/cd9660_vnops.c +++ b/sys/fs/cd9660/cd9660_vnops.c @@ -158,7 +158,7 @@ cd9660_access(ap) } return (vaccess(vp->v_type, ip->inode.iso_mode, ip->inode.iso_uid, - ip->inode.iso_gid, ap->a_accmode, ap->a_cred, NULL)); + ip->inode.iso_gid, ap->a_accmode, ap->a_cred)); } static int diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index c21c1128543e..0605fad13cf5 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -533,7 +533,7 @@ devfs_access(struct vop_access_args *ap) de = de->de_dir; error = vaccess(vp->v_type, de->de_mode, de->de_uid, de->de_gid, - ap->a_accmode, ap->a_cred, NULL); + ap->a_accmode, ap->a_cred); if (error == 0) return (0); if (error != EACCES) diff --git a/sys/fs/ext2fs/ext2_vnops.c b/sys/fs/ext2fs/ext2_vnops.c index b98f8289e05c..0944889c3cce 100644 --- a/sys/fs/ext2fs/ext2_vnops.c +++ b/sys/fs/ext2fs/ext2_vnops.c @@ -348,7 +348,7 @@ ext2_access(struct vop_access_args *ap) return (EPERM); error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid, - ap->a_accmode, ap->a_cred, NULL); + ap->a_accmode, ap->a_cred); return (error); } diff --git a/sys/fs/fuse/fuse_internal.c b/sys/fs/fuse/fuse_internal.c index 22bc2d630971..2c4f90d1ece2 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -208,7 +208,7 @@ fuse_internal_access(struct vnode *vp, fuse_internal_getattr(vp, &va, cred, td); return vaccess(vp->v_type, va.va_mode, va.va_uid, - va.va_gid, mode, cred, NULL); + va.va_gid, mode, cred); } if (mode & VADMIN) { diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index d5df4f7ff4a7..11d26386f645 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -250,7 +250,7 @@ msdosfs_access(struct vop_access_args *ap) } return (vaccess(vp->v_type, file_mode, pmp->pm_uid, pmp->pm_gid, - ap->a_accmode, ap->a_cred, NULL)); + ap->a_accmode, ap->a_cred)); } static int diff --git a/sys/fs/nfsclient/nfs_clvnops.c b/sys/fs/nfsclient/nfs_clvnops.c index fd8e76ef028a..e93720f1a137 100644 --- a/sys/fs/nfsclient/nfs_clvnops.c +++ b/sys/fs/nfsclient/nfs_clvnops.c @@ -3393,8 +3393,8 @@ nfsspec_access(struct vop_access_args *ap) error = VOP_GETATTR(vp, vap, cred); if (error) goto out; - error = vaccess(vp->v_type, vap->va_mode, vap->va_uid, vap->va_gid, - accmode, cred, NULL); + error = vaccess(vp->v_type, vap->va_mode, vap->va_uid, vap->va_gid, + accmode, cred); out: return error; } diff --git a/sys/fs/pseudofs/pseudofs_vnops.c b/sys/fs/pseudofs/pseudofs_vnops.c index f4a0c3371088..75981d8b5350 100644 --- a/sys/fs/pseudofs/pseudofs_vnops.c +++ b/sys/fs/pseudofs/pseudofs_vnops.c @@ -167,8 +167,8 @@ pfs_access(struct vop_access_args *va) error = VOP_GETATTR(vn, &vattr, va->a_cred); if (error) PFS_RETURN (error); - error = vaccess(vn->v_type, vattr.va_mode, vattr.va_uid, - vattr.va_gid, va->a_accmode, va->a_cred, NULL); + error = vaccess(vn->v_type, vattr.va_mode, vattr.va_uid, vattr.va_gid, + va->a_accmode, va->a_cred); PFS_RETURN (error); } diff --git a/sys/fs/smbfs/smbfs_vnops.c b/sys/fs/smbfs/smbfs_vnops.c index 026fab8d000c..674ca7ede798 100644 --- a/sys/fs/smbfs/smbfs_vnops.c +++ b/sys/fs/smbfs/smbfs_vnops.c @@ -141,7 +141,7 @@ smbfs_access(ap) } mpmode = vp->v_type == VREG ? smp->sm_file_mode : smp->sm_dir_mode; return (vaccess(vp->v_type, mpmode, smp->sm_uid, - smp->sm_gid, ap->a_accmode, ap->a_cred, NULL)); + smp->sm_gid, ap->a_accmode, ap->a_cred)); } /* ARGSUSED */ diff --git a/sys/fs/tmpfs/tmpfs_vnops.c b/sys/fs/tmpfs/tmpfs_vnops.c index c0d970edeb94..0e414a46c701 100644 --- a/sys/fs/tmpfs/tmpfs_vnops.c +++ b/sys/fs/tmpfs/tmpfs_vnops.c @@ -396,8 +396,8 @@ tmpfs_access(struct vop_access_args *v) goto out; } - error = vaccess(vp->v_type, node->tn_mode, node->tn_uid, - node->tn_gid, accmode, cred, NULL); + error = vaccess(vp->v_type, node->tn_mode, node->tn_uid, node->tn_gid, + accmode, cred); out: MPASS(VOP_ISLOCKED(vp)); diff --git a/sys/fs/udf/udf_vnops.c b/sys/fs/udf/udf_vnops.c index 4a13c0c272c1..56a7613ad5a2 100644 --- a/sys/fs/udf/udf_vnops.c +++ b/sys/fs/udf/udf_vnops.c @@ -180,7 +180,7 @@ udf_access(struct vop_access_args *a) mode = udf_permtomode(node); return (vaccess(vp->v_type, mode, node->fentry->uid, node->fentry->gid, - accmode, a->a_cred, NULL)); + accmode, a->a_cred)); } static int diff --git a/sys/kern/subr_acl_nfs4.c b/sys/kern/subr_acl_nfs4.c index 05a4b653757b..4d36506ffa2f 100644 --- a/sys/kern/subr_acl_nfs4.c +++ b/sys/kern/subr_acl_nfs4.c @@ -172,7 +172,7 @@ _acl_denies(const struct acl *aclp, int access_mask, struct ucred *cred, int vaccess_acl_nfs4(enum vtype type, uid_t file_uid, gid_t file_gid, - struct acl *aclp, accmode_t accmode, struct ucred *cred, int *privused) + struct acl *aclp, accmode_t accmode, struct ucred *cred) { accmode_t priv_granted = 0; int denied, explicitly_denied, access_mask, is_directory, @@ -187,9 +187,6 @@ vaccess_acl_nfs4(enum vtype type, uid_t file_uid, gid_t file_gid, KASSERT((accmode & VAPPEND) == 0 || (accmode & VWRITE), ("VAPPEND without VWRITE")); - if (privused != NULL) - *privused = 0; - if (accmode & VADMIN) must_be_owner = 1; @@ -289,9 +286,6 @@ vaccess_acl_nfs4(enum vtype type, uid_t file_uid, gid_t file_gid, priv_granted |= VSTAT_PERMS; if ((accmode & priv_granted) == accmode) { - if (privused != NULL) - *privused = 1; - return (0); } diff --git a/sys/kern/subr_acl_posix1e.c b/sys/kern/subr_acl_posix1e.c index 5fd0aeefbc33..775957f9ef6f 100644 --- a/sys/kern/subr_acl_posix1e.c +++ b/sys/kern/subr_acl_posix1e.c @@ -57,7 +57,7 @@ __FBSDID("$FreeBSD$"); */ int vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, - struct acl *acl, accmode_t accmode, struct ucred *cred, int *privused) + struct acl *acl, accmode_t accmode, struct ucred *cred) { struct acl_entry *acl_other, *acl_mask; accmode_t dac_granted; @@ -77,8 +77,6 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, * privileges to use may be ambiguous due to "best match", in which * case fall back on first match for the time being. */ - if (privused != NULL) - *privused = 0; /* * Determine privileges now, but don't apply until we've found a DAC @@ -142,8 +140,6 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, */ if ((accmode & (dac_granted | priv_granted)) == accmode) { - if (privused != NULL) - *privused = 1; return (0); } goto error; @@ -220,8 +216,6 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, accmode) goto error; - if (privused != NULL) - *privused = 1; return (0); } } @@ -303,8 +297,6 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, != accmode) break; - if (privused != NULL) - *privused = 1; return (0); case ACL_GROUP: @@ -327,8 +319,6 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, != accmode) break; - if (privused != NULL) - *privused = 1; return (0); default: @@ -359,8 +349,6 @@ vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, * XXXRW: Do privilege lookup here. */ if ((accmode & (dac_granted | priv_granted)) == accmode) { - if (privused != NULL) - *privused = 1; return (0); } diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c index 5a4054df09f5..018630ca7dad 100644 --- a/sys/kern/uipc_mqueue.c +++ b/sys/kern/uipc_mqueue.c @@ -1178,8 +1178,8 @@ mqfs_access(struct vop_access_args *ap) error = VOP_GETATTR(vp, &vattr, ap->a_cred); if (error) return (error); - error = vaccess(vp->v_type, vattr.va_mode, vattr.va_uid, - vattr.va_gid, ap->a_accmode, ap->a_cred, NULL); + error = vaccess(vp->v_type, vattr.va_mode, vattr.va_uid, vattr.va_gid, + ap->a_accmode, ap->a_cred); return (error); } @@ -2088,7 +2088,7 @@ kern_kmq_open(struct thread *td, const char *upath, int flags, mode_t mode, if (flags & FWRITE) accmode |= VWRITE; error = vaccess(VREG, pn->mn_mode, pn->mn_uid, - pn->mn_gid, accmode, td->td_ucred, NULL); + pn->mn_gid, accmode, td->td_ucred); } } @@ -2566,7 +2566,7 @@ mqf_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, pn = fp->f_data; sx_xlock(&mqfs_data.mi_lock); error = vaccess(VREG, pn->mn_mode, pn->mn_uid, pn->mn_gid, VADMIN, - active_cred, NULL); + active_cred); if (error != 0) goto out; pn->mn_mode = mode & ACCESSPERMS; diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c index 27f586119c77..4d7c8ff03773 100644 --- a/sys/kern/uipc_sem.c +++ b/sys/kern/uipc_sem.c @@ -212,7 +212,7 @@ ksem_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, goto out; #endif error = vaccess(VREG, ks->ks_mode, ks->ks_uid, ks->ks_gid, VADMIN, - active_cred, NULL); + active_cred); if (error != 0) goto out; ks->ks_mode = mode & ACCESSPERMS; @@ -362,7 +362,7 @@ ksem_access(struct ksem *ks, struct ucred *ucred) int error; error = vaccess(VREG, ks->ks_mode, ks->ks_uid, ks->ks_gid, - VREAD | VWRITE, ucred, NULL); + VREAD | VWRITE, ucred); if (error) error = priv_check_cred(ucred, PRIV_SEM_WRITE); return (error); diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index a8af8c815492..796c2b08582a 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -679,7 +679,7 @@ shm_access(struct shmfd *shmfd, struct ucred *ucred, int flags) accmode |= VWRITE; mtx_lock(&shm_timestamp_lock); error = vaccess(VREG, shmfd->shm_mode, shmfd->shm_uid, shmfd->shm_gid, - accmode, ucred, NULL); + accmode, ucred); mtx_unlock(&shm_timestamp_lock); return (error); } @@ -1240,8 +1240,8 @@ shm_chmod(struct file *fp, mode_t mode, struct ucred *active_cred, if (error != 0) goto out; #endif - error = vaccess(VREG, shmfd->shm_mode, shmfd->shm_uid, - shmfd->shm_gid, VADMIN, active_cred, NULL); + error = vaccess(VREG, shmfd->shm_mode, shmfd->shm_uid, shmfd->shm_gid, + VADMIN, active_cred); if (error != 0) goto out; shmfd->shm_mode = mode & ACCESSPERMS; diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index d13150c2c7cf..8b1e6553452f 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -5299,14 +5299,12 @@ vaccess_vexec_smr(mode_t file_mode, uid_t file_uid, gid_t file_gid, struct ucred /* * Common filesystem object access control check routine. Accepts a - * vnode's type, "mode", uid and gid, requested access mode, credentials, - * and optional call-by-reference privused argument allowing vaccess() - * to indicate to the caller whether privilege was used to satisfy the - * request (obsoleted). Returns 0 on success, or an errno on failure. + * vnode's type, "mode", uid and gid, requested access mode, and credentials. + * Returns 0 on success, or an errno on failure. */ int vaccess(enum vtype type, mode_t file_mode, uid_t file_uid, gid_t file_gid, - accmode_t accmode, struct ucred *cred, int *privused) + accmode_t accmode, struct ucred *cred) { accmode_t dac_granted; accmode_t priv_granted; @@ -5321,9 +5319,6 @@ vaccess(enum vtype type, mode_t file_mode, uid_t file_uid, gid_t file_gid, * as requested. If it exists, go with that. */ - if (privused != NULL) - *privused = 0; - dac_granted = 0; /* Check the owner. */ @@ -5409,9 +5404,6 @@ privcheck: priv_granted |= VADMIN; if ((accmode & (priv_granted | dac_granted)) == accmode) { - /* XXX audit: privilege used */ - if (privused != NULL) - *privused = 1; return (0); } diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h index 398fb088d7f1..5d9e3496d12e 100644 --- a/sys/sys/vnode.h +++ b/sys/sys/vnode.h @@ -667,16 +667,14 @@ int vn_commname(struct vnode *vn, char *buf, u_int buflen); int vn_path_to_global_path(struct thread *td, struct vnode *vp, char *path, u_int pathlen); int vaccess(enum vtype type, mode_t file_mode, uid_t file_uid, - gid_t file_gid, accmode_t accmode, struct ucred *cred, - int *privused); + gid_t file_gid, accmode_t accmode, struct ucred *cred); int vaccess_vexec_smr(mode_t file_mode, uid_t file_uid, gid_t file_gid, struct ucred *cred); int vaccess_acl_nfs4(enum vtype type, uid_t file_uid, gid_t file_gid, - struct acl *aclp, accmode_t accmode, struct ucred *cred, - int *privused); + struct acl *aclp, accmode_t accmode, struct ucred *cred); int vaccess_acl_posix1e(enum vtype type, uid_t file_uid, gid_t file_gid, struct acl *acl, accmode_t accmode, - struct ucred *cred, int *privused); + struct ucred *cred); void vattr_null(struct vattr *vap); int vcount(struct vnode *vp); void vlazy(struct vnode *); diff --git a/sys/ufs/ufs/ufs_vnops.c b/sys/ufs/ufs/ufs_vnops.c index 70dd7dbe86c1..25c75e1d584f 100644 --- a/sys/ufs/ufs/ufs_vnops.c +++ b/sys/ufs/ufs/ufs_vnops.c @@ -390,12 +390,12 @@ ufs_accessx(ap) case 0: if (type == ACL_TYPE_NFS4) { error = vaccess_acl_nfs4(vp->v_type, ip->i_uid, - ip->i_gid, acl, accmode, ap->a_cred, NULL); + ip->i_gid, acl, accmode, ap->a_cred); } else { error = vfs_unixify_accmode(&accmode); if (error == 0) error = vaccess_acl_posix1e(vp->v_type, ip->i_uid, - ip->i_gid, acl, accmode, ap->a_cred, NULL); + ip->i_gid, acl, accmode, ap->a_cred); } break; default: @@ -410,8 +410,8 @@ ufs_accessx(ap) */ error = vfs_unixify_accmode(&accmode); if (error == 0) - error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, - ip->i_gid, accmode, ap->a_cred, NULL); + error = vaccess(vp->v_type, ip->i_mode, + ip->i_uid, ip->i_gid, accmode, ap->a_cred); } acl_free(acl); @@ -421,7 +421,7 @@ ufs_accessx(ap) error = vfs_unixify_accmode(&accmode); if (error == 0) error = vaccess(vp->v_type, ip->i_mode, ip->i_uid, ip->i_gid, - accmode, ap->a_cred, NULL); + accmode, ap->a_cred); return (error); }