From: netdev-bot+sashiko@kernel.org
To: sunyiqi2@huawei.com
Cc: netdev@vger.kernel.org, linux-sctp@vger.kernel.org,
marcelo.leitner@gmail.com, lucien.xin@gmail.com,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, willemb@google.com, horms@kernel.org,
trilobyte777@gmail.com, luoxiaoxing@huawei.com
Subject: Re: [PATCH net] sctp: validate Cookie Preservative in the first pass
Date: Sat, 28 Nov 2026 03:37:03 +0000 [thread overview]
Message-ID: <179583702392.3135.14690679679244034273@kernel.org> (raw)
In-Reply-To: <20261127033534.175-1-sunyiqi2@huawei.com>
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/20261127033534.175-1-sunyiqi2%40huawei.com
prev parent reply other threads:[~2026-11-28 3:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 3:35 [PATCH net] sctp: validate Cookie Preservative in the first pass Sun Yiqi
2026-11-27 3:39 ` netdev-bot+sinfo
2026-11-27 5:25 ` Charles Research
2026-11-28 3:37 ` 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=179583702392.3135.14690679679244034273@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--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=luoxiaoxing@huawei.com \
--cc=marcelo.leitner@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sunyiqi2@huawei.com \
--cc=trilobyte777@gmail.com \
--cc=willemb@google.com \
/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