vfs: remove the obsolete privused argument from vaccess

This brings argument count down to 6, which is passable without the
stack on amd64.
This commit is contained in:
Mateusz Guzik 2020-08-05 09:27:03 +00:00
parent 2b86f9d6d0
commit d292b1940c
19 changed files with 36 additions and 64 deletions

View File

@ -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);
}
}

View File

@ -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

View File

@ -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)

View File

@ -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);
}

View File

@ -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) {

View File

@ -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

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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 */

View File

@ -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));

View File

@ -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

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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);
}

View File

@ -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 *);

View File

@ -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);
}