1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-20 11:11:24 +00:00

Replace struct filedesc argument in getsock_cap with struct thread

This is is a step towards removal of spurious arguments.
This commit is contained in:
Mateusz Guzik 2015-04-11 16:00:33 +00:00
parent 90f54cbfeb
commit 2574218578
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=281437
3 changed files with 30 additions and 32 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);