On Tue, Dec 1, 2026 at 2:46 PM <netd…@kernel.org> wrote:
> > Thank you for your contribution! Sashiko AI review found 2 potential > issue(s) to consider. > > Critical: 0 · High: 1 · Medium: 1 · Low: 0 > > 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 fix is incomplete. > - [Medium] Every sctp_process_init() failure in sctp_sf_do_5_1C_ack() > (net/sctp/sm_statefuns.c, around lines 606-613) is now reported as an… > > -- > > sctp: fail the association when the INIT-ACK cannot be processed > > This patch calls sctp_process_init() and sctp_auth_asoc_init_active_key() > directly from sctp_sf_do_5_1C_ack() instead of queueing them as side-effect > commands. If either step fails, the association is aborted with > sctp_stop_t1_and_abort(). The now unused SCTP_CMD_PEER_INIT and > SCTP_CMD_ASSOC_SHKEY commands are removed. >
> > diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c > > index 6a4205de0aa69..206fa0b6cd4b8 100644 > > --- a/net/sctp/sm_statefuns.c > > +++ b/net/sctp/sm_statefuns.c > > @@ -603,13 +603,26 @@ enum sctp_disposition sctp_sf_do_5_1C_ack(struct net *net, > > > > initchunk = (struct sctp_init_chunk *)chunk->chunk_hdr; > > > > - sctp_add_cmd_sf(commands, SCTP_CMD_PEER_INIT, > > - SCTP_PEER_INIT(initchunk)); > > + if (!sctp_process_init((struct sctp_association *)asoc, chunk, > > + sctp_source(chunk), initchunk, GFP_ATOMIC)) { > > + if (err_chunk) > > + sctp_chunk_free(err_chunk); > > + return sctp_stop_t1_and_abort(net, commands, > > + SCTP_ERROR_NO_RESOURCE, ENOMEM, > > + asoc, chunk->transport); > > + }
> > [Severity: Medium] > sctp_process_init() returns 0 for allocation failures and also for peer > or policy rejections. Does this report ENOMEM for failures that have > nothing to do with memory? >
Since sctp_verify_init() failure already refused the invalid params, using ENOMEM for sctp_process_init() failure is acceptable.
> The non-memory cases are the !src_match check, sctp_process_param() > rejections, and the ASCONF-without-AUTH check. That last check is active > by default because addip_noauth is 0: > > net/sctp/sm_make_chunk.c:sctp_process_init() { > ... > if (!asoc->base.net->sctp.addip_noauth && > (asoc->peer.asconf_capable && !asoc->peer.auth_capable)) { > ... > goto clean_up; > } > ... > } > > In those cases sctp_cmd_set_sk_err() sets sk->sk_err = ENOMEM on > non-UDP-style sockets. That value is what SO_ERROR returns after a > non-blocking connect(), and later sock_error() callers see it too. The > SCTP_ASSOC_CHANGE / SCTP_CANT_STR_ASSOC notification also carries > SCTP_ERROR_NO_RESOURCE. > > A blocking connect() still returns ECONNREFUSED or ETIMEDOUT from > sctp_wait_for_connect(), because that path ignores sk_err. > > The verification failure path just above reports a similar peer-caused > rejection as ECONNREFUSED with SCTP_ERROR_INV_PARAM. Before this patch the > -ENOMEM from the interpreter was dropped, T1-init kept retransmitting, and > the application eventually saw ETIMEDOUT. > > The commit message says the ASCONF-without-AUTH case now aborts at once, > but it doesn't say that userspace will see ENOMEM / NO_RESOURCE for it. > Could the non-memory rejections report a different error here? > > The comment in sctp_process_init() also still says: > > * also give us an option to silently ignore the packet, which > * is what we'll do here. > > The INIT-ACK path is the only caller with a non-temporary association, > and it now tears the association down instead. Should this comment be > updated? >
> > > > /* SCTP-AUTH: generate the association shared keys so that > > * we can potentially sign the COOKIE-ECHO. > > */ > > - sctp_add_cmd_sf(commands, SCTP_CMD_ASSOC_SHKEY, SCTP_NULL()); > > + if (sctp_auth_asoc_init_active_key((struct sctp_association *)asoc, > > + GFP_ATOMIC)) { > > + if (err_chunk) > > + sctp_chunk_free(err_chunk); > > + return sctp_stop_t1_and_abort(net, commands, > > + SCTP_ERROR_NO_RESOURCE, ENOMEM, > > + asoc, chunk->transport); > > + }
> > [Severity: High] > The commit message describes the bug as: > > with the peer marked AUTH capable and asoc->shkey still NULL, a > chunk that the peer wants authenticated ... takes a reference on the > NULL key > > Can the COOKIE-ECHO restart and collision handlers still reach this state? > sctp_sf_do_dupcook_a() and sctp_sf_do_dupcook_b() both call > sctp_sf_do_assoc_update()->sctp_assoc_update(). That function commits the > peer's AUTH state before it installs the key: > > net/sctp/associola.c:sctp_assoc_update() { > ... > asoc->peer.auth_capable = new->peer.auth_capable; > ... > kfree(asoc->peer.peer_chunks); > asoc->peer.peer_chunks = new->peer.peer_chunks; > new->peer.peer_chunks = NULL; > ... > return sctp_auth_asoc_init_active_key(asoc, GFP_ATOMIC); > } > > sctp_auth_asoc_init_active_key() can fail with -ENOMEM when > sctp_auth_asoc_create_secret() fails, and then asoc->shkey is never set. > Suppose the existing association had a non-AUTH peer, or was still in > COOKIE_WAIT (the dupcook_b collision case). Then shkey stays NULL while > auth_capable is now 1 and peer_chunks can list ABORT. > > sctp_sf_do_assoc_update() then builds an ABORT on that association right > away: > > net/sctp/sm_statefuns.c:sctp_sf_do_assoc_update() { > if (!sctp_assoc_update(asoc, new)) > return 0; > > abort = sctp_make_abort(asoc, NULL, sizeof(struct sctp_errhdr)); > ... > } > > This looks like it ends at the same crash site as the KASAN report: > > sctp_make_abort() > sctp_make_control() > _sctp_make_chunk() > sctp_auth_send_cid(SCTP_CID_ABORT, asoc) -> retval->auth = 1 > sctp_control_set_owner_w() > chunk->shkey = asoc->shkey; /* NULL */ > sctp_auth_shkey_hold(chunk->shkey); > > A remote peer can trigger this if ep->auth_enable is set locally and the > same GFP_ATOMIC failure that the reproducer relies on happens. The peer > restarts or collides with an INIT that advertises AUTH (RANDOM, HMAC-ALGO, > and CHUNKS including ABORT), then echoes the cookie. > > Should sctp_assoc_update() commit auth_capable and peer_chunks only after > the key is installed? Alternatively, should the ABORT built in > sctp_sf_do_assoc_update() not be authenticated? >
As commented in v3, this is an pre-existing issue and should be addressed in a separate patch. Thanks.
> > > > /* Reset init error count upon receipt of INIT-ACK. */ > > sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL());
> > -- > Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/1796…%40gmail.com