sctp: hold shkey across socket migration
Subsystems (3)
PATCH 1/1 sctp: hold shkey across socket migration
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.
Bug found and triaged by OpenAI Security Research and validated by Trail of Bits.
---
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(-)
net/sctp/socket.c +11 -1
@@ -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.
Signature · 1 line
2.53.0
Quoted 13 lines · David Lee
sctp_sock_migrate()transfers queued DATA skbs from the old socket to the new one.skb_orphan()invokessctp_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 freedchunk->shkeywhile 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.
Quoted 6 lines
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-cyberSigned-off-by Kyle Zeng <[email protected]>
The "Fixes: " is not together with others at the end, and the "Signed-off-by:" for yourself is also missed:
Patch looks good to me:
Not sure if you need to repost for fixing the tags, let's see.
Thanks.
Hi Xin Long,
Is there any progress regarding this patch?
Best
Zihua GUO.
Xin Long
maintainerQuoted 5 lines · On Wed, Sep 9, 2026 at 10:08 PM <[email protected]> wrote:
Hi Xin Long,
Is there any progress regarding this patch?
I think you need to post v2 with the tag issues addressed.
Thanks.
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
Xin Long
maintainerQuoted 10 lines · Jun Yang
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.
Quoted 8 lines
David, could you provide the missing Signed-off-by requested in the earlier review?
Thanks,
Jun