mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-18 10:35:55 +00:00
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.
This commit is contained in:
parent
e06ea46468
commit
99f293a20e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=233004
@ -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) {
|
||||
|
@ -59,16 +59,16 @@ sctp_can_peel_off(struct socket *head, sctp_assoc_t assoc_id)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user