Date: Tue, 12 Jan 2021 13:44:09 GMT From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 6b3a9a0f3d2c - main - Convert remaining cap_rights_init users to cap_rights_init_one Message-ID: <202101121344.10CDi9Ti053685@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=6b3a9a0f3d2cd66145e89fdd8d07cb33a9963e8f commit 6b3a9a0f3d2cd66145e89fdd8d07cb33a9963e8f Author: Mateusz Guzik <mjg@FreeBSD.org> AuthorDate: 2021-01-12 12:11:26 +0000 Commit: Mateusz Guzik <mjg@FreeBSD.org> CommitDate: 2021-01-12 13:16:10 +0000 Convert remaining cap_rights_init users to cap_rights_init_one semantic patch: @@ expression rights, r; @@ - cap_rights_init(&rights, r) + cap_rights_init_one(&rights, r) --- sys/amd64/sgx/sgx_linux.c | 3 ++- sys/compat/freebsd32/freebsd32_ioctl.c | 2 +- sys/compat/freebsd32/freebsd32_misc.c | 2 +- sys/compat/linux/linux_event.c | 7 ++++--- sys/dev/aac/aac_linux.c | 3 ++- sys/dev/aacraid/aacraid_linux.c | 2 +- sys/dev/amr/amr_linux.c | 2 +- sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 2 +- sys/dev/filemon/filemon_wrapper.c | 2 +- sys/dev/ipmi/ipmi_linux.c | 3 ++- sys/dev/iscsi/icl_soft.c | 2 +- sys/dev/iscsi_initiator/iscsi.c | 4 ++-- sys/dev/mfi/mfi_linux.c | 2 +- sys/dev/mrsas/mrsas_linux.c | 2 +- sys/dev/tdfx/tdfx_linux.c | 2 +- sys/fs/fdescfs/fdesc_vnops.c | 2 +- sys/fs/nfsclient/nfs_clport.c | 2 +- sys/fs/nfsserver/nfs_nfsdport.c | 2 +- sys/kern/kern_event.c | 3 ++- sys/kern/tty.c | 2 +- sys/kern/uipc_sem.c | 7 ++++--- sys/kern/uipc_usrreq.c | 6 ++++-- sys/netinet/sctp_syscalls.c | 4 ++-- sys/security/mac/mac_syscalls.c | 6 ++++-- sys/security/mac_veriexec/mac_veriexec.c | 4 ++-- sys/ufs/ffs/ffs_alloc.c | 2 +- 26 files changed, 45 insertions(+), 35 deletions(-) diff --git a/sys/amd64/sgx/sgx_linux.c b/sys/amd64/sgx/sgx_linux.c index 60ebec0e0278..c2975b0d2c84 100644 --- a/sys/amd64/sgx/sgx_linux.c +++ b/sys/amd64/sgx/sgx_linux.c @@ -63,7 +63,8 @@ sgx_linux_ioctl(struct thread *td, struct linux_ioctl_args *args) int error; int len; - error = fget(td, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(td, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), + &fp); if (error != 0) return (error); diff --git a/sys/compat/freebsd32/freebsd32_ioctl.c b/sys/compat/freebsd32/freebsd32_ioctl.c index db6946246b90..b3ed457f7132 100644 --- a/sys/compat/freebsd32/freebsd32_ioctl.c +++ b/sys/compat/freebsd32/freebsd32_ioctl.c @@ -212,7 +212,7 @@ freebsd32_ioctl(struct thread *td, struct freebsd32_ioctl_args *uap) cap_rights_t rights; int error; - error = fget(td, uap->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(td, uap->fd, cap_rights_init_one(&rights, CAP_IOCTL), &fp); if (error != 0) return (error); if ((fp->f_flag & (FREAD | FWRITE)) == 0) { diff --git a/sys/compat/freebsd32/freebsd32_misc.c b/sys/compat/freebsd32/freebsd32_misc.c index 14afd433d9f1..b7db1c4468d7 100644 --- a/sys/compat/freebsd32/freebsd32_misc.c +++ b/sys/compat/freebsd32/freebsd32_misc.c @@ -2095,7 +2095,7 @@ freebsd32_do_sendfile(struct thread *td, AUDIT_ARG_FD(uap->fd); if ((error = fget_read(td, uap->fd, - cap_rights_init(&rights, CAP_PREAD), &fp)) != 0) + cap_rights_init_one(&rights, CAP_PREAD), &fp)) != 0) goto out; error = fo_sendfile(fp, uap->s, hdr_uio, trl_uio, offset, diff --git a/sys/compat/linux/linux_event.c b/sys/compat/linux/linux_event.c index b4b4be1f7b49..dfb4588392cc 100644 --- a/sys/compat/linux/linux_event.c +++ b/sys/compat/linux/linux_event.c @@ -421,7 +421,7 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ctl_args *args) } error = fget(td, args->epfd, - cap_rights_init(&rights, CAP_KQUEUE_CHANGE), &epfp); + cap_rights_init_one(&rights, CAP_KQUEUE_CHANGE), &epfp); if (error != 0) return (error); if (epfp->f_type != DTYPE_KQUEUE) { @@ -430,7 +430,8 @@ linux_epoll_ctl(struct thread *td, struct linux_epoll_ctl_args *args) } /* Protect user data vector from incorrectly supplied fd. */ - error = fget(td, args->fd, cap_rights_init(&rights, CAP_POLL_EVENT), &fp); + error = fget(td, args->fd, + cap_rights_init_one(&rights, CAP_POLL_EVENT), &fp); if (error != 0) goto leave1; @@ -505,7 +506,7 @@ linux_epoll_wait_common(struct thread *td, int epfd, struct epoll_event *events, return (EINVAL); error = fget(td, epfd, - cap_rights_init(&rights, CAP_KQUEUE_EVENT), &epfp); + cap_rights_init_one(&rights, CAP_KQUEUE_EVENT), &epfp); if (error != 0) return (error); if (epfp->f_type != DTYPE_KQUEUE) { diff --git a/sys/dev/aac/aac_linux.c b/sys/dev/aac/aac_linux.c index 02babb5c0576..3f2d8a827441 100644 --- a/sys/dev/aac/aac_linux.c +++ b/sys/dev/aac/aac_linux.c @@ -82,7 +82,8 @@ aac_linux_ioctl(struct thread *td, struct linux_ioctl_args *args) u_long cmd; int error; - error = fget(td, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(td, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), + &fp); if (error != 0) return (error); cmd = args->cmd; diff --git a/sys/dev/aacraid/aacraid_linux.c b/sys/dev/aacraid/aacraid_linux.c index b58b8bacd7f3..7592a0d5a8cb 100644 --- a/sys/dev/aacraid/aacraid_linux.c +++ b/sys/dev/aacraid/aacraid_linux.c @@ -85,7 +85,7 @@ aacraid_linux_ioctl(struct thread *td, struct linux_ioctl_args *args) int error; if ((error = fget(td, args->fd, - cap_rights_init(&rights, CAP_IOCTL), + cap_rights_init_one(&rights, CAP_IOCTL), &fp)) != 0) { return (error); } diff --git a/sys/dev/amr/amr_linux.c b/sys/dev/amr/amr_linux.c index 967907cc6846..9e0a5cac693e 100644 --- a/sys/dev/amr/amr_linux.c +++ b/sys/dev/amr/amr_linux.c @@ -78,7 +78,7 @@ amr_linux_ioctl(struct thread *p, struct linux_ioctl_args *args) struct file *fp; int error; - error = fget(p, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(p, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), &fp); if (error != 0) return (error); error = fo_ioctl(fp, args->cmd, (caddr_t)args->arg, p->td_ucred, p); diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c index f5d4f03476cb..5588d3cb9511 100644 --- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c +++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c @@ -624,7 +624,7 @@ icl_cxgbei_conn_handoff(struct icl_conn *ic, int fd) * Steal the socket from userland. */ error = fget(curthread, fd, - cap_rights_init(&rights, CAP_SOCK_CLIENT), &fp); + cap_rights_init_one(&rights, CAP_SOCK_CLIENT), &fp); if (error != 0) return (error); if (fp->f_type != DTYPE_SOCKET) { diff --git a/sys/dev/filemon/filemon_wrapper.c b/sys/dev/filemon/filemon_wrapper.c index 52dd3bb483eb..4e64d8254f8d 100644 --- a/sys/dev/filemon/filemon_wrapper.c +++ b/sys/dev/filemon/filemon_wrapper.c @@ -185,7 +185,7 @@ _filemon_wrapper_openat(struct thread *td, const char *upath, int flags, * than nothing. */ if (getvnode(td, fd, - cap_rights_init(&rights, CAP_LOOKUP), &fp) == 0) { + cap_rights_init_one(&rights, CAP_LOOKUP), &fp) == 0) { vn_fullpath(fp->f_vnode, &atpath, &freepath); } } diff --git a/sys/dev/ipmi/ipmi_linux.c b/sys/dev/ipmi/ipmi_linux.c index 136712e8cfb5..4b33c5b014d8 100644 --- a/sys/dev/ipmi/ipmi_linux.c +++ b/sys/dev/ipmi/ipmi_linux.c @@ -96,7 +96,8 @@ ipmi_linux_ioctl(struct thread *td, struct linux_ioctl_args *args) u_long cmd; int error; - error = fget(td, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(td, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), + &fp); if (error != 0) return (error); cmd = args->cmd; diff --git a/sys/dev/iscsi/icl_soft.c b/sys/dev/iscsi/icl_soft.c index f8bcbb9eaa1c..bd4d9db81bb0 100644 --- a/sys/dev/iscsi/icl_soft.c +++ b/sys/dev/iscsi/icl_soft.c @@ -1397,7 +1397,7 @@ icl_soft_conn_handoff(struct icl_conn *ic, int fd) * Steal the socket from userland. */ error = fget(curthread, fd, - cap_rights_init(&rights, CAP_SOCK_CLIENT), &fp); + cap_rights_init_one(&rights, CAP_SOCK_CLIENT), &fp); if (error != 0) return (error); if (fp->f_type != DTYPE_SOCKET) { diff --git a/sys/dev/iscsi_initiator/iscsi.c b/sys/dev/iscsi_initiator/iscsi.c index 19c45f87d132..ce190c5c892a 100644 --- a/sys/dev/iscsi_initiator/iscsi.c +++ b/sys/dev/iscsi_initiator/iscsi.c @@ -392,8 +392,8 @@ i_setsoc(isc_session_t *sp, int fd, struct thread *td) if(sp->soc != NULL) isc_stop_receiver(sp); - error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_SOCK_CLIENT), - &sp->fp, NULL, NULL); + error = getsock_cap(td, fd, cap_rights_init_one(&rights, CAP_SOCK_CLIENT), + &sp->fp, NULL, NULL); if(error) return error; diff --git a/sys/dev/mfi/mfi_linux.c b/sys/dev/mfi/mfi_linux.c index 1452b80c280f..892b4f7a9fba 100644 --- a/sys/dev/mfi/mfi_linux.c +++ b/sys/dev/mfi/mfi_linux.c @@ -100,7 +100,7 @@ mfi_linux_ioctl(struct thread *p, struct linux_ioctl_args *args) break; } - error = fget(p, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(p, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), &fp); if (error != 0) return (error); error = fo_ioctl(fp, cmd, (caddr_t)args->arg, p->td_ucred, p); diff --git a/sys/dev/mrsas/mrsas_linux.c b/sys/dev/mrsas/mrsas_linux.c index 1794f977a21d..11ce3c3f8d54 100644 --- a/sys/dev/mrsas/mrsas_linux.c +++ b/sys/dev/mrsas/mrsas_linux.c @@ -121,7 +121,7 @@ mrsas_linux_ioctl(struct thread *p, struct linux_ioctl_args *args) goto END; } #if (__FreeBSD_version >= 1000000) - error = fget(p, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(p, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), &fp); #elif (__FreeBSD_version <= 900000) error = fget(p, args->fd, &fp); #else /* For FreeBSD version greater than diff --git a/sys/dev/tdfx/tdfx_linux.c b/sys/dev/tdfx/tdfx_linux.c index e20763b37647..922ff5478a42 100644 --- a/sys/dev/tdfx/tdfx_linux.c +++ b/sys/dev/tdfx/tdfx_linux.c @@ -57,7 +57,7 @@ linux_ioctl_tdfx(struct thread *td, struct linux_ioctl_args* args) struct file *fp; - error = fget(td, args->fd, cap_rights_init(&rights, CAP_IOCTL), &fp); + error = fget(td, args->fd, cap_rights_init_one(&rights, CAP_IOCTL), &fp); if (error != 0) return (error); /* We simply copy the data and send it right to ioctl */ diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c index ba13aaf1ce85..1271b50e6e94 100644 --- a/sys/fs/fdescfs/fdesc_vnops.c +++ b/sys/fs/fdescfs/fdesc_vnops.c @@ -496,7 +496,7 @@ fdesc_setattr(struct vop_setattr_args *ap) * Allow setattr where there is an underlying vnode. */ error = getvnode(td, fd, - cap_rights_init(&rights, CAP_EXTATTR_SET), &fp); + cap_rights_init_one(&rights, CAP_EXTATTR_SET), &fp); if (error) { /* * getvnode() returns EINVAL if the file descriptor is not diff --git a/sys/fs/nfsclient/nfs_clport.c b/sys/fs/nfsclient/nfs_clport.c index 730877b6eb6f..9c0ac5c4364e 100644 --- a/sys/fs/nfsclient/nfs_clport.c +++ b/sys/fs/nfsclient/nfs_clport.c @@ -1247,7 +1247,7 @@ nfssvc_nfscl(struct thread *td, struct nfssvc_args *uap) * careful than too reckless. */ error = fget(td, nfscbdarg.sock, - cap_rights_init(&rights, CAP_SOCK_CLIENT), &fp); + cap_rights_init_one(&rights, CAP_SOCK_CLIENT), &fp); if (error) return (error); if (fp->f_type != DTYPE_SOCKET) { diff --git a/sys/fs/nfsserver/nfs_nfsdport.c b/sys/fs/nfsserver/nfs_nfsdport.c index 8336a0b8fab2..b781503a6815 100644 --- a/sys/fs/nfsserver/nfs_nfsdport.c +++ b/sys/fs/nfsserver/nfs_nfsdport.c @@ -3609,7 +3609,7 @@ nfssvc_nfsd(struct thread *td, struct nfssvc_args *uap) * careful than too reckless. */ error = fget(td, sockarg.sock, - cap_rights_init(&rights, CAP_SOCK_SERVER), &fp); + cap_rights_init_one(&rights, CAP_SOCK_SERVER), &fp); if (error != 0) goto out; if (fp->f_type != DTYPE_SOCKET) { diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c index e22c987f8a08..5185723b8d10 100644 --- a/sys/kern/kern_event.c +++ b/sys/kern/kern_event.c @@ -2714,7 +2714,8 @@ kqfd_register(int fd, struct kevent *kev, struct thread *td, int mflag) cap_rights_t rights; int error; - error = fget(td, fd, cap_rights_init(&rights, CAP_KQUEUE_CHANGE), &fp); + error = fget(td, fd, cap_rights_init_one(&rights, CAP_KQUEUE_CHANGE), + &fp); if (error != 0) return (error); if ((error = kqueue_acquire(fp, &kq)) != 0) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 4b1f7ca52abe..00b4df675311 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -2087,7 +2087,7 @@ ttyhook_register(struct tty **rtp, struct proc *p, int fd, struct ttyhook *th, /* Validate the file descriptor. */ fdp = p->p_fd; - error = fget_unlocked(fdp, fd, cap_rights_init(&rights, CAP_TTYHOOK), + error = fget_unlocked(fdp, fd, cap_rights_init_one(&rights, CAP_TTYHOOK), &fp); if (error != 0) return (error); diff --git a/sys/kern/uipc_sem.c b/sys/kern/uipc_sem.c index bb47fe9a3905..db1d84696df0 100644 --- a/sys/kern/uipc_sem.c +++ b/sys/kern/uipc_sem.c @@ -725,7 +725,7 @@ sys_ksem_post(struct thread *td, struct ksem_post_args *uap) AUDIT_ARG_FD(uap->id); error = ksem_get(td, uap->id, - cap_rights_init(&rights, CAP_SEM_POST), &fp); + cap_rights_init_one(&rights, CAP_SEM_POST), &fp); if (error) return (error); ks = fp->f_data; @@ -817,7 +817,8 @@ kern_sem_wait(struct thread *td, semid_t id, int tryflag, DP((">>> kern_sem_wait entered! pid=%d\n", (int)td->td_proc->p_pid)); AUDIT_ARG_FD(id); - error = ksem_get(td, id, cap_rights_init(&rights, CAP_SEM_WAIT), &fp); + error = ksem_get(td, id, cap_rights_init_one(&rights, CAP_SEM_WAIT), + &fp); if (error) return (error); ks = fp->f_data; @@ -886,7 +887,7 @@ sys_ksem_getvalue(struct thread *td, struct ksem_getvalue_args *uap) AUDIT_ARG_FD(uap->id); error = ksem_get(td, uap->id, - cap_rights_init(&rights, CAP_SEM_GETVALUE), &fp); + cap_rights_init_one(&rights, CAP_SEM_GETVALUE), &fp); if (error) return (error); ks = fp->f_data; diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index afea72fd2700..ad369fc7b23e 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -636,7 +636,8 @@ uipc_bindat(int fd, struct socket *so, struct sockaddr *nam, struct thread *td) restart: NDINIT_ATRIGHTS(&nd, CREATE, NOFOLLOW | LOCKPARENT | SAVENAME | NOCACHE, - UIO_SYSSPACE, buf, fd, cap_rights_init(&rights, CAP_BINDAT), td); + UIO_SYSSPACE, buf, fd, cap_rights_init_one(&rights, CAP_BINDAT), + td); /* SHOULD BE ABLE TO ADOPT EXISTING AND wakeup() ALA FIFO's */ error = namei(&nd); if (error) @@ -1559,7 +1560,8 @@ unp_connectat(int fd, struct socket *so, struct sockaddr *nam, else sa = NULL; NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF, - UIO_SYSSPACE, buf, fd, cap_rights_init(&rights, CAP_CONNECTAT), td); + UIO_SYSSPACE, buf, fd, cap_rights_init_one(&rights, CAP_CONNECTAT), + td); error = namei(&nd); if (error) vp = NULL; diff --git a/sys/netinet/sctp_syscalls.c b/sys/netinet/sctp_syscalls.c index 0dad76b0f8bc..2697d139300c 100644 --- a/sys/netinet/sctp_syscalls.c +++ b/sys/netinet/sctp_syscalls.c @@ -153,7 +153,7 @@ sys_sctp_peeloff(td, uap) int error, fd; AUDIT_ARG_FD(uap->sd); - error = getsock_cap(td, uap->sd, cap_rights_init(&rights, CAP_PEELOFF), + error = getsock_cap(td, uap->sd, cap_rights_init_one(&rights, CAP_PEELOFF), &headfp, &fflag, NULL); if (error != 0) goto done2; @@ -472,7 +472,7 @@ sys_sctp_generic_recvmsg(td, uap) int error, fromlen, i, msg_flags; AUDIT_ARG_FD(uap->sd); - error = getsock_cap(td, uap->sd, cap_rights_init(&rights, CAP_RECV), + error = getsock_cap(td, uap->sd, cap_rights_init_one(&rights, CAP_RECV), &fp, NULL, NULL); if (error != 0) return (error); diff --git a/sys/security/mac/mac_syscalls.c b/sys/security/mac/mac_syscalls.c index c28a5e99c656..e7d71b2e22da 100644 --- a/sys/security/mac/mac_syscalls.c +++ b/sys/security/mac/mac_syscalls.c @@ -253,7 +253,8 @@ sys___mac_get_fd(struct thread *td, struct __mac_get_fd_args *uap) } buffer = malloc(mac.m_buflen, M_MACTEMP, M_WAITOK | M_ZERO); - error = fget(td, uap->fd, cap_rights_init(&rights, CAP_MAC_GET), &fp); + error = fget(td, uap->fd, cap_rights_init_one(&rights, CAP_MAC_GET), + &fp); if (error) goto out; @@ -411,7 +412,8 @@ sys___mac_set_fd(struct thread *td, struct __mac_set_fd_args *uap) return (error); } - error = fget(td, uap->fd, cap_rights_init(&rights, CAP_MAC_SET), &fp); + error = fget(td, uap->fd, cap_rights_init_one(&rights, CAP_MAC_SET), + &fp); if (error) goto out; diff --git a/sys/security/mac_veriexec/mac_veriexec.c b/sys/security/mac_veriexec/mac_veriexec.c index 8d43d59c9a3c..ecaa8cc35e09 100644 --- a/sys/security/mac_veriexec/mac_veriexec.c +++ b/sys/security/mac_veriexec/mac_veriexec.c @@ -656,8 +656,8 @@ mac_veriexec_syscall(struct thread *td, int call, void *arg) switch (call) { case MAC_VERIEXEC_CHECK_FD_SYSCALL: /* Get the vnode associated with the file descriptor passed */ - error = getvnode(td, (uintptr_t) arg, cap_rights_init(&rights, - CAP_READ), &fp); + error = getvnode(td, (uintptr_t) arg, + cap_rights_init_one(&rights, CAP_READ), &fp); if (error) return (error); if (fp->f_type != DTYPE_VNODE) { diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index be93dd16cd0a..3b652ea14303 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -3218,7 +3218,7 @@ sysctl_ffs_fsck(SYSCTL_HANDLER_ARGS) if (cmd.version != FFS_CMD_VERSION) return (ERPCMISMATCH); if ((error = getvnode(td, cmd.handle, - cap_rights_init(&rights, CAP_FSCK), &fp)) != 0) + cap_rights_init_one(&rights, CAP_FSCK), &fp)) != 0) return (error); vp = fp->f_vnode; if (vp->v_type != VREG && vp->v_type != VDIR) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202101121344.10CDi9Ti053685>