Note, this opens up pending items for cleanup, from my notes: - fuse_file_open (into fb_setup) - nfs_vinvalbuf (and vinvalbuf itself).
I'm skeptical of touching the latter until I have (again) some facsimile of the setup that lives in theo's basement :) On Sat, Jul 15, 2023 at 02:20:36PM +0200, Thordur Bjornsson wrote: > First of a few. > > Many thanks to mpi@ for adding the curproc assert's! > > Two questions: > - NOCRED: Best this should just be NULL ? > - FSCRED: This is only AFAICT used for mounts > Not 100% clear, but this could perhaps be done away with at the loss > of some metadata (it just forces spec_open to open up given secure > levels) in ufs. beck@, thoughts ? (i want to say the S word, but not > sure if it is strictly true). > > diff --git sys/dev/softraid.c sys/dev/softraid.c > index decea16cb24..2319b85b946 100644 > --- sys/dev/softraid.c > +++ sys/dev/softraid.c > @@ -333,7 +333,7 @@ sr_meta_probe(struct sr_discipline *sd, dev_t *dt, int > no_chunk) > * XXX leaving dev open for now; move this to attach > * and figure out the open/close dance for unwind. > */ > - error = VOP_OPEN(vn, FREAD | FWRITE, NOCRED, curproc); > + error = VOP_OPEN(vn, FREAD | FWRITE, NOCRED); > if (error) { > DNPRINTF(SR_D_META,"%s: sr_meta_probe can't " > "open %s\n", DEVNAME(sc), devname); > @@ -1037,7 +1037,7 @@ sr_meta_native_bootprobe(struct sr_softc *sc, dev_t > devno, > } > > /* open device */ > - error = VOP_OPEN(vn, FREAD, NOCRED, curproc); > + error = VOP_OPEN(vn, FREAD, NOCRED); > if (error) { > DNPRINTF(SR_D_META, "%s: sr_meta_native_bootprobe open " > "failed\n", DEVNAME(sc)); > @@ -1093,7 +1093,7 @@ sr_meta_native_bootprobe(struct sr_softc *sc, dev_t > devno, > "allocate vnode for partition"); > goto done; > } > - error = VOP_OPEN(vn, FREAD, NOCRED, curproc); > + error = VOP_OPEN(vn, FREAD, NOCRED); > if (error) { > DNPRINTF(SR_D_META, "%s: sr_meta_native_bootprobe " > "open failed, partition %d\n", > @@ -2833,7 +2833,7 @@ sr_hotspare(struct sr_softc *sc, dev_t dev) > sr_error(sc, "sr_hotspare: cannot allocate vnode"); > goto done; > } > - if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED, curproc)) { > + if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED)) { > DNPRINTF(SR_D_META,"%s: sr_hotspare cannot open %s\n", > DEVNAME(sc), devname); > vput(vn); > @@ -3147,7 +3147,7 @@ sr_rebuild_init(struct sr_discipline *sd, dev_t dev, > int hotspare) > DEVNAME(sc)); > goto done; > } > - if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED, curproc)) { > + if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED)) { > DNPRINTF(SR_D_META,"%s: sr_ioctl_setstate can't " > "open %s\n", DEVNAME(sc), devname); > vput(vn); > diff --git sys/dev/softraid_crypto.c sys/dev/softraid_crypto.c > index fbe8358e5dd..354c6560180 100644 > --- sys/dev/softraid_crypto.c > +++ sys/dev/softraid_crypto.c > @@ -665,7 +665,7 @@ sr_crypto_create_key_disk(struct sr_discipline *sd, > sr_error(sc, "cannot open key disk %s", devname); > goto done; > } > - if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED, curproc)) { > + if (VOP_OPEN(vn, FREAD | FWRITE, NOCRED)) { > DNPRINTF(SR_D_META,"%s: sr_crypto_create_key_disk cannot " > "open %s\n", DEVNAME(sc), devname); > vput(vn); > @@ -829,7 +829,7 @@ sr_crypto_read_key_disk(struct sr_discipline *sd, struct > sr_crypto *mdd_crypto, > sr_error(sc, "cannot open key disk %s", devname); > goto done; > } > - if (VOP_OPEN(vn, FREAD, NOCRED, curproc)) { > + if (VOP_OPEN(vn, FREAD, NOCRED)) { > DNPRINTF(SR_D_META,"%s: sr_crypto_read_key_disk cannot " > "open %s\n", DEVNAME(sc), devname); > vput(vn); > diff --git sys/isofs/cd9660/cd9660_vfsops.c sys/isofs/cd9660/cd9660_vfsops.c > index b844a2ff709..601c761a000 100644 > --- sys/isofs/cd9660/cd9660_vfsops.c > +++ sys/isofs/cd9660/cd9660_vfsops.c > @@ -240,7 +240,7 @@ iso_mountfs(struct vnode *devvp, struct mount *mp, struct > proc *p, > if (error) > return (error); > > - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); > + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED); > if (error) > return (error); > > diff --git sys/isofs/udf/udf_vfsops.c sys/isofs/udf/udf_vfsops.c > index c0fc5068e08..2a5b7f03314 100644 > --- sys/isofs/udf/udf_vfsops.c > +++ sys/isofs/udf/udf_vfsops.c > @@ -243,7 +243,7 @@ udf_mountfs(struct vnode *devvp, struct mount *mp, > uint32_t lb, struct proc *p) > if (error) > return (error); > > - error = VOP_OPEN(devvp, FREAD, FSCRED, p); > + error = VOP_OPEN(devvp, FREAD, FSCRED); > if (error) > return (error); > > diff --git sys/kern/kern_exec.c sys/kern/kern_exec.c > index 3f3112b018f..7253bc3cc8e 100644 > --- sys/kern/kern_exec.c > +++ sys/kern/kern_exec.c > @@ -172,7 +172,7 @@ check_exec(struct proc *p, struct exec_package *epp) > } > > /* try to open it */ > - if ((error = VOP_OPEN(vp, FREAD, p->p_ucred, p)) != 0) > + if ((error = VOP_OPEN(vp, FREAD, p->p_ucred)) != 0) > goto bad1; > > /* unlock vp, we need it unlocked from here */ > @@ -630,7 +630,7 @@ sys_execve(struct proc *p, void *v, register_t *retval) > closef(fp, p); > break; > } > - if ((error = VOP_OPEN(vp, flags, cred, p)) != > 0) { > + if ((error = VOP_OPEN(vp, flags, cred)) != 0) { > fdremove(p->p_fd, indx); > closef(fp, p); > vrele(vp); > diff --git sys/kern/spec_vnops.c sys/kern/spec_vnops.c > index f43ceda680f..9bd8f0dc09e 100644 > --- sys/kern/spec_vnops.c > +++ sys/kern/spec_vnops.c > @@ -100,7 +100,7 @@ int > spec_open(void *v) > { > struct vop_open_args *ap = v; > - struct proc *p = ap->a_p; > + struct proc *p = curproc; > struct vnode *vp = ap->a_vp; > struct vnode *bvp; > dev_t bdev; > @@ -721,7 +721,7 @@ spec_open_clone(struct vop_open_args *ap) > VOP_UNLOCK(vp); > > error = cdevsw[major(vp->v_rdev)].d_open(cvp->v_rdev, ap->a_mode, > - S_IFCHR, ap->a_p); > + S_IFCHR, curproc); > > vn_lock(vp, LK_EXCLUSIVE | LK_RETRY); > > diff --git sys/kern/subr_disk.c sys/kern/subr_disk.c > index f90d41d14a5..05e0ebba624 100644 > --- sys/kern/subr_disk.c > +++ sys/kern/subr_disk.c > @@ -1731,7 +1731,7 @@ disk_readlabel(struct disklabel *dl, dev_t dev, char > *errbuf, size_t errsize) > return (errbuf); > } > > - error = VOP_OPEN(vn, FREAD, NOCRED, curproc); > + error = VOP_OPEN(vn, FREAD, NOCRED); > if (error) { > snprintf(errbuf, errsize, > "cannot open disk, 0x%x/0x%x, error %d", > diff --git sys/kern/tty_pty.c sys/kern/tty_pty.c > index 2d51d9caf2c..dd9dca7539a 100644 > --- sys/kern/tty_pty.c > +++ sys/kern/tty_pty.c > @@ -1022,7 +1022,7 @@ ptm_vn_open(struct nameidata *ndp) > * Get us a fresh cred with root privileges. > */ > cred = crget(); > - error = VOP_OPEN(vp, FREAD|FWRITE, cred, p); > + error = VOP_OPEN(vp, FREAD|FWRITE, cred); > if (!error) { > /* update atime/mtime */ > VATTR_NULL(&vattr); > diff --git sys/kern/tty_tty.c sys/kern/tty_tty.c > index d34aa0cee9f..c54912d715e 100644 > --- sys/kern/tty_tty.c > +++ sys/kern/tty_tty.c > @@ -57,7 +57,7 @@ cttyopen(dev_t dev, int flag, int mode, struct proc *p) > if (ttyvp == NULL) > return (ENXIO); > vn_lock(ttyvp, LK_EXCLUSIVE | LK_RETRY); > - error = VOP_OPEN(ttyvp, flag, NOCRED, p); > + error = VOP_OPEN(ttyvp, flag, NOCRED); > VOP_UNLOCK(ttyvp); > return (error); > } > diff --git sys/kern/vfs_syscalls.c sys/kern/vfs_syscalls.c > index 43462b1496e..1bcbd6b45f0 100644 > --- sys/kern/vfs_syscalls.c > +++ sys/kern/vfs_syscalls.c > @@ -1413,7 +1413,7 @@ sys_fhopen(struct proc *p, void *v, register_t *retval) > if ((error = VOP_SETATTR(vp, &va, cred, p)) != 0) > goto bad; > } > - if ((error = VOP_OPEN(vp, flags, cred, p)) != 0) > + if ((error = VOP_OPEN(vp, flags, cred)) != 0) > goto bad; > if (flags & FWRITE) > vp->v_writecount++; > diff --git sys/kern/vfs_vnops.c sys/kern/vfs_vnops.c > index 765b70a0947..071c2b8ed4f 100644 > --- sys/kern/vfs_vnops.c > +++ sys/kern/vfs_vnops.c > @@ -174,7 +174,7 @@ vn_open(struct nameidata *ndp, int fmode, int cmode) > if ((error = VOP_SETATTR(vp, &va, cred, p)) != 0) > goto bad; > } > - if ((error = VOP_OPEN(vp, fmode, cred, p)) != 0) > + if ((error = VOP_OPEN(vp, fmode, cred)) != 0) > goto bad; > > if (vp->v_flag & VCLONED) { > diff --git sys/kern/vfs_vops.c sys/kern/vfs_vops.c > index 3d08b2ec5ca..2cf321d8d21 100644 > --- sys/kern/vfs_vops.c > +++ sys/kern/vfs_vops.c > @@ -122,15 +122,12 @@ VOP_MKNOD(struct vnode *dvp, struct vnode **vpp, > } > > int > -VOP_OPEN(struct vnode *vp, int mode, struct ucred *cred, struct proc *p) > +VOP_OPEN(struct vnode *vp, int mode, struct ucred *cred) > { > struct vop_open_args a; > a.a_vp = vp; > a.a_mode = mode; > a.a_cred = cred; > - a.a_p = p; > - > - KASSERT(p == curproc); > > if (vp->v_op->vop_open == NULL) > return (EOPNOTSUPP); > diff --git sys/miscfs/fifofs/fifo_vnops.c sys/miscfs/fifofs/fifo_vnops.c > index 985b0e4cab4..105ad54c8fe 100644 > --- sys/miscfs/fifofs/fifo_vnops.c > +++ sys/miscfs/fifofs/fifo_vnops.c > @@ -225,7 +225,7 @@ fifo_open(void *v) > } > return (0); > bad: > - VOP_CLOSE(vp, ap->a_mode, ap->a_cred, ap->a_p); > + VOP_CLOSE(vp, ap->a_mode, ap->a_cred, curproc); > return (error); > } > > diff --git sys/miscfs/fuse/fuse_vnops.c sys/miscfs/fuse/fuse_vnops.c > index 8f9a66f2c15..505297b513d 100644 > --- sys/miscfs/fuse/fuse_vnops.c > +++ sys/miscfs/fuse/fuse_vnops.c > @@ -281,7 +281,7 @@ fusefs_open(void *v) > * that no creation and truncation flags are passed to open. > */ > flags = OFLAGS(ap->a_mode) & ~(O_CREAT|O_EXCL|O_TRUNC); > - error = fusefs_file_open(fmp, ip, fufh_type, flags, isdir, ap->a_p); > + error = fusefs_file_open(fmp, ip, fufh_type, flags, isdir, curproc); > > return (error); > } > diff --git sys/msdosfs/msdosfs_vfsops.c sys/msdosfs/msdosfs_vfsops.c > index 6b90195b5e5..01324f2bdd0 100644 > --- sys/msdosfs/msdosfs_vfsops.c > +++ sys/msdosfs/msdosfs_vfsops.c > @@ -263,7 +263,7 @@ msdosfs_mountfs(struct vnode *devvp, struct mount *mp, > struct proc *p, > return (error); > > ronly = (mp->mnt_flag & MNT_RDONLY) != 0; > - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); > + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED); > if (error) > return (error); > > diff --git sys/nfs/nfs_vnops.c sys/nfs/nfs_vnops.c > index d61f0a46847..c5076edd46c 100644 > --- sys/nfs/nfs_vnops.c > +++ sys/nfs/nfs_vnops.c > @@ -472,25 +472,25 @@ nfs_open(void *v) > } > > if (np->n_flag & NMODIFIED) { > - error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p); > + error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, curproc); > if (error == EINTR) > return (error); > uvm_vnp_uncache(vp); > NFS_INVALIDATE_ATTRCACHE(np); > if (vp->v_type == VDIR) > np->n_direofoffset = 0; > - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); > + error = VOP_GETATTR(vp, &vattr, ap->a_cred, curproc); > if (error) > return (error); > np->n_mtime = vattr.va_mtime; > } else { > - error = VOP_GETATTR(vp, &vattr, ap->a_cred, ap->a_p); > + error = VOP_GETATTR(vp, &vattr, ap->a_cred, curproc); > if (error) > return (error); > if (timespeccmp(&np->n_mtime, &vattr.va_mtime, !=)) { > if (vp->v_type == VDIR) > np->n_direofoffset = 0; > - error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p); > + error = nfs_vinvalbuf(vp, V_SAVE, ap->a_cred, curproc); > if (error == EINTR) > return (error); > uvm_vnp_uncache(vp); > diff --git sys/ntfs/ntfs_vfsops.c sys/ntfs/ntfs_vfsops.c > index d665f5db8df..ca083954f98 100644 > --- sys/ntfs/ntfs_vfsops.c > +++ sys/ntfs/ntfs_vfsops.c > @@ -284,7 +284,7 @@ ntfs_mountfs(struct vnode *devvp, struct mount *mp, > struct ntfs_args *argsp, > if (error) > return (error); > > - error = VOP_OPEN(devvp, FREAD, FSCRED, p); > + error = VOP_OPEN(devvp, FREAD, FSCRED); > if (error) > return (error); > > diff --git sys/sys/vnode.h sys/sys/vnode.h > index b2f0fa4b60c..b900e34285d 100644 > --- sys/sys/vnode.h > +++ sys/sys/vnode.h > @@ -335,9 +335,8 @@ struct vop_open_args { > struct vnode *a_vp; > int a_mode; > struct ucred *a_cred; > - struct proc *a_p; > }; > -int VOP_OPEN(struct vnode *, int, struct ucred *, struct proc *); > +int VOP_OPEN(struct vnode *, int, struct ucred *); > > struct vop_close_args { > struct vnode *a_vp; > diff --git sys/ufs/ext2fs/ext2fs_vfsops.c sys/ufs/ext2fs/ext2fs_vfsops.c > index 3baea804c68..57b973433e0 100644 > --- sys/ufs/ext2fs/ext2fs_vfsops.c > +++ sys/ufs/ext2fs/ext2fs_vfsops.c > @@ -513,7 +513,7 @@ ext2fs_mountfs(struct vnode *devvp, struct mount *mp, > struct proc *p) > return (error); > > ronly = (mp->mnt_flag & MNT_RDONLY) != 0; > - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); > + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED); > if (error) > return (error); > > diff --git sys/ufs/ffs/ffs_vfsops.c sys/ufs/ffs/ffs_vfsops.c > index 8c780d5340b..9778ec7264d 100644 > --- sys/ufs/ffs/ffs_vfsops.c > +++ sys/ufs/ffs/ffs_vfsops.c > @@ -723,7 +723,7 @@ ffs_mountfs(struct vnode *devvp, struct mount *mp, struct > proc *p) > return (error); > > ronly = (mp->mnt_flag & MNT_RDONLY) != 0; > - error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED, p); > + error = VOP_OPEN(devvp, ronly ? FREAD : FREAD|FWRITE, FSCRED); > if (error) > return (error); > > diff --git sys/uvm/uvm_swap.c sys/uvm/uvm_swap.c > index 27963259eba..65348470683 100644 > --- sys/uvm/uvm_swap.c > +++ sys/uvm/uvm_swap.c > @@ -911,7 +911,7 @@ swap_on(struct proc *p, struct swapdev *sdp) > * has already been opened when root was mounted (mountroot). > */ > if (vp != rootvp) { > - if ((error = VOP_OPEN(vp, FREAD|FWRITE, p->p_ucred, p))) > + if ((error = VOP_OPEN(vp, FREAD|FWRITE, p->p_ucred))) > return (error); > } > >