* [PATCH net] sctp: validate Cookie Preservative in the first pass
@ 2026-11-27 3:35 Sun Yiqi
2026-11-27 3:39 ` netdev-bot+sinfo
2026-11-28 3:37 ` netdev-bot+sashiko
0 siblings, 2 replies; 4+ messages in thread
From: Sun Yiqi @ 2026-11-27 3:35 UTC (permalink / raw)
To: netdev
Cc: linux-sctp, marcelo.leitner, lucien.xin, davem, edumazet, kuba,
pabeni, willemb, horms, trilobyte777, luoxiaoxing, Sun Yiqi
The Cookie Preservative parameter is eight bytes long, including a
32-bit lifespan increment. The generic SCTP parameter walk accepts
shorter parameters, so sctp_process_param() can read beyond the
parameter and expose data to the peer.
Validate the fixed length during the first parameter walk in
sctp_verify_init() and use the existing invalid-parameter-length
handler for mismatches. The second pass can return success before
checking all parameters, while sctp_process_init() walks the list
again. Checking the length in the first pass covers that path too.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Link: https://lists.openwall.net/netdev/2026/07/29/316
Signed-off-by: Sun Yiqi <sunyiqi2@huawei.com>
---
net/sctp/sm_make_chunk.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index ba0474c2a0bc..01b1eea0222c 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))
+ return sctp_process_inv_paramlength(asoc, param.p,
+ chunk, errp);
+
if (param.p->type == SCTP_PARAM_STATE_COOKIE)
has_cookie = true;
}
--
2.51.0.windows.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH net] sctp: validate Cookie Preservative in the first pass
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
1 sibling, 1 reply; 4+ messages in thread
From: netdev-bot+sinfo @ 2026-11-27 3:39 UTC (permalink / raw)
To: Sun Yiqi
Cc: netdev, linux-sctp, marcelo.leitner, lucien.xin, davem, edumazet,
kuba, pabeni, willemb, horms, trilobyte777, luoxiaoxing
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sctp: validate Cookie Preservative in the first pass
2026-11-27 3:39 ` netdev-bot+sinfo
@ 2026-11-27 5:25 ` Charles Research
0 siblings, 0 replies; 4+ messages in thread
From: Charles Research @ 2026-11-27 5:25 UTC (permalink / raw)
To: netdev-bot+sinfo
Cc: Sun Yiqi, netdev, linux-sctp, marcelo.leitner, lucien.xin, davem,
edumazet, kuba, pabeni, willemb, horms, luoxiaoxing
For the missing discovery/runtime context:
I originally found the Cookie Preservative length issue during
AI-assisted/manual review of the SCTP fixed-format parameter
validation following the Adaptation Indication issue, and then
independently reproduced it at runtime in an owned KVM/QEMU
environment.
The malformed Cookie Preservative parameter was accepted on the
unpatched kernel in both header-only and overlong forms. The
header-only case causes sctp_process_param() to read
lifespan_increment beyond the declared parameter and use that value
when calculating the State Cookie lifetime returned to the peer.
For my July 29 testing, the unpatched kernel accepted both malformed
forms. With the original validation patch applied, both malformed
forms were rejected while the baseline and valid eight-byte Cookie
Preservative controls continued to pass.
Sun's patch moves the validation into the first parameter walk, which
addresses the additional path where the second verification pass can
return before all parameters are checked.
Since this is a follow up on the Cookie Preservative issue I
originally reported and runtime-tested in the linked July patch,
please feel free to add Reported-by: Charles Vosburgh
<trilobyte777@gmail.com>.
Thanks,
Charles
On Thu, Nov 26, 2026 at 10:39 PM <netdev-bot+sinfo@kernel.org> wrote:
>
> Hi!
>
> This is an automated message. This series looks like a fix, but its
> commit messages seem to be missing some information:
>
> - How the issue was discovered, e.g. hit in production, hit during
> development, syzbot report, manual code inspection, LLM or static
> analysis tool scan.
>
> - Whether the issue was actually triggered, or is only theoretical
> (e.g. found by LLM and not proven at runtime). If it was triggered
> please include the symptoms, like the stack trace or kernel messages.
>
> Please do not repost the series just to address the above. Instead,
> reply to this email with the missing information, so that reviewers
> can take it into account.
>
> *IMPORTANT*: If you do repost (for other reasons) - please include
> the relevant info in the cover letter or commit messages.
> --
> The evaluation is done by an LLM so it may be wrong, if you think
> that is the case please reply and explain.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net] sctp: validate Cookie Preservative in the first pass
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-28 3:37 ` netdev-bot+sashiko
1 sibling, 0 replies; 4+ messages in thread
From: netdev-bot+sashiko @ 2026-11-28 3:37 UTC (permalink / raw)
To: sunyiqi2
Cc: netdev, linux-sctp, marcelo.leitner, lucien.xin, davem, edumazet,
kuba, pabeni, willemb, horms, trilobyte777, luoxiaoxing
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-11-28 3:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox