* [PATCH] sctp: hold shkey across socket migration
@ 2026-07-31 12:05 David Lee
2026-08-01 1:24 ` Xin Long
2026-09-23 8:04 ` Jun Yang
0 siblings, 2 replies; 6+ messages in thread
From: David Lee @ 2026-07-31 12:05 UTC (permalink / raw)
To: marcelo.leitner, lucien.xin, davem, edumazet, kuba, pabeni
Cc: David Lee, Kyle Zeng, Dominik 'Disconnect3d' Czarnota,
horms, linux-sctp, netdev, linux-kernel
sctp_sock_migrate() transfers queued DATA skbs from the old socket to
the new one. skb_orphan() invokes sctp_wfree() during that transfer and
drops the skb-owned shared-key reference.
If userspace has removed that key from the association, this can be the
final reference. The following sctp_set_owner_w() then dereferences the
freed chunk->shkey while trying to take the new owner reference.
Take a temporary shared-key reference before orphaning the skb and
release it after the new owner has taken its reference. This preserves
the selected authentication key throughout the ownership transfer.
Fixes: 1b1e0bc99474 ("sctp: add refcnt support for sh_key")
Bug found and triaged by OpenAI Security Research and
validated by Trail of Bits.
Assisted-by: Codex:gpt-5.6-sol gpt-5.5-cyber
Signed-off-by: Kyle Zeng <kylebot@openai.com>
---
Trail of Bits has a reproducer for this bug that triggers a
KASAN use-after-free and can share if needed.
net/sctp/socket.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index c7b9e325e..4a08023d5 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -147,9 +147,19 @@ static inline void sctp_set_owner_w(struct sctp_chunk *chunk)
static void sctp_clear_owner_w(struct sctp_chunk *chunk)
{
+ /* Keep the shkey alive until the new owner takes its reference. */
+ if (chunk->shkey)
+ sctp_auth_shkey_hold(chunk->shkey);
skb_orphan(chunk->skb);
}
+static void sctp_set_owner_w_migrate(struct sctp_chunk *chunk)
+{
+ sctp_set_owner_w(chunk);
+ if (chunk->shkey)
+ sctp_auth_shkey_release(chunk->shkey);
+}
+
#define traverse_and_process() \
do { \
msg = chunk->msg; \
@@ -9632,7 +9642,7 @@ static int sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
lock_sock_nested(newsk, SINGLE_DEPTH_NESTING);
sctp_for_each_tx_datachunk(assoc, true, sctp_clear_owner_w);
sctp_assoc_migrate(assoc, newsk);
- sctp_for_each_tx_datachunk(assoc, false, sctp_set_owner_w);
+ sctp_for_each_tx_datachunk(assoc, false, sctp_set_owner_w_migrate);
/* If the association on the newsk is already closed before accept()
* is called, set RCV_SHUTDOWN flag.
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] sctp: hold shkey across socket migration
2026-07-31 12:05 [PATCH] sctp: hold shkey across socket migration David Lee
@ 2026-08-01 1:24 ` Xin Long
2026-09-10 2:07 ` scott_gzh
2026-09-23 8:04 ` Jun Yang
1 sibling, 1 reply; 6+ messages in thread
From: Xin Long @ 2026-08-01 1:24 UTC (permalink / raw)
To: David Lee
Cc: marcelo.leitner, davem, edumazet, kuba, pabeni, Kyle Zeng,
Dominik 'Disconnect3d' Czarnota, horms, linux-sctp,
netdev, linux-kernel
On Fri, Jul 31, 2026 at 8:06 AM David Lee <david.lee@trailofbits.com> wrote:
>
> sctp_sock_migrate() transfers queued DATA skbs from the old socket to
> the new one. skb_orphan() invokes sctp_wfree() during that transfer and
> drops the skb-owned shared-key reference.
>
> If userspace has removed that key from the association, this can be the
> final reference. The following sctp_set_owner_w() then dereferences the
> freed chunk->shkey while trying to take the new owner reference.
>
> Take a temporary shared-key reference before orphaning the skb and
> release it after the new owner has taken its reference. This preserves
> the selected authentication key throughout the ownership transfer.
>
> Fixes: 1b1e0bc99474 ("sctp: add refcnt support for sh_key")
> Bug found and triaged by OpenAI Security Research and
> validated by Trail of Bits.
>
> Assisted-by: Codex:gpt-5.6-sol gpt-5.5-cyber
> Signed-off-by: Kyle Zeng <kylebot@openai.com>
The "Fixes: " is not together with others at the end, and the "Signed-off-by:"
for yourself is also missed:
Signed-off-by: David Lee <david.lee@trailofbits.com>
Patch looks good to me:
Acked-by: Xin Long <lucien.xin@gmail.com>
Not sure if you need to repost for fixing the tags, let's see.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sctp: hold shkey across socket migration
2026-08-01 1:24 ` Xin Long
@ 2026-09-10 2:07 ` scott_gzh
2026-09-10 13:47 ` Xin Long
0 siblings, 1 reply; 6+ messages in thread
From: scott_gzh @ 2026-09-10 2:07 UTC (permalink / raw)
To: lucien.xin
Cc: davem, david.lee, dominik.czarnota, edumazet, horms, kuba,
kylebot, linux-kernel, linux-sctp, marcelo.leitner, netdev,
pabeni
Hi Xin Long,
Is there any progress regarding this patch?
Best
Zihua GUO.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sctp: hold shkey across socket migration
2026-09-10 2:07 ` scott_gzh
@ 2026-09-10 13:47 ` Xin Long
0 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2026-09-10 13:47 UTC (permalink / raw)
To: scott_gzh
Cc: davem, david.lee, dominik.czarnota, edumazet, horms, kuba,
kylebot, linux-kernel, linux-sctp, marcelo.leitner, netdev,
pabeni
On Wed, Sep 9, 2026 at 10:08 PM <scott_gzh@163.com> wrote:
>
> Hi Xin Long,
>
> Is there any progress regarding this patch?
>
I think you need to post v2 with the tag issues addressed.
Thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sctp: hold shkey across socket migration
2026-07-31 12:05 [PATCH] sctp: hold shkey across socket migration David Lee
2026-08-01 1:24 ` Xin Long
@ 2026-09-23 8:04 ` Jun Yang
2026-09-23 12:49 ` Xin Long
1 sibling, 1 reply; 6+ messages in thread
From: Jun Yang @ 2026-09-23 8:04 UTC (permalink / raw)
To: David Lee
Cc: Jun Yang, Xin Long, Kyle Zeng, Marcelo Ricardo Leitner,
Dominik Czarnota, David S . Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, linux-sctp, netdev
Hi David and Xin,
My control-chunk migration fix [1] depends on this patch. Xin asked me
to wait for it to land so the dependent patch would apply.
Xin, would it be acceptable to send a v3 series carrying this patch as
1/2, without code changes, and my fix as 2/2? I would preserve David's
authorship, fix the tag placement noted in your review, and add my
sign-off.
David, could you provide the missing Signed-off-by requested in the
earlier review?
Thanks,
Jun
[1] https://lore.kernel.org/netdev/20260804113705.45754-1-juny24602@gmail.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] sctp: hold shkey across socket migration
2026-09-23 8:04 ` Jun Yang
@ 2026-09-23 12:49 ` Xin Long
0 siblings, 0 replies; 6+ messages in thread
From: Xin Long @ 2026-09-23 12:49 UTC (permalink / raw)
To: Jun Yang
Cc: David Lee, Kyle Zeng, Marcelo Ricardo Leitner, Dominik Czarnota,
David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Simon Horman, linux-sctp, netdev
On Wed, Sep 23, 2026 at 4:04 AM Jun Yang <juny24602@gmail.com> wrote:
>
> Hi David and Xin,
>
> My control-chunk migration fix [1] depends on this patch. Xin asked me
> to wait for it to land so the dependent patch would apply.
>
> Xin, would it be acceptable to send a v3 series carrying this patch as
> 1/2, without code changes, and my fix as 2/2? I would preserve David's
> authorship, fix the tag placement noted in your review, and add my
> sign-off.
Sure, sounds good to me.
Thanks.
>
> David, could you provide the missing Signed-off-by requested in the
> earlier review?
>
> Thanks,
> Jun
>
> [1] https://lore.kernel.org/netdev/20260804113705.45754-1-juny24602@gmail.com/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-23 12:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 12:05 [PATCH] sctp: hold shkey across socket migration David Lee
2026-08-01 1:24 ` Xin Long
2026-09-10 2:07 ` scott_gzh
2026-09-10 13:47 ` Xin Long
2026-09-23 8:04 ` Jun Yang
2026-09-23 12:49 ` Xin Long
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox