From owner-svn-src-stable@freebsd.org Sat Jul 15 17:28:04 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A3CBEAFE953; Sat, 15 Jul 2017 17:28:04 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 78CF37C8AE; Sat, 15 Jul 2017 17:28:04 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6FHS37r065454; Sat, 15 Jul 2017 17:28:03 GMT (envelope-from dchagin@FreeBSD.org) Received: (from dchagin@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6FHS3nc065451; Sat, 15 Jul 2017 17:28:03 GMT (envelope-from dchagin@FreeBSD.org) Message-Id: <201707151728.v6FHS3nc065451@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dchagin set sender to dchagin@FreeBSD.org using -f From: Dmitry Chagin Date: Sat, 15 Jul 2017 17:28:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r321021 - in stable/10/sys: kern netinet sys X-SVN-Group: stable-10 X-SVN-Commit-Author: dchagin X-SVN-Commit-Paths: in stable/10/sys: kern netinet sys X-SVN-Commit-Revision: 321021 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jul 2017 17:28:04 -0000 Author: dchagin Date: Sat Jul 15 17:28:03 2017 New Revision: 321021 URL: https://svnweb.freebsd.org/changeset/base/321021 Log: MFC r281437 (by mjg@): Replace struct filedesc argument in getsock_cap with struct thread This is is a step towards removal of spurious arguments. Modified: stable/10/sys/kern/uipc_syscalls.c stable/10/sys/netinet/sctp_syscalls.c stable/10/sys/sys/socketvar.h Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/uipc_syscalls.c ============================================================================== --- stable/10/sys/kern/uipc_syscalls.c Sat Jul 15 17:25:40 2017 (r321020) +++ stable/10/sys/kern/uipc_syscalls.c Sat Jul 15 17:28:03 2017 (r321021) @@ -150,17 +150,17 @@ SYSCTL_PROC(_kern_ipc, OID_AUTO, sfstat, CTLTYPE_OPAQU * 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, 0, &fp, NULL); + error = fget_unlocked(td->td_proc->p_fd, fd, rightsp, 0, &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, stru 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; @@ -326,8 +326,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 @@ -403,7 +403,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; @@ -416,8 +415,7 @@ kern_accept4(struct thread *td, int s, struct sockaddr *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); @@ -624,8 +622,8 @@ kern_connectat(struct thread *td, int dirfd, int fd, s 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; @@ -892,7 +890,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; @@ -1092,8 +1090,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; @@ -1407,8 +1405,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); @@ -1472,8 +1470,8 @@ kern_setsockopt(td, s, level, name, val, valseg, valsi } 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); @@ -1553,8 +1551,8 @@ kern_getsockopt(td, s, level, name, val, valseg, valsi } 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); @@ -1614,8 +1612,8 @@ kern_getsockname(struct thread *td, int fd, struct soc 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; @@ -1713,8 +1711,8 @@ kern_getpeername(struct thread *td, int fd, struct soc 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; @@ -2154,8 +2152,8 @@ kern_sendfile_getsock(struct thread *td, int s, struct /* * 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: stable/10/sys/netinet/sctp_syscalls.c ============================================================================== --- stable/10/sys/netinet/sctp_syscalls.c Sat Jul 15 17:25:40 2017 (r321020) +++ stable/10/sys/netinet/sctp_syscalls.c Sat Jul 15 17:28:03 2017 (r321021) @@ -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 @@ -361,7 +361,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; @@ -476,8 +476,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: stable/10/sys/sys/socketvar.h ============================================================================== --- stable/10/sys/sys/socketvar.h Sat Jul 15 17:25:40 2017 (r321020) +++ stable/10/sys/sys/socketvar.h Sat Jul 15 17:28:03 2017 (r321021) @@ -317,7 +317,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);