]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
espintcp: Fix race condition in espintcp_close()
authorHyunwoo Kim <imv4bel@gmail.com>
Tue, 17 Feb 2026 17:16:43 +0000 (02:16 +0900)
committerJakub Kicinski <kuba@kernel.org>
Thu, 19 Feb 2026 22:27:40 +0000 (14:27 -0800)
This issue was discovered during a code audit.

After cancel_work_sync() is called from espintcp_close(),
espintcp_tx_work() can still be scheduled from paths such as
the Delayed ACK handler or ksoftirqd.
As a result, the espintcp_tx_work() worker may dereference a
freed espintcp ctx or sk.

The following is a simple race scenario:

           cpu0                             cpu1

  espintcp_close()
    cancel_work_sync(&ctx->work);
                                     espintcp_write_space()
                                       schedule_work(&ctx->work);

To prevent this race condition, cancel_work_sync() is
replaced with disable_work_sync().

Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/aZSie7rEdh9Nu0eM@v4bel
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/xfrm/espintcp.c

index bf744ac9d5a73e04c3ff58151f305a3b4164a4b0..8709df716e98ea1a14f3fb1bc9741a513cb34ab0 100644 (file)
@@ -536,7 +536,7 @@ static void espintcp_close(struct sock *sk, long timeout)
        sk->sk_prot = &tcp_prot;
        barrier();
 
-       cancel_work_sync(&ctx->work);
+       disable_work_sync(&ctx->work);
        strp_done(&ctx->strp);
 
        skb_queue_purge(&ctx->out_queue);