svn commit: r233242 - in stable/9/sys: kern netinet
Michael Tuexen
tuexen at FreeBSD.org
Tue Mar 20 19:24:57 UTC 2012
Author: tuexen
Date: Tue Mar 20 19:24:56 2012
New Revision: 233242
URL: http://svn.freebsd.org/changeset/base/233242
Log:
MFC r233004:
Fix bugs which can result in a panic when an non-SCTP socket it
used with an sctp_ system-call which expects an SCTP socket.
Modified:
stable/9/sys/kern/uipc_syscalls.c
stable/9/sys/netinet/sctp_peeloff.c
Directory Properties:
stable/9/sys/ (props changed)
Modified: stable/9/sys/kern/uipc_syscalls.c
==============================================================================
--- stable/9/sys/kern/uipc_syscalls.c Tue Mar 20 19:22:44 2012 (r233241)
+++ stable/9/sys/kern/uipc_syscalls.c Tue Mar 20 19:24:56 2012 (r233242)
@@ -2320,6 +2320,10 @@ sys_sctp_peeloff(td, uap)
error = fgetsock(td, uap->sd, CAP_PEELOFF, &head, &fflag);
if (error)
goto done2;
+ if (head->so_proto->pr_protocol != IPPROTO_SCTP) {
+ error = EOPNOTSUPP;
+ goto done2;
+ }
error = sctp_can_peel_off(head, (sctp_assoc_t)uap->name);
if (error)
goto done2;
@@ -2442,6 +2446,10 @@ sys_sctp_generic_sendmsg (td, uap)
iov[0].iov_len = uap->mlen;
so = (struct socket *)fp->f_data;
+ if (so->so_proto->pr_protocol != IPPROTO_SCTP) {
+ error = EOPNOTSUPP;
+ goto sctp_bad;
+ }
#ifdef MAC
error = mac_socket_check_send(td->td_ucred, so);
if (error)
@@ -2555,6 +2563,10 @@ sys_sctp_generic_sendmsg_iov(td, uap)
#endif
so = (struct socket *)fp->f_data;
+ if (so->so_proto->pr_protocol != IPPROTO_SCTP) {
+ error = EOPNOTSUPP;
+ goto sctp_bad;
+ }
#ifdef MAC
error = mac_socket_check_send(td->td_ucred, so);
if (error)
@@ -2659,6 +2671,10 @@ sys_sctp_generic_recvmsg(td, uap)
goto out1;
so = fp->f_data;
+ if (so->so_proto->pr_protocol != IPPROTO_SCTP) {
+ error = EOPNOTSUPP;
+ goto out;
+ }
#ifdef MAC
error = mac_socket_check_receive(td->td_ucred, so);
if (error) {
Modified: stable/9/sys/netinet/sctp_peeloff.c
==============================================================================
--- stable/9/sys/netinet/sctp_peeloff.c Tue Mar 20 19:22:44 2012 (r233241)
+++ stable/9/sys/netinet/sctp_peeloff.c Tue Mar 20 19:24:56 2012 (r233242)
@@ -59,16 +59,16 @@ sctp_can_peel_off(struct socket *head, s
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EBADF);
return (EBADF);
}
- if ((head->so_proto->pr_protocol != IPPROTO_SCTP) ||
- (head->so_type != SOCK_SEQPACKET)) {
- SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EOPNOTSUPP);
- return (EOPNOTSUPP);
- }
inp = (struct sctp_inpcb *)head->so_pcb;
if (inp == NULL) {
SCTP_LTRACE_ERR_RET(NULL, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EFAULT);
return (EFAULT);
}
+ if ((inp->sctp_flags & SCTP_PCB_FLAGS_TCPTYPE) ||
+ (inp->sctp_flags & SCTP_PCB_FLAGS_IN_TCPPOOL)) {
+ SCTP_LTRACE_ERR_RET(inp, NULL, NULL, SCTP_FROM_SCTP_PEELOFF, EOPNOTSUPP);
+ return (EOPNOTSUPP);
+ }
stcb = sctp_findassociation_ep_asocid(inp, assoc_id, 1);
if (stcb == NULL) {
SCTP_LTRACE_ERR_RET(inp, stcb, NULL, SCTP_FROM_SCTP_PEELOFF, ENOENT);
More information about the svn-src-stable-9
mailing list