svn commit: r281437 - in head/sys: kern netinet sys
Mateusz Guzik
mjg at FreeBSD.org
Sat Apr 11 16:00:34 UTC 2015
Author: mjg
Date: Sat Apr 11 16:00:33 2015
New Revision: 281437
URL: https://svnweb.freebsd.org/changeset/base/281437
Log:
Replace struct filedesc argument in getsock_cap with struct thread
This is is a step towards removal of spurious arguments.
Modified:
head/sys/kern/uipc_syscalls.c
head/sys/netinet/sctp_syscalls.c
head/sys/sys/socketvar.h
Modified: head/sys/kern/uipc_syscalls.c
==============================================================================
--- head/sys/kern/uipc_syscalls.c Sat Apr 11 15:40:28 2015 (r281436)
+++ head/sys/kern/uipc_syscalls.c Sat Apr 11 16:00:33 2015 (r281437)
@@ -150,17 +150,17 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, sfstat,
* 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
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, s
*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 di
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, s
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,
}
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,
}
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
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
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,
/*
* 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;
Modified: head/sys/netinet/sctp_syscalls.c
==============================================================================
--- head/sys/netinet/sctp_syscalls.c Sat Apr 11 15:40:28 2015 (r281436)
+++ head/sys/netinet/sctp_syscalls.c Sat Apr 11 16:00:33 2015 (r281437)
@@ -248,7 +248,7 @@ sys_sctp_generic_sendmsg (td, uap)
}
AUDIT_ARG_FD(uap->sd);
- error = getsock_cap(td->td_proc->p_fd, uap->sd, &rights, &fp, NULL);
+ error = getsock_cap(td, uap->sd, &rights, &fp, NULL);
if (error != 0)
goto sctp_bad;
#ifdef KTRACE
@@ -357,7 +357,7 @@ sys_sctp_generic_sendmsg_iov(td, uap)
}
AUDIT_ARG_FD(uap->sd);
- error = getsock_cap(td->td_proc->p_fd, uap->sd, &rights, &fp, NULL);
+ error = getsock_cap(td, uap->sd, &rights, &fp, NULL);
if (error != 0)
goto sctp_bad1;
@@ -468,8 +468,8 @@ sys_sctp_generic_recvmsg(td, uap)
int error, fromlen, i, msg_flags;
AUDIT_ARG_FD(uap->sd);
- error = getsock_cap(td->td_proc->p_fd, uap->sd,
- cap_rights_init(&rights, CAP_RECV), &fp, NULL);
+ error = getsock_cap(td, uap->sd, cap_rights_init(&rights, CAP_RECV),
+ &fp, NULL);
if (error != 0)
return (error);
#ifdef COMPAT_FREEBSD32
Modified: head/sys/sys/socketvar.h
==============================================================================
--- head/sys/sys/socketvar.h Sat Apr 11 15:40:28 2015 (r281436)
+++ head/sys/sys/socketvar.h Sat Apr 11 16:00:33 2015 (r281437)
@@ -339,7 +339,7 @@ struct uio;
*/
int sockargs(struct mbuf **mp, caddr_t buf, int buflen, int type);
int getsockaddr(struct sockaddr **namp, caddr_t uaddr, size_t len);
-int getsock_cap(struct filedesc *fdp, int fd, cap_rights_t *rightsp,
+int getsock_cap(struct thread *td, int fd, cap_rights_t *rightsp,
struct file **fpp, u_int *fflagp);
void soabort(struct socket *so);
int soaccept(struct socket *so, struct sockaddr **nam);
More information about the svn-src-all
mailing list