* [PATCH net] sctp: don't count pending-deleted addresses as survivors on bindx del
@ 2026-11-27 6:50 Henry Martin
2026-11-28 7:49 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: Henry Martin @ 2026-11-27 6:50 UTC (permalink / raw)
To: Xin Long, Marcelo Ricardo Leitner, Vlad Yasevich,
David S . Miller, Jakub Kicinski, Paolo Abeni, Eric Dumazet,
Simon Horman
Cc: linux-sctp, netdev, Henry Martin, stable
sctp_send_asconf_del_ip() uses sctp_find_unmatch_addr() to make sure a
bindx delete keeps at least one address in the association. The lookup
counts entries that are already marked SCTP_ADDR_DEL by a previous
delete request as survivors. With a peer that holds back the ASCONF
acks, two sequential bindx deletes each pass the check while together
marking every address for deletion. Once the peer acks both deletes,
the association's address list is empty.
An empty address list breaks its consumers. SCTP diag reads the list
head as an address and returns 16 bytes of association memory in
idiag_src. A following bindx add builds an ASCONF from a bogus address
taken from the empty list head, whose address family matches no sctp_af,
and dereferences a NULL af pointer.
e.g. on mainline v7.4-rc4 (KASAN build):
Oops: general protection fault (non-canonical 0xdffffc000000000b)
KASAN: null-ptr-deref in range [0x0000000000000058-0x000000000000005f]
CPU: 1 UID: 1000 PID: 81 Comm: poc-crash Not tainted 7.4.0-rc4 #1
RIP: 0010:sctp_make_asconf+0xd9/0x280
Call Trace:
sctp_make_asconf_update_ip+0x243/0x540
sctp_send_asconf_add_ip+0x366/0xc90
sctp_setsockopt+0x1986/0x9410
do_sock_setsockopt+0xb2/0x160
__sys_setsockopt+0xdd/0x140
An address that is already being deleted cannot serve as the remaining
address, so skip SCTP_ADDR_DEL entries in the survivor lookup. The
existing keep-last handling then holds the final address back, same as
it already does for a single-address delete.
This issue was discovered by Tencent CodeBuddy Security.
Cc: stable@vger.kernel.org
Fixes: f57d96b2e92d ("[SCTP]: Change use_as_src into a full address state")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
net/sctp/bind_addr.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
index 31737f144c7f0..e20006b9f12e4 100644
--- a/net/sctp/bind_addr.c
+++ b/net/sctp/bind_addr.c
@@ -445,6 +445,12 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
* can't change.
*/
list_for_each_entry(laddr, &bp->address_list, list) {
+ /* An address already being deleted cannot serve as the
+ * one remaining address.
+ */
+ if (laddr->state == SCTP_ADDR_DEL)
+ continue;
+
addr_buf = (union sctp_addr *)addrs;
for (i = 0; i < addrcnt; i++) {
addr = addr_buf;
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] sctp: don't count pending-deleted addresses as survivors on bindx del
2026-11-27 6:50 [PATCH net] sctp: don't count pending-deleted addresses as survivors on bindx del Henry Martin
@ 2026-11-28 7:49 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-11-28 7:49 UTC (permalink / raw)
To: bsdhenrymartin
Cc: lucien.xin, marcelo.leitner, vladislav.yasevich, davem, kuba,
pabeni, edumazet, horms, linux-sctp, netdev, stable
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 1 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch only partly closes the bug class it claims to fix.
- [Medium] The patch sends a second delete into the keep-last branch of
sctp_send_asconf_del_ip() (net/sctp/socket.c:863-896) while the first…
- [Low] Two comments no longer match the patched code: - The header
comment of sctp_find_unmatch_addr() (net/sctp/bind_addr.c:429-431)…
--
sctp: don't count pending-deleted addresses as survivors on bindx del
This patch makes sctp_find_unmatch_addr() skip entries that are already
marked SCTP_ADDR_DEL. Two bindx deletes in a row, with unacknowledged
ASCONFs, should then no longer be able to empty the association's bind
address list. When no undeleted survivor is left, the keep-last handling
in sctp_send_asconf_del_ip() is used instead.
> diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
> index 31737f144c7f0..e20006b9f12e4 100644
> --- a/net/sctp/bind_addr.c
> +++ b/net/sctp/bind_addr.c
> @@ -445,6 +445,12 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp,
> * can't change.
> */
> list_for_each_entry(laddr, &bp->address_list, list) {
> + /* An address already being deleted cannot serve as the
> + * one remaining address.
> + */
> + if (laddr->state == SCTP_ADDR_DEL)
> + continue;
[Severity: High]
Can the SCTP_ADDR_DEL mark be overwritten while its delete is still
queued?
The new check relies only on laddr->state. However,
sctp_asconf_param_success() sets the state back to SRC on a successful
ADD_IP ack, without checking the current state:
net/sctp/sm_make_chunk.c:sctp_asconf_param_success() {
...
case SCTP_PARAM_ADD_IP:
...
list_for_each_entry(saddr, &bp->address_list, list) {
if (sctp_cmp_addr_exact(&saddr->a, &addr))
saddr->state = SCTP_ADDR_SRC;
}
...
}
Take an association whose list is only A(SRC). The endpoint also holds a
third address D, which is needed to pass the endpoint-level check in
sctp_bindx_rem(). The reproducer in the commit message needs the same
thing.
bindx ADD B
B is SCTP_ADDR_NEW, ASCONF1 (ADD B) sent
bindx DEL B
sctp_find_unmatch_addr() returns A
ASCONF2 (DEL B) queued behind ASCONF1, B marked SCTP_ADDR_DEL
peer acks ASCONF1
sctp_asconf_param_success() sets B back to SCTP_ADDR_SRC
ASCONF2 sent, peer holds the ack
bindx DEL A
B is SRC, so the new check doesn't skip it; B returned as survivor
keep-last branch skipped, ASCONF3 (DEL A) queued, A marked DEL
peer acks ASCONF2 and ASCONF3
sctp_del_bind_addr() runs for B and A, asoc list is now empty
sctp_sf_do_asconf_ack() matches acks by serial number only.
The next bindx ADD then reaches sctp_send_asconf_add_ip(). It takes the
first entry without checking whether the list is empty:
net/sctp/socket.c:sctp_send_asconf_add_ip() {
...
bp = &asoc->base.bind_addr;
p = bp->address_list.next;
laddr = list_entry(p, struct sctp_sockaddr_entry, list);
chunk = sctp_make_asconf_update_ip(asoc, &laddr->a, addrs,
...
}
Wouldn't this hit the same NULL af dereference in sctp_make_asconf(), and
the same diag leak, that the commit message describes?
Could pending deletes be tracked in a way the ADD-ack path can't reset?
For example, sctp_asconf_param_success() could skip entries that are
SCTP_ADDR_DEL. Or the survivor check could look at the queued and
outstanding DEL params.
[Severity: Medium]
Is the keep-last branch really the same as the single-address case here?
With this change, a second delete issued while the first DEL ASCONF is
still outstanding goes into the keep-last branch of
sctp_send_asconf_del_ip(), which does:
asoc->src_out_of_asoc_ok = 1;
stored = 1;
goto skip_mkasconf;
sctp_process_asconf_ack() clears that flag on any error-free ack, even if
asconf_addr_del_pending is still set:
net/sctp/sm_make_chunk.c:sctp_process_asconf_ack() {
...
if (no_err && asoc->src_out_of_asoc_ok) {
asoc->src_out_of_asoc_ok = 0;
sctp_transport_immediate_rtx(asoc->peer.primary_path);
}
...
}
Take an association with [A(SRC), B(SRC)]:
bindx DEL A
ASCONF(DEL A) sent, A marked DEL
bindx DEL B
patched sctp_find_unmatch_addr() skips A, returns NULL
keep-last: pending = B, src_out_of_asoc_ok = 1, B marked DEL
peer acks DEL A, delayed only by normal RTT
A removed, pending B kept (no match), src_out_of_asoc_ok cleared
That leaves the association with [B(DEL)] and src_out_of_asoc_ok == 0.
sctp_v4_get_dst() then rejects every candidate source address, and the
IPv6 version does the same:
if (!laddr->valid || (laddr->state == SCTP_ADDR_DEL) ||
(laddr->state != SCTP_ADDR_SRC &&
!asoc->src_out_of_asoc_ok))
continue;
sctp_packet_transmit() drops packets when tp->dst is NULL.
Keep-last relies on a later bindx ADD C to recover, by sending
ASCONF(ADD C, DEL B). That ASCONF doesn't look like it can be sent
either:
- C is SCTP_ADDR_NEW, so it can't be a source address without
src_out_of_asoc_ok.
- The transport reset block in sctp_send_asconf_add_ip() runs only when
asoc->src_out_of_asoc_ok is set, so it is skipped.
Can the association do anything other than stall until the
retransmission limits abort it?
The clear-on-any-ack logic is older than this patch. Still, the commit
message's "same as it already does for a single-address delete" relies on
it.
[Severity: Low]
This isn't a bug, but the header comment of sctp_find_unmatch_addr() still
says:
/* Find the first address in the bind address list that is not present in
* the addrs packed array.
*/
With this change the function also skips SCTP_ADDR_DEL entries. It can
return NULL even when an unmatched address exists.
Should this comment be updated? The same applies to the "Find one address
in the association's bind address list that is not in the packed array of
addresses" comment in sctp_send_asconf_del_ip().
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261127065017.2922776-1-bsdhenrymartin%40gmail.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-28 7:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 6:50 [PATCH net] sctp: don't count pending-deleted addresses as survivors on bindx del Henry Martin
2026-11-28 7:49 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox