sctp: fix so_proto when peeling off a socket

Reported by:		glebius
Reviewed by:		rrs
Fixes:			d195b3783fa4 ("sctp: fix socket type created by sctp_peeloff()")
Differential Revision:	https://reviews.freebsd.org/D55454
Event:			Wiesbaden Hackathon 2026

(cherry picked from commit 454212b9718b55b43781f81bef252658e20e0fd3)
This commit is contained in:
Michael Tuexen 2026-02-25 13:55:54 +01:00 committed by Franco Fichtner
parent 6b41d9082e
commit 0064d9a193
3 changed files with 6 additions and 4 deletions

View file

@ -1286,7 +1286,7 @@ solisten_enqueue(struct socket *so, int connstatus)
* XXXGL: reduce copy-paste with solisten_clone().
*/
struct socket *
sopeeloff(struct socket *head)
sopeeloff(struct socket *head, struct protosw *so_proto)
{
struct socket *so;
@ -1304,7 +1304,7 @@ sopeeloff(struct socket *head)
so->so_linger = head->so_linger;
so->so_state = (head->so_state & SS_NBIO) | SS_ISCONNECTED;
so->so_fibnum = head->so_fibnum;
so->so_proto = head->so_proto;
so->so_proto = so_proto;
so->so_cred = crhold(head->so_cred);
#ifdef MAC
mac_socket_newconn(head, so);

View file

@ -76,6 +76,8 @@
#include <security/mac/mac_framework.h>
#include <netinet/sctp.h>
#include <netinet/sctp_pcb.h>
#include <netinet/sctp_var.h>
#include <netinet/sctp_os_bsd.h>
#include <netinet/sctp_peeloff.h>
@ -172,7 +174,7 @@ sys_sctp_peeloff(struct thread *td, struct sctp_peeloff_args *uap)
td->td_retval[0] = fd;
CURVNET_SET(head->so_vnet);
so = sopeeloff(head);
so = sopeeloff(head, &sctp_stream_protosw);
if (so == NULL) {
error = ENOMEM;
goto noconnection;

View file

@ -525,7 +525,7 @@ struct socket *
struct socket *
sonewconn(struct socket *head, int connstatus);
struct socket *
sopeeloff(struct socket *);
sopeeloff(struct socket *, struct protosw *);
int sopoll(struct socket *so, int events, struct ucred *active_cred,
struct thread *td);
int sopoll_generic(struct socket *so, int events,