* [PATCH net] sctp: reject stale cookies with mismatched verification tags
@ 2026-07-23 22:56 Yuxiang Yang
2026-07-24 15:50 ` Xin Long
2026-07-27 22:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Yuxiang Yang @ 2026-07-23 22:56 UTC (permalink / raw)
To: linux-sctp, netdev
Cc: marcelo.leitner, lucien.xin, davem, edumazet, kuba, pabeni, horms,
linux-kernel, Yuxiang Yang, stable, Yizhou Zhao, Ao Wang,
Xuewei Feng, Qi Li, Ke Xu, yyxroy22
sctp_unpack_cookie() skips cookie expiration checks whenever an
association already exists. This is broader than the exception in
RFC 9260 Section 5.2.4.
For an existing association, Section 5.2.4 permits an expired State
Cookie only when both Verification Tags in the cookie match the current
association. Otherwise, the packet SHOULD be discarded and a Stale
Cookie ERROR MUST be sent.
The broad check lets an expired Action A restart cookie reach
sctp_sf_do_dupcook_a(). In a runtime test with the default 60 second
cookie lifetime, replaying such a cookie after 65 seconds returned a
COOKIE-ACK and restarted the association.
Check cookie expiration unless both Verification Tags match. This
preserves the Action D exception for a lost COOKIE ACK while rejecting
expired cookies in all other cases.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
---
net/sctp/sm_make_chunk.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
index c02809264..a1c0334a1 100644
--- a/net/sctp/sm_make_chunk.c
+++ b/net/sctp/sm_make_chunk.c
@@ -1802,9 +1802,9 @@ struct sctp_association *sctp_unpack_cookie(
goto fail;
}
- /* Check to see if the cookie is stale. If there is already
- * an association, there is no need to check cookie's expiration
- * for init collision case of lost COOKIE ACK.
+ /* Check to see if the cookie is stale. RFC 9260 Section 5.2.4
+ * exempts an expired cookie only when both Verification Tags match
+ * the current association.
* If skb has been timestamped, then use the stamp, otherwise
* use current time. This introduces a small possibility that
* a cookie may be considered expired, but this would only slow
@@ -1815,7 +1815,10 @@ struct sctp_association *sctp_unpack_cookie(
else
kt = ktime_get_real();
- if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
+ if ((!asoc ||
+ asoc->c.my_vtag != bear_cookie->my_vtag ||
+ asoc->c.peer_vtag != bear_cookie->peer_vtag) &&
+ ktime_before(bear_cookie->expiration, kt)) {
suseconds_t usecs = ktime_to_us(ktime_sub(kt, bear_cookie->expiration));
__be32 n = htonl(usecs);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] sctp: reject stale cookies with mismatched verification tags
2026-07-23 22:56 [PATCH net] sctp: reject stale cookies with mismatched verification tags Yuxiang Yang
@ 2026-07-24 15:50 ` Xin Long
2026-07-27 22:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Xin Long @ 2026-07-24 15:50 UTC (permalink / raw)
To: Yuxiang Yang
Cc: linux-sctp, netdev, marcelo.leitner, davem, edumazet, kuba,
pabeni, horms, linux-kernel, stable, Yizhou Zhao, Ao Wang,
Xuewei Feng, Qi Li, Ke Xu, yyxroy22
On Thu, Jul 23, 2026 at 6:56 PM Yuxiang Yang
<yangyx22@mails.tsinghua.edu.cn> wrote:
>
> sctp_unpack_cookie() skips cookie expiration checks whenever an
> association already exists. This is broader than the exception in
> RFC 9260 Section 5.2.4.
>
> For an existing association, Section 5.2.4 permits an expired State
> Cookie only when both Verification Tags in the cookie match the current
> association. Otherwise, the packet SHOULD be discarded and a Stale
> Cookie ERROR MUST be sent.
>
> The broad check lets an expired Action A restart cookie reach
> sctp_sf_do_dupcook_a(). In a runtime test with the default 60 second
> cookie lifetime, replaying such a cookie after 65 seconds returned a
> COOKIE-ACK and restarted the association.
>
> Check cookie expiration unless both Verification Tags match. This
> preserves the Action D exception for a lost COOKIE ACK while rejecting
> expired cookies in all other cases.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
> ---
> net/sctp/sm_make_chunk.c | 11 +++++++----
> 1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c
> index c02809264..a1c0334a1 100644
> --- a/net/sctp/sm_make_chunk.c
> +++ b/net/sctp/sm_make_chunk.c
> @@ -1802,9 +1802,9 @@ struct sctp_association *sctp_unpack_cookie(
> goto fail;
> }
>
> - /* Check to see if the cookie is stale. If there is already
> - * an association, there is no need to check cookie's expiration
> - * for init collision case of lost COOKIE ACK.
> + /* Check to see if the cookie is stale. RFC 9260 Section 5.2.4
> + * exempts an expired cookie only when both Verification Tags match
> + * the current association.
> * If skb has been timestamped, then use the stamp, otherwise
> * use current time. This introduces a small possibility that
> * a cookie may be considered expired, but this would only slow
> @@ -1815,7 +1815,10 @@ struct sctp_association *sctp_unpack_cookie(
> else
> kt = ktime_get_real();
>
> - if (!asoc && ktime_before(bear_cookie->expiration, kt)) {
> + if ((!asoc ||
> + asoc->c.my_vtag != bear_cookie->my_vtag ||
> + asoc->c.peer_vtag != bear_cookie->peer_vtag) &&
> + ktime_before(bear_cookie->expiration, kt)) {
> suseconds_t usecs = ktime_to_us(ktime_sub(kt, bear_cookie->expiration));
> __be32 n = htonl(usecs);
>
> --
> 2.34.1
>
Acked-by: Xin Long <lucien.xin@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] sctp: reject stale cookies with mismatched verification tags
2026-07-23 22:56 [PATCH net] sctp: reject stale cookies with mismatched verification tags Yuxiang Yang
2026-07-24 15:50 ` Xin Long
@ 2026-07-27 22:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-27 22:40 UTC (permalink / raw)
To: Yuxiang Yang
Cc: linux-sctp, netdev, marcelo.leitner, lucien.xin, davem, edumazet,
kuba, pabeni, horms, linux-kernel, stable, zhaoyz24, wangao,
fengxw06, qli01, xuke, yyxroy22
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 23 Jul 2026 22:56:23 +0000 you wrote:
> sctp_unpack_cookie() skips cookie expiration checks whenever an
> association already exists. This is broader than the exception in
> RFC 9260 Section 5.2.4.
>
> For an existing association, Section 5.2.4 permits an expired State
> Cookie only when both Verification Tags in the cookie match the current
> association. Otherwise, the packet SHOULD be discarded and a Stale
> Cookie ERROR MUST be sent.
>
> [...]
Here is the summary with links:
- [net] sctp: reject stale cookies with mismatched verification tags
https://git.kernel.org/netdev/net/c/9d8da8e0a9bc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-27 22:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23 22:56 [PATCH net] sctp: reject stale cookies with mismatched verification tags Yuxiang Yang
2026-07-24 15:50 ` Xin Long
2026-07-27 22:40 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.