Thread View: muc.lists.freebsd.bugs
3 messages
3 total messages
Started by bugzilla-noreply
Mon, 26 Oct 2026 13:18
[Bug 300091] [sctp] SO_SETFIB setsockopt() silently fails on SCTP sockets
Author: bugzilla-noreply
Date: Mon, 26 Oct 2026 13:18
Date: Mon, 26 Oct 2026 13:18
121 lines
5770 bytes
5770 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300091
Bug ID: 300091
Summary: [sctp] SO_SETFIB setsockopt() silently fails on SCTP
sockets
Product: Base System
Version: CURRENT
Hardware: Any
OS: Any
Status: New
Severity: Affects Some People
Priority: ---
Component: kern
Assignee: bugs@FreeBSD.org
Reporter: albin.hellqvist@ericsson.com
Description:
Commit caccbaef8e26 ("socket: Move SO_SETFIB handling to protocol layers", Feb
6, 2025) moved SO_SETFIB handling from the generic socket layer in sosetopt()
into each protocol's pr_ctloutput(). The TCP/IPv4, IPv6, raw IP, raw IPv6, and
route socket handlers were all updated to call sooptcopyin() and sosetfib().
However, the SCTP handler in sctp_ctloutput() (sys/netinet/sctp_usrreq.c) was
not updated.
The SCTP handler (originally added in commit d089f9b9155f) still does:
inp->fibnum = so->so_fibnum;
This worked before because the generic socket layer set so->so_fibnum first.
After caccbaef8e26, the generic layer no longer does this, it delegates
entirely to pr_ctloutput. So so->so_fibnum is never updated and the
user-provided FIB value is never read from the sockopt buffer.
The result is that setsockopt(fd, SOL_SOCKET, SO_SETFIB, &fibnum,
sizeof(fibnum)) on an SCTP socket returns 0 (success) but does nothing, the FIB
stays at its previous value.
For comparison, the correct implementation in ip_ctloutput()
(sys/netinet/ip_output.c):
case SO_SETFIB:
error = sooptcopyin(sopt, &optval, sizeof(optval), sizeof(optval));
if (error != 0)
break;
INP_WLOCK(inp);
error = sosetfib(inp->inp_socket, optval);
if (error == 0)
inp->inp_inc.inc_fibnum = optval;
INP_WUNLOCK(inp);
break;
Affected versions:
- main (15-CURRENT) since commit caccbaef8e26 (Feb 6, 2025)
- stable/14 since MFC a55bde2328e5, affects 14.3, 14.4, 14.5
- releng/15.0, releng/15.1
Not affected:
- FreeBSD 13.x (generic socket layer still handles SO_SETFIB)
- FreeBSD 14.0, 14.1, 14.2
How to reproduce:
int fd = socket(AF_INET6, SOCK_STREAM, IPPROTO_SCTP);
int fib = 1;
// Returns 0 (success) but FIB stays at 0:
setsockopt(fd, SOL_SOCKET, SO_SETFIB, &fib, sizeof(fib));
Verified by checking that SCTP source address selection
(sctp_source_address_selection) returns EHOSTUNREACH when the socket's FIB
doesn't match the routing table where addresses are configured.
Proposed fix:
The SCTP handler needs to call sooptcopyin() to read the value from userspace
and sosetfib() to update so->so_fibnum, matching the pattern used by
ip_ctloutput() and ip6_ctloutput():
--- a/sys/netinet/sctp_usrreq.c
+++ b/sys/netinet/sctp_usrreq.c
@@ -6877,11 +6877,21 @@
if ((sopt->sopt_level == SOL_SOCKET) &&
(sopt->sopt_name == SO_SETFIB)) {
+ int optval;
+
+ error = sooptcopyin(sopt, &optval, sizeof(optval),
+ sizeof(optval));
+ if (error != 0)
+ return (error);
inp = (struct sctp_inpcb *)so->so_pcb;
if (inp == NULL) {
SCTP_LTRACE_ERR_RET(so->so_pcb, NULL, NULL, SCTP_FROM_SCTP_USRREQ,
ENOBUFS);
return (EINVAL);
}
SCTP_INP_WLOCK(inp);
- inp->fibnum = so->so_fibnum;
+ error = sosetfib(so, optval);
+ if (error == 0)
+ inp->fibnum = optval;
SCTP_INP_WUNLOCK(inp);
- return (0);
+ return (error);
}
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300091] [sctp] SO_SETFIB setsockopt() silently fails on SCTP sockets
Author: bugzilla-noreply
Date: Mon, 26 Oct 2026 13:21
Date: Mon, 26 Oct 2026 13:21
16 lines
2615 bytes
2615 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300091
Albin Hellqvist <albin.hellqvist@ericsson.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |regression
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
[Bug 300091] [sctp] SO_SETFIB setsockopt() silently fails on SCTP sockets
Author: bugzilla-noreply
Date: Mon, 26 Oct 2026 15:36
Date: Mon, 26 Oct 2026 15:36
16 lines
2608 bytes
2608 bytes
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=300091
Mark Linimon <linimon@FreeBSD.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|bugs@FreeBSD.org |net@FreeBSD.org
--
You are receiving this mail because:
You are the assignee for the bug.
--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-admin@muc.de
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads