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)
This commit is contained in:
parent
c00ec4dab2
commit
6b3a9a0f3d
@ -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);
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user