On Fri, Nov 27, 2026 at 10:37 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: 0 · 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 fix is incomplete. > - [Low] The lines added to sctp_verify_init() are badly indented. > > -- > > sctp: validate Cookie Preservative in the first pass > > This commit adds a length check for the Cookie Preservative parameter to > the first parameter walk in sctp_verify_init(). A mismatched length is > reported through sctp_process_inv_paramlength(). The goal is to stop > sctp_process_param() from reading past a short parameter, even when the > second verification pass returns early. > > Link: https://lists.openwall.net/netdev/2026/07/29/316 >
> > diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c > > index ba0474c2a0bc8..01b1eea0222c4 100644 > > --- a/net/sctp/sm_make_chunk.c > > +++ b/net/sctp/sm_make_chunk.c > > @@ -2317,6 +2317,12 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep, > > return sctp_process_inv_mandatory(asoc, chunk, errp); > > > > sctp_walk_params(param, peer_init) { > > + /* Validate the length even if the second pass stops early. */ > > + if (param.p->type == SCTP_PARAM_COOKIE_PRESERVATIVE && > > + ntohs(param.p->length) != sizeof(*param.life))
> > [Severity: High] > > Other fixed-length parameters have the same problem. Does this patch > cover them? > > This check only handles SCTP_PARAM_COOKIE_PRESERVATIVE. The length checks > for SCTP_PARAM_ADAPTATION_LAYER_IND and SCTP_PARAM_SET_PRIMARY are still > only in sctp_verify_param(), which runs in the second pass. > > As the commit message says, the second pass can stop early. An > unrecognized parameter with action bits 00 or 01 makes > sctp_process_unk_param() return SCTP_IERROR_ERROR: > > net/sctp/sm_make_chunk.c:sctp_process_unk_param() { > ... > case SCTP_PARAM_ACTION_DISCARD: > retval = SCTP_IERROR_ERROR; > break; > ... > } > > sctp_verify_init() then returns 1 before it checks any of the later > parameters: > > case SCTP_IERROR_ERROR: > return 1; > > Say a peer sends an INIT that has an unknown parameter (action 00 or 01) > followed by a 4-byte ADAPTATION_LAYER_IND. This check in > sctp_verify_param() is never reached: > > case SCTP_PARAM_ADAPTATION_LAYER_IND: > if (ntohs(param.p->length) != sizeof(*param.aind)) { > > The path then continues: > > sctp_sf_do_5_1B_init() > sctp_verify_init() returns 1 at the unknown parameter > sctp_process_init() walks every parameter > sctp_process_param() > asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind); > > This reads 4 bytes past the end of the parameter. sctp_pack_cookie() then > copies the value into the State Cookie: > > cookie->c.adaptation_ind = asoc->peer.adaptation_ind; > > The cookie is sent back to the peer in the INIT-ACK. Isn't that the same > disclosure to the peer that the commit message describes? > > SET_PRIMARY (with asconf_enable set) seems to get past the checks the > same way. For a parameter length of 4 to 7, this check in > sctp_process_param() is computed in size_t and wraps: > > addr_param = param.v + sizeof(struct sctp_addip_param); > if (ntohs(addr_param->p.length) > > ntohs(param.p->length) - sizeof(struct sctp_addip_param)) > break; > > The out-of-bounds addr_param is then read through addr_param->p and > af->from_addr_param(). > > Would one of these options work instead? > > - validate every fixed-length parameter in the first pass > - have sctp_process_init() and sctp_process_param() check bounds > themselves > - have sctp_process_init() stop where the second verify pass stopped >
> > + return sctp_process_inv_paramlength(asoc, param.p, > > + chunk, errp);
> > [Severity: Low] > > This isn't a bug, but the indentation of the added lines doesn't follow > kernel coding style or match the rest of sctp_verify_init(). The condition > continuation and the return are indented too far. Also, "chunk, errp);" > doesn't line up with the open parenthesis. checkpatch will probably warn > about this. >
> > + > > if (param.p->type == SCTP_PARAM_STATE_COOKIE) > > has_cookie = true; > > }
> > -- > Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40huawei.com
Please move the check ntohs(param.p->length) != sizeof(*param.life) for SCTP_PARAM_COOKIE_PRESERVATIVE to sctp_verify_param(), similar to SCTP_PARAM_ADAPTATION_LAYER_IND. Also fix the indentation of the new 'chunk, errp)' line. and make sure it will pass the check with ./scripts/checkpatch.pl As for the second pass can return success before checking all parameters, that is a pre-existing issue, and you may address it in sctp_process_init() in a separate patch, something like: 1. In sctp_process_param(), return -1 for error, 0 for unrecognized parameter, 1 for successful process. 2. In sctp_process_init(), change to goto clean_up when sctp_process_param() returns -1, and check (param.p->type & SCTP_PARAM_ACTION_MASK) when it returns 0 and decides if it should break and skip the rest params to align with sctp_verify_init(). Thanks. pw-bot: cr