diff options
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/in_pcb.c | 49 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 8 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 2 | ||||
-rw-r--r-- | sys/netinet/tcp_syncache.c | 6 | ||||
-rw-r--r-- | sys/netinet/tcp_usrreq.c | 17 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 8 |
6 files changed, 46 insertions, 44 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index c6e2ace..f0a3bca 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -210,10 +210,10 @@ out: } int -in_pcbbind(inp, nam, td) +in_pcbbind(inp, nam, cred) register struct inpcb *inp; struct sockaddr *nam; - struct thread *td; + struct ucred *cred; { int anonport, error; @@ -225,7 +225,7 @@ in_pcbbind(inp, nam, td) anonport = inp->inp_lport == 0 && (nam == NULL || ((struct sockaddr_in *)nam)->sin_port == 0); error = in_pcbbind_setup(inp, nam, &inp->inp_laddr.s_addr, - &inp->inp_lport, td); + &inp->inp_lport, cred); if (error) return (error); if (in_pcbinshash(inp) != 0) { @@ -248,12 +248,12 @@ in_pcbbind(inp, nam, td) * On error, the values of *laddrp and *lportp are not changed. */ int -in_pcbbind_setup(inp, nam, laddrp, lportp, td) +in_pcbbind_setup(inp, nam, laddrp, lportp, cred) struct inpcb *inp; struct sockaddr *nam; in_addr_t *laddrp; u_short *lportp; - struct thread *td; + struct ucred *cred; { struct socket *so = inp->inp_socket; unsigned short *lastport; @@ -287,7 +287,7 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, td) return (EAFNOSUPPORT); #endif if (sin->sin_addr.s_addr != INADDR_ANY) - if (prison_ip(td->td_ucred, 0, &sin->sin_addr.s_addr)) + if (prison_ip(cred, 0, &sin->sin_addr.s_addr)) return(EINVAL); if (sin->sin_port != *lportp) { /* Don't allow the port to change. */ @@ -318,9 +318,9 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, td) /* GROSS */ if (ntohs(lport) <= ipport_reservedhigh && ntohs(lport) >= ipport_reservedlow && - td && suser_cred(td->td_ucred, PRISON_ROOT)) + suser_cred(cred, PRISON_ROOT)) return (EACCES); - if (td && jailed(td->td_ucred)) + if (jailed(cred)) prison = 1; if (so->so_cred->cr_uid != 0 && !IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) { @@ -356,8 +356,7 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, td) return (EADDRINUSE); } } - if (prison && - prison_ip(td->td_ucred, 0, &sin->sin_addr.s_addr)) + if (prison && prison_ip(cred, 0, &sin->sin_addr.s_addr)) return (EADDRNOTAVAIL); t = in_pcblookup_local(pcbinfo, sin->sin_addr, lport, prison ? 0 : wild); @@ -386,7 +385,7 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, td) int count; if (laddr.s_addr != INADDR_ANY) - if (prison_ip(td->td_ucred, 0, &laddr.s_addr)) + if (prison_ip(cred, 0, &laddr.s_addr)) return (EINVAL); if (inp->inp_flags & INP_HIGHPORT) { @@ -394,8 +393,7 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, td) last = ipport_hilastauto; lastport = &pcbinfo->lasthi; } else if (inp->inp_flags & INP_LOWPORT) { - if (td && (error = suser_cred(td->td_ucred, - PRISON_ROOT)) != 0) + if ((error = suser_cred(cred, PRISON_ROOT)) != 0) return error; first = ipport_lowfirstauto; /* 1023 */ last = ipport_lowlastauto; /* 600 */ @@ -444,7 +442,7 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, td) wild)); } } - if (prison_ip(td->td_ucred, 0, &laddr.s_addr)) + if (prison_ip(cred, 0, &laddr.s_addr)) return (EINVAL); *laddrp = laddr.s_addr; *lportp = lport; @@ -458,10 +456,10 @@ in_pcbbind_setup(inp, nam, laddrp, lportp, td) * then pick one. */ int -in_pcbconnect(inp, nam, td) +in_pcbconnect(inp, nam, cred) register struct inpcb *inp; struct sockaddr *nam; - struct thread *td; + struct ucred *cred; { u_short lport, fport; in_addr_t laddr, faddr; @@ -471,7 +469,7 @@ in_pcbconnect(inp, nam, td) laddr = inp->inp_laddr.s_addr; anonport = (lport == 0); error = in_pcbconnect_setup(inp, nam, &laddr, &lport, &faddr, &fport, - NULL, td); + NULL, cred); if (error) return (error); @@ -517,7 +515,7 @@ in_pcbconnect(inp, nam, td) * is set to NULL. */ int -in_pcbconnect_setup(inp, nam, laddrp, lportp, faddrp, fportp, oinpp, td) +in_pcbconnect_setup(inp, nam, laddrp, lportp, faddrp, fportp, oinpp, cred) register struct inpcb *inp; struct sockaddr *nam; in_addr_t *laddrp; @@ -525,12 +523,12 @@ in_pcbconnect_setup(inp, nam, laddrp, lportp, faddrp, fportp, oinpp, td) in_addr_t *faddrp; u_short *fportp; struct inpcb **oinpp; - struct thread *td; + struct ucred *cred; { struct sockaddr_in *sin = (struct sockaddr_in *)nam; struct in_ifaddr *ia; struct sockaddr_in sa; - struct ucred *cred; + struct ucred *socred; struct inpcb *oinp; struct in_addr laddr, faddr; u_short lport, fport; @@ -548,14 +546,14 @@ in_pcbconnect_setup(inp, nam, laddrp, lportp, faddrp, fportp, oinpp, td) lport = *lportp; faddr = sin->sin_addr; fport = sin->sin_port; - cred = inp->inp_socket->so_cred; - if (laddr.s_addr == INADDR_ANY && jailed(cred)) { + socred = inp->inp_socket->so_cred; + if (laddr.s_addr == INADDR_ANY && jailed(socred)) { bzero(&sa, sizeof(sa)); - sa.sin_addr.s_addr = htonl(prison_getip(cred)); + sa.sin_addr.s_addr = htonl(prison_getip(socred)); sa.sin_len = sizeof(sa); sa.sin_family = AF_INET; error = in_pcbbind_setup(inp, (struct sockaddr *)&sa, - &laddr.s_addr, &lport, td); + &laddr.s_addr, &lport, cred); if (error) return (error); } @@ -646,7 +644,8 @@ in_pcbconnect_setup(inp, nam, laddrp, lportp, faddrp, fportp, oinpp, td) return (EADDRINUSE); } if (lport == 0) { - error = in_pcbbind_setup(inp, NULL, &laddr.s_addr, &lport, td); + error = in_pcbbind_setup(inp, NULL, &laddr.s_addr, &lport, + cred); if (error) return (error); } diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index d2f4852..828689f 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -338,13 +338,13 @@ extern int ipport_hilastauto; void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *); int in_pcballoc(struct socket *, struct inpcbinfo *, const char *); -int in_pcbbind(struct inpcb *, struct sockaddr *, struct thread *); +int in_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *); int in_pcbbind_setup(struct inpcb *, struct sockaddr *, in_addr_t *, - u_short *, struct thread *); -int in_pcbconnect(struct inpcb *, struct sockaddr *, struct thread *); + u_short *, struct ucred *); +int in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *); int in_pcbconnect_setup(struct inpcb *, struct sockaddr *, in_addr_t *, u_short *, in_addr_t *, u_short *, struct inpcb **, - struct thread *); + struct ucred *); void in_pcbdetach(struct inpcb *); void in_pcbdisconnect(struct inpcb *); int in_pcbinshash(struct inpcb *); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 46c5810..0baddc7 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -505,7 +505,7 @@ div_bind(struct socket *so, struct sockaddr *nam, struct thread *td) else { ((struct sockaddr_in *)nam)->sin_addr.s_addr = INADDR_ANY; INP_LOCK(inp); - error = in_pcbbind(inp, nam, td); + error = in_pcbbind(inp, nam, td->td_ucred); INP_UNLOCK(inp); } INP_INFO_WUNLOCK(&divcbinfo); diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 9e5f8f2..51575a3 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -632,7 +632,8 @@ syncache_socket(sc, lso, m) laddr6 = inp->in6p_laddr; if (IN6_IS_ADDR_UNSPECIFIED(&inp->in6p_laddr)) inp->in6p_laddr = sc->sc_inc.inc6_laddr; - if (in6_pcbconnect(inp, (struct sockaddr *)&sin6, &thread0)) { + if (in6_pcbconnect(inp, (struct sockaddr *)&sin6, + thread0.td_ucred)) { inp->in6p_laddr = laddr6; goto abort; } @@ -656,7 +657,8 @@ syncache_socket(sc, lso, m) laddr = inp->inp_laddr; if (inp->inp_laddr.s_addr == INADDR_ANY) inp->inp_laddr = sc->sc_inc.inc_laddr; - if (in_pcbconnect(inp, (struct sockaddr *)&sin, &thread0)) { + if (in_pcbconnect(inp, (struct sockaddr *)&sin, + thread0.td_ucred)) { inp->inp_laddr = laddr; goto abort; } diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index c896256..88eb781 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -252,7 +252,7 @@ tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) error = EAFNOSUPPORT; goto out; } - error = in_pcbbind(inp, nam, td); + error = in_pcbbind(inp, nam, td->td_ucred); if (error) goto out; COMMON_END(PRU_BIND); @@ -294,11 +294,12 @@ tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) in6_sin6_2_sin(&sin, sin6p); inp->inp_vflag |= INP_IPV4; inp->inp_vflag &= ~INP_IPV6; - error = in_pcbbind(inp, (struct sockaddr *)&sin, td); + error = in_pcbbind(inp, (struct sockaddr *)&sin, + td->td_ucred); goto out; } } - error = in6_pcbbind(inp, nam, td); + error = in6_pcbbind(inp, nam, td->td_ucred); if (error) goto out; COMMON_END(PRU_BIND); @@ -319,7 +320,7 @@ tcp_usr_listen(struct socket *so, struct thread *td) COMMON_START(); if (inp->inp_lport == 0) - error = in_pcbbind(inp, (struct sockaddr *)0, td); + error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); if (error == 0) tp->t_state = TCPS_LISTEN; COMMON_END(PRU_LISTEN); @@ -340,7 +341,7 @@ tcp6_usr_listen(struct socket *so, struct thread *td) inp->inp_vflag &= ~INP_IPV4; if ((inp->inp_flags & IN6P_IPV6_V6ONLY) == 0) inp->inp_vflag |= INP_IPV4; - error = in6_pcbbind(inp, (struct sockaddr *)0, td); + error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); } if (error == 0) tp->t_state = TCPS_LISTEN; @@ -865,7 +866,7 @@ tcp_connect(tp, nam, td) bzero(&tao, sizeof(tao)); if (inp->inp_lport == 0) { - error = in_pcbbind(inp, (struct sockaddr *)0, td); + error = in_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); if (error) return error; } @@ -878,7 +879,7 @@ tcp_connect(tp, nam, td) laddr = inp->inp_laddr; lport = inp->inp_lport; error = in_pcbconnect_setup(inp, nam, &laddr.s_addr, &lport, - &inp->inp_faddr.s_addr, &inp->inp_fport, &oinp, td); + &inp->inp_faddr.s_addr, &inp->inp_fport, &oinp, td->td_ucred); if (error && oinp == NULL) return error; if (oinp) { @@ -949,7 +950,7 @@ tcp6_connect(tp, nam, td) bzero(&tao, sizeof(tao)); if (inp->inp_lport == 0) { - error = in6_pcbbind(inp, (struct sockaddr *)0, td); + error = in6_pcbbind(inp, (struct sockaddr *)0, td->td_ucred); if (error) return error; } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 56f195e..0629666 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -795,7 +795,7 @@ udp_output(inp, m, addr, control, td) goto release; } error = in_pcbbind_setup(inp, (struct sockaddr *)&src, - &laddr.s_addr, &lport, td); + &laddr.s_addr, &lport, td->td_ucred); if (error) goto release; } @@ -809,7 +809,7 @@ udp_output(inp, m, addr, control, td) goto release; } error = in_pcbconnect_setup(inp, addr, &laddr.s_addr, &lport, - &faddr.s_addr, &fport, NULL, td); + &faddr.s_addr, &fport, NULL, td->td_ucred); if (error) goto release; @@ -970,7 +970,7 @@ udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) } INP_LOCK(inp); s = splnet(); - error = in_pcbbind(inp, nam, td); + error = in_pcbbind(inp, nam, td->td_ucred); splx(s); INP_UNLOCK(inp); INP_INFO_WUNLOCK(&udbinfo); @@ -1000,7 +1000,7 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) sin = (struct sockaddr_in *)nam; if (td && jailed(td->td_ucred)) prison_remote_ip(td->td_ucred, 0, &sin->sin_addr.s_addr); - error = in_pcbconnect(inp, nam, td); + error = in_pcbconnect(inp, nam, td->td_ucred); splx(s); if (error == 0) soisconnected(so); |