diff options
author | tuexen <tuexen@FreeBSD.org> | 2012-03-15 14:13:38 +0000 |
---|---|---|
committer | tuexen <tuexen@FreeBSD.org> | 2012-03-15 14:13:38 +0000 |
commit | b8b34b6ecf69ed8b2b0ca1cc1f8954eb205bced3 (patch) | |
tree | b2eab1fd923075a5f769b7a59ec7232beb0607b6 /sys/kern/uipc_syscalls.c | |
parent | 070929ac809549154d10221a19a80f8f0caab078 (diff) | |
download | FreeBSD-src-b8b34b6ecf69ed8b2b0ca1cc1f8954eb205bced3.zip FreeBSD-src-b8b34b6ecf69ed8b2b0ca1cc1f8954eb205bced3.tar.gz |
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.
MFC after: 3 days.
Diffstat (limited to 'sys/kern/uipc_syscalls.c')
-rw-r--r-- | sys/kern/uipc_syscalls.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 3b44848..4502e43 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -2321,6 +2321,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; @@ -2443,6 +2447,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) @@ -2557,6 +2565,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) @@ -2662,6 +2674,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) { |