Skip to content

Commit e1512c1

Browse files
V4belkuba-moo
authored andcommitted
espintcp: Fix race condition in espintcp_close()
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: e27cca9 ("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>
1 parent f891007 commit e1512c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

net/xfrm/espintcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static void espintcp_close(struct sock *sk, long timeout)
536536
sk->sk_prot = &tcp_prot;
537537
barrier();
538538

539-
cancel_work_sync(&ctx->work);
539+
disable_work_sync(&ctx->work);
540540
strp_done(&ctx->strp);
541541

542542
skb_queue_purge(&ctx->out_queue);

0 commit comments

Comments
 (0)