From: netdev-bot+sashiko@kernel.org
To: bsdhenrymartin@gmail.com
Cc: lucien.xin@gmail.com, marcelo.leitner@gmail.com,
davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@kernel.org, horms@kernel.org,
linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH net v2] sctp: don't count pending-deleted addresses as survivors on bindx del
Date: Thu, 03 Dec 2026 11:09:32 +0000 [thread overview]
Message-ID: <179629617259.3146.5656250467314221888@kernel.org> (raw)
In-Reply-To: <20261202101355.540636-1-bsdhenrymartin@gmail.com>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 3 (2) · Low: 1 (2)
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] sctp: duplicate queued DEL_IP parameters can still empty
bind_addr list
- [Medium] After the patch, sctp_process_asconf_ack() clears
src_out_of_asoc_ok only when asoc->asconf_addr_del_pending is NULL.
- [Medium] The commit says 'the existing keep-last handling then holds
the final address back'.
- [Medium] Because SCTP_ADDR_DEL entries are now skipped, the keep-last
branch in sctp_send_asconf_del_ip() can be reached for an address…
- [Low] The commit message understates what it takes to trigger the bug
and where it can be reached from.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the
association address list can still become empty.
- [Medium] This problem wasn't introduced by this patch, but
sctp_find_unmatch_addr() still counts SCTP_ADDR_NEW entries (ADD_IP…
- [Medium] This problem wasn't introduced by this patch, but
SCTP_ADDR_DEL is never rolled back when the peer refuses a DEL_IP.
- [Low] This problem wasn't introduced by this patch, but the comment in
sctp_send_asconf_add_ip() says 'Use the first valid address in bind…
- [Low] This problem wasn't introduced by this patch, but two comments
still refer to the removed use_as_src field.
--
sctp: don't count pending-deleted addresses as survivors on bindx del
This commit makes sctp_find_unmatch_addr() skip SCTP_ADDR_DEL entries, so
that sequential bindx deletes cannot mark every association address for
deletion. It also keeps the SCTP_ADDR_DEL mark across an ADD_IP ack in
sctp_asconf_param_success(). In addition, sctp_process_asconf_ack() now
clears src_out_of_asoc_ok only after asconf_addr_del_pending is gone.
Link: https://lore.kernel.org/netdev/20261127065017.2922776-1-bsdhenrymartin@gmail.com/
> 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.
[Severity: Low]
Is this the full picture of what is needed to trigger this? A compliant
peer refuses the second delete in sctp_process_asconf_param():
if (asoc->peer.transport_count == 1)
return SCTP_ERROR_DEL_LAST_IP;
A Linux peer that has already processed DEL A returns DEL_LAST_IP for the
second delete. The local address then stays SCTP_ADDR_DEL and is never
removed. To get the empty list, the peer has to ack the deletion of our
last address, which means a non-compliant or malicious peer.
sctp_send_asconf_del_ip() and sctp_send_asconf_add_ip() are also called
from sctp_asconf_mgmt(), the auto_asconf addr_wq path, not only from
sctp_setsockopt_bindx():
if (addrw->state == SCTP_ADDR_NEW)
return sctp_send_asconf_add_ip(sk, (struct sockaddr *)addr, 1);
else
return sctp_send_asconf_del_ip(sk, (struct sockaddr *)addr, 1);
That means interface address events can reach the same empty list and the
same NULL af dereference in sctp_make_asconf(), with no bindx call.
The code fix is in the shared helper, so it covers both paths. Could the
commit message mention the peer requirement and the auto_asconf path?
> diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c
> index 31737f144c7f0..7a5890877ff0e 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 address list still be emptied through duplicate DEL_IP
parameters for the same address? This check assumes an address has at
most one DEL_IP in flight, but there seem to be two ways to queue a
second one.
First, the lookup loop in sctp_send_asconf_del_ip() only calls
sctp_assoc_lookup_laddr(), which also matches entries that are already
SCTP_ADDR_DEL. With ep/asoc {A,B}:
bindx rem A -> DEL A sent, A marked SCTP_ADDR_DEL, ack outstanding
bindx add A -> A back in the ep only, sctp_send_asconf_add_ip()
skips the asoc because A is still in its list
bindx rem A -> A is still found in the asoc and B is the survivor,
so a second DEL A is queued on addip_chunk_list
Second, asconf_addr_del_pending is only freed when its DEL_IP is acked.
Until then, sctp_make_asconf_update_ip() piggybacks it on every ADD_IP
it builds:
if (flags == SCTP_PARAM_ADD_IP && asoc->asconf_addr_del_pending) {
With A held back by keep-last, bindx add B followed by bindx add C
before the first ack queues ADD B + DEL A and then ADD C + DEL A.
Either way, once the first DEL A is acked, sctp_asconf_param_success()
removes A and the second DEL A goes out. If A is added back at this
point, sctp_assoc_lookup_laddr() no longer finds it. A new SCTP_ADDR_NEW
entry for A is inserted, and ADD A is queued behind the second DEL A.
A following bindx rem of B (and C) then picks A as the survivor here,
because its state is SCTP_ADDR_NEW, and queues DEL B.
Suppose the peer acks everything. The second DEL A calls
sctp_del_bind_addr() on the new A entry, and the ADD A ack finds nothing
to promote. The DEL B ack then removes the last entry, which leaves
asoc->base.bind_addr.address_list empty again. That gives the same
idiag_src leak in inet_diag_msg_sctpasoc_fill(), and the same NULL af
dereference in sctp_make_asconf() on the next ADD-IP.
Like the original scenario, this needs a peer that acks the deletion of
our last address. Should sctp_send_asconf_del_ip() skip addresses that
are already SCTP_ADDR_DEL in the asoc? And should
asconf_addr_del_pending stop being piggybacked once it has been placed
in an ASCONF? Or is there a better way to stop a queued DEL_IP from
removing a re-added entry for the same address?
[Severity: Medium]
The commit message says "The existing keep-last handling then holds the
final address back". In sctp_send_asconf_del_ip(), that handling only
exists for addrcnt == 1:
if ((laddr == NULL) && (addrcnt == 1)) {
What happens to a multi-address delete when every other entry is
SCTP_ADDR_DEL? sctp_find_unmatch_addr() now returns NULL, and the code
falls through to this, inside the ep->asocs loop:
if (laddr == NULL)
return -EINVAL;
For example, with ep {A,B,C} and asoc {A,B,C}:
bindx rem A -> DEL A sent, A marked SCTP_ADDR_DEL, ack outstanding
bindx add A -> A re-added to the ep only, because
sctp_assoc_lookup_laddr() still finds A in the asoc
bindx rem B,C -> sctp_bindx_rem() leaves ep {A}, then
sctp_send_asconf_del_ip(B,C) finds no survivor and
returns -EINVAL
By this point sctp_setsockopt_bindx() has already removed B and C from the
endpoint, and nothing puts them back:
err = sctp_bindx_rem(sk, addrs, addrcnt);
if (err)
return err;
return sctp_send_asconf_del_ip(sk, addrs, addrcnt);
Doesn't this leave the asoc with B and C as SCTP_ADDR_SRC, with no way to
delete them through bindx? It also looks like associations later in
ep->asocs are never processed.
The bare return and the missing rollback predate this patch. This patch
is what sends the multi-address form of the target scenario down that
path instead of into keep-last handling.
[Severity: Medium]
This isn't a bug introduced by this patch, but sctp_find_unmatch_addr()
still counts SCTP_ADDR_NEW entries (ADD_IP not yet acked) as the surviving
address. Source selection in sctp_v4_get_dst() does not accept them:
if (!laddr->valid || (laddr->state == SCTP_ADDR_DEL) ||
(laddr->state != SCTP_ADDR_SRC &&
!asoc->src_out_of_asoc_ok))
continue;
sctp_v6_get_dst() applies the same rule.
Take asoc {A(SRC)}, then bindx add C (C is NEW), then bindx del A. C is
returned as the survivor, a normal DEL A is queued, and
src_out_of_asoc_ok stays 0.
Suppose the peer refuses ADD C and acks DEL A.
sctp_process_asconf_ack() has no rollback for refusals, so the asoc ends
up with {C(NEW)}. How would the association recover, when no code path
will use C as a source?
A compliant peer would refuse that DEL with DEL_LAST_IP, so this needs a
non-compliant peer. The list is not empty, so the diag leak and the oops
are not reached.
[Severity: Medium]
This is a pre-existing issue, but the new comment assumes SCTP_ADDR_DEL
means a delete is in flight. Is that always true? When the peer refuses a
DEL_IP, sctp_process_asconf_ack() just breaks:
case SCTP_ERROR_REQ_REFUSED:
case SCTP_ERROR_DEL_LAST_IP:
case SCTP_ERROR_DEL_SRC_IP:
default:
break;
laddr->state is written in only two places: the SCTP_ADDR_DEL marking in
sctp_send_asconf_del_ip(), and the SCTP_ADDR_SRC promotion on ADD_IP
success in sctp_asconf_param_success(). So an address whose delete was
refused stays SCTP_ADDR_DEL for good. It also cannot be re-added, because
sctp_assoc_lookup_laddr() still finds it.
With this patch, that address is excluded from the survivor lookup. A
later single-address delete of the last SRC address then takes the
keep-last path: src_out_of_asoc_ok = 1, no ASCONF is sent, and DATA is
held back until the next bindx add.
Before the patch, the same delete went ahead and left only the DEL entry,
so the association was stuck either way.
> addr_buf = (union sctp_addr *)addrs;
> for (i = 0; i < addrcnt; i++) {
> addr = addr_buf;
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index 22207ac4de145..1536e52ccecc6 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
[ ... ]
> @@ -3562,7 +3563,8 @@ int sctp_process_asconf_ack(struct sctp_association *asoc,
> asconf_len -= length;
> }
>
> - if (no_err && asoc->src_out_of_asoc_ok) {
> + if (no_err && asoc->src_out_of_asoc_ok &&
> + !asoc->asconf_addr_del_pending) {
[Severity: Medium]
Can this stall the association indefinitely? src_out_of_asoc_ok does more
than widen source selection. While it is set, sctp_outq_flush_ctrl()
holds back every non-ASCONF control chunk:
if (ctx->asoc->src_out_of_asoc_ok &&
chunk->chunk_hdr->type != SCTP_CID_ASCONF)
continue;
and sctp_outq_flush() skips DATA:
if (q->asoc->src_out_of_asoc_ok)
goto sctp_flush_out;
asconf_addr_del_pending is freed only when the piggybacked DEL_IP
succeeds. sctp_make_asconf_update_ip() appends that DEL_IP only to ADD_IP
ASCONFs:
if (flags == SCTP_PARAM_ADD_IP && asoc->asconf_addr_del_pending) {
Suppose the peer accepts ADD X but refuses the piggybacked DEL P with
REQ_REFUSED, DEL_SRC_IP, RSRC_LOW or any other error. X becomes
SCTP_ADDR_SRC, so a usable source exists, but pending stays set.
Before this patch, a later error-free ack cleared the flag, for example
SET_PRIMARY or a DEL of another address that has a normal survivor. With
the new condition, only a successful DEL P can clear it.
Wouldn't the association then send no DATA, SACK or HEARTBEAT until a
later bindx add carries a DEL P that the peer accepts? A peer that keeps
refusing DEL P would stall it indefinitely. The commit message describes
the flag only as permission to use a new address as the source.
> asoc->src_out_of_asoc_ok = 0;
> sctp_transport_immediate_rtx(asoc->peer.primary_path);
> }
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index e97eb78e202f0..64e65d6b1a2af 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -858,9 +858,9 @@ static int sctp_send_asconf_del_ip(struct sock *sk,
> continue;
>
> /* Find one address in the association's bind address list
> - * that is not in the packed array of addresses. This is to
> - * make sure that we do not delete all the addresses in the
> - * association.
> + * that is not in the packed array of addresses and is not
> + * being deleted. This is to make sure that we do not delete
> + * all the addresses in the association.
> */
> bp = &asoc->base.bind_addr;
> laddr = sctp_find_unmatch_addr(bp, (union sctp_addr *)addrs,
[Severity: Medium]
Now that SCTP_ADDR_DEL entries are skipped, can the keep-last branch just
below this be reached for an address other than the one already stored in
asconf_addr_del_pending? If so, the delete is silently dropped:
if ((laddr == NULL) && (addrcnt == 1)) {
if (asoc->asconf_addr_del_pending)
continue;
For example, with a compliant peer and ep/asoc {A,B}:
bindx rem A -> DEL A sent, ack outstanding
bindx add A -> A back in the ep only
bindx rem B -> no survivor (A is DEL), so keep-last sets pending = B,
src_out_of_asoc_ok = 1, and marks B DEL
bindx add X -> ADD X + DEL B queued, X inserted as SCTP_ADDR_NEW
bindx rem X -> X removed from the ep; sctp_find_unmatch_addr() skips
A and B, X is in addrs, so it returns NULL and the
code hits the continue above
X is not marked DEL, no ASCONF is queued, and retval is 0. When the acks
arrive, sctp_asconf_param_success() promotes X to SCTP_ADDR_SRC, deletes
B and frees pending.
The asoc ends up as {X(SRC)} and the ep as {A}, and the removal of X
returned success. Through sctp_asconf_mgmt(), X may be an address that
has already been removed from the host.
Before this patch, B counted as a survivor, so this branch was reached
only when deleting the pending address itself.
[Severity: High]
This is a pre-existing issue, but can the association address list still
become empty through sctp_send_asconf_add_ip()? The ASCONF is built
before the new address is inserted. When asconf_addr_del_pending is set,
it already carries the DEL_IP for the held-back address.
If the GFP_ATOMIC insertion then fails, the -ENOMEM is overwritten and
the ASCONF is sent anyway:
retval = sctp_add_bind_addr(bp, &saveaddr,
sizeof(saveaddr),
SCTP_ADDR_NEW, GFP_ATOMIC);
...
retval = sctp_send_asconf(asoc, chunk);
A compliant peer adds X first, so DEL_LAST_IP does not fire, and it acks
both parameters. Locally, the ADD_IP success finds no entry to promote,
and the DEL_IP success calls sctp_del_bind_addr() on the last address.
That leaves the list empty.
After that, inet_diag_msg_sctpasoc_fill() reads the list head as an
entry:
laddr = list_entry(asoc->base.bind_addr.address_list.next,
struct sctp_sockaddr_entry, list)->a;
The next ADD-IP, from bindx add or auto_asconf, then hits the same NULL
af dereference in sctp_make_asconf().
The keep-last state this depends on is reachable both before this patch
(single-address asoc) and after it (the two-delete scenario). Since this
fix relies on the list never becoming empty, should this error be
returned and the ASCONF not sent?
[Severity: Low]
This isn't a bug introduced by this patch, but the comment in
sctp_send_asconf_add_ip() does not match the code:
/* Use the first valid address in bind addr list of
* association as Address Parameter of ASCONF CHUNK.
*/
bp = &asoc->base.bind_addr;
p = bp->address_list.next;
laddr = list_entry(p, struct sctp_sockaddr_entry, list);
There is no emptiness, laddr->valid or state check here, and this is the
crash site in the commit message.
After this patch the first entry can still be SCTP_ADDR_DEL, either the
held-back keep-last address or one with a DEL_IP in flight. Should the
comment or the code be updated to match?
[Severity: Low]
This isn't a bug introduced by this patch, but two comments still refer
to the removed use_as_src field. The commit named in Fixes: replaced that
field with the state enum.
In sctp_send_asconf_del_ip():
/* Reset use_as_src flag for the addresses in the bind address
* list that are to be deleted.
*/
and in sctp_send_asconf_add_ip():
/* Add the new addresses to the bind address list with
* use_as_src set to 0.
*/
Since this patch updates the nearby survivor-lookup comment, could these
two be updated as well?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202101355.540636-1-bsdhenrymartin%40gmail.com
prev parent reply other threads:[~2026-12-03 11:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 10:13 [PATCH net v2] sctp: don't count pending-deleted addresses as survivors on bindx del Henry Martin
2026-12-03 11:09 ` netdev-bot+sashiko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179629617259.3146.5656250467314221888@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=bsdhenrymartin@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-sctp@vger.kernel.org \
--cc=lucien.xin@gmail.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox