aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/uipc_syscalls.c
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2015-04-11 16:00:33 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2015-04-11 16:00:33 +0000
commit2574218578003321766b2bc85b3dc877308c0fe4 (patch)
tree0822ba61532bccc72584d41489003180d35e9335 /sys/kern/uipc_syscalls.c
parent90f54cbfeb973c0e2ee7b617b7759ac4335a9efe (diff)
downloadsrc-2574218578003321766b2bc85b3dc877308c0fe4.tar.gz
src-2574218578003321766b2bc85b3dc877308c0fe4.zip
Replace struct filedesc argument in getsock_cap with struct thread
This is is a step towards removal of spurious arguments.
Notes
Notes: svn path=/head/; revision=281437
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r--sys/kern/uipc_syscalls.c52
1 files changed, 25 insertions, 27 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c
index 1a4c65824e29..1efe3da8a8d4 100644
--- a/sys/kern/uipc_syscalls.c
+++ b/sys/kern/uipc_syscalls.c
@@ -150,17 +150,17 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, sfstat, CTLTYPE_OPAQUE | CTLFLAG_RW,
* A reference on the file entry is held upon returning.
*/
int
-getsock_cap(struct filedesc *fdp, int fd, cap_rights_t *rightsp,
+getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
struct file **fpp, u_int *fflagp)
{
struct file *fp;
int error;
- error = fget_unlocked(fdp, fd, rightsp, &fp, NULL);
+ error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, &fp, NULL);
if (error != 0)
return (error);
if (fp->f_type != DTYPE_SOCKET) {
- fdrop(fp, curthread);
+ fdrop(fp, td);
return (ENOTSOCK);
}
if (fflagp != NULL)
@@ -258,8 +258,8 @@ kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
AUDIT_ARG_FD(fd);
AUDIT_ARG_SOCKADDR(td, dirfd, sa);
- error = getsock_cap(td->td_proc->p_fd, fd,
- cap_rights_init(&rights, CAP_BIND), &fp, NULL);
+ error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_BIND),
+ &fp, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -319,8 +319,8 @@ sys_listen(td, uap)
int error;
AUDIT_ARG_FD(uap->s);
- error = getsock_cap(td->td_proc->p_fd, uap->s,
- cap_rights_init(&rights, CAP_LISTEN), &fp, NULL);
+ error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_LISTEN),
+ &fp, NULL);
if (error == 0) {
so = fp->f_data;
#ifdef MAC
@@ -390,7 +390,6 @@ int
kern_accept4(struct thread *td, int s, struct sockaddr **name,
socklen_t *namelen, int flags, struct file **fp)
{
- struct filedesc *fdp;
struct file *headfp, *nfp = NULL;
struct sockaddr *sa = NULL;
struct socket *head, *so;
@@ -403,8 +402,7 @@ kern_accept4(struct thread *td, int s, struct sockaddr **name,
*name = NULL;
AUDIT_ARG_FD(s);
- fdp = td->td_proc->p_fd;
- error = getsock_cap(fdp, s, cap_rights_init(&rights, CAP_ACCEPT),
+ error = getsock_cap(td, s, cap_rights_init(&rights, CAP_ACCEPT),
&headfp, &fflag);
if (error != 0)
return (error);
@@ -604,8 +602,8 @@ kern_connectat(struct thread *td, int dirfd, int fd, struct sockaddr *sa)
AUDIT_ARG_FD(fd);
AUDIT_ARG_SOCKADDR(td, dirfd, sa);
- error = getsock_cap(td->td_proc->p_fd, fd,
- cap_rights_init(&rights, CAP_CONNECT), &fp, NULL);
+ error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_CONNECT),
+ &fp, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -865,7 +863,7 @@ kern_sendit(td, s, mp, flags, control, segflg)
AUDIT_ARG_SOCKADDR(td, AT_FDCWD, mp->msg_name);
cap_rights_set(&rights, CAP_CONNECT);
}
- error = getsock_cap(td->td_proc->p_fd, s, &rights, &fp, NULL);
+ error = getsock_cap(td, s, &rights, &fp, NULL);
if (error != 0)
return (error);
so = (struct socket *)fp->f_data;
@@ -1065,8 +1063,8 @@ kern_recvit(td, s, mp, fromseg, controlp)
*controlp = NULL;
AUDIT_ARG_FD(s);
- error = getsock_cap(td->td_proc->p_fd, s,
- cap_rights_init(&rights, CAP_RECV), &fp, NULL);
+ error = getsock_cap(td, s, cap_rights_init(&rights, CAP_RECV),
+ &fp, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -1380,8 +1378,8 @@ sys_shutdown(td, uap)
int error;
AUDIT_ARG_FD(uap->s);
- error = getsock_cap(td->td_proc->p_fd, uap->s,
- cap_rights_init(&rights, CAP_SHUTDOWN), &fp, NULL);
+ error = getsock_cap(td, uap->s, cap_rights_init(&rights, CAP_SHUTDOWN),
+ &fp, NULL);
if (error == 0) {
so = fp->f_data;
error = soshutdown(so, uap->how);
@@ -1445,8 +1443,8 @@ kern_setsockopt(td, s, level, name, val, valseg, valsize)
}
AUDIT_ARG_FD(s);
- error = getsock_cap(td->td_proc->p_fd, s,
- cap_rights_init(&rights, CAP_SETSOCKOPT), &fp, NULL);
+ error = getsock_cap(td, s, cap_rights_init(&rights, CAP_SETSOCKOPT),
+ &fp, NULL);
if (error == 0) {
so = fp->f_data;
error = sosetopt(so, &sopt);
@@ -1526,8 +1524,8 @@ kern_getsockopt(td, s, level, name, val, valseg, valsize)
}
AUDIT_ARG_FD(s);
- error = getsock_cap(td->td_proc->p_fd, s,
- cap_rights_init(&rights, CAP_GETSOCKOPT), &fp, NULL);
+ error = getsock_cap(td, s, cap_rights_init(&rights, CAP_GETSOCKOPT),
+ &fp, NULL);
if (error == 0) {
so = fp->f_data;
error = sogetopt(so, &sopt);
@@ -1587,8 +1585,8 @@ kern_getsockname(struct thread *td, int fd, struct sockaddr **sa,
int error;
AUDIT_ARG_FD(fd);
- error = getsock_cap(td->td_proc->p_fd, fd,
- cap_rights_init(&rights, CAP_GETSOCKNAME), &fp, NULL);
+ error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_GETSOCKNAME),
+ &fp, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -1686,8 +1684,8 @@ kern_getpeername(struct thread *td, int fd, struct sockaddr **sa,
int error;
AUDIT_ARG_FD(fd);
- error = getsock_cap(td->td_proc->p_fd, fd,
- cap_rights_init(&rights, CAP_GETPEERNAME), &fp, NULL);
+ error = getsock_cap(td, fd, cap_rights_init(&rights, CAP_GETPEERNAME),
+ &fp, NULL);
if (error != 0)
return (error);
so = fp->f_data;
@@ -2153,8 +2151,8 @@ kern_sendfile_getsock(struct thread *td, int s, struct file **sock_fp,
/*
* The socket must be a stream socket and connected.
*/
- error = getsock_cap(td->td_proc->p_fd, s, cap_rights_init(&rights,
- CAP_SEND), sock_fp, NULL);
+ error = getsock_cap(td, s, cap_rights_init(&rights, CAP_SEND),
+ sock_fp, NULL);
if (error != 0)
return (error);
*so = (*sock_fp)->f_data;