Re: [PATCH net v4] sctp: fix use-after-free after association migration

From: Xin Long

Date: Tue Nov 24 2026 - 09:54:36 EST


On Thu, Nov 19, 2026 at 10:56 PM Yong Liu <pkfxxxing@xxxxxxxxx> wrote:
>
> SCTP timers and ICMP error handling can cache asoc->base.sk before
> locking it. If accept or peeloff migrates the association in between,
> processing under the old socket lock can race with an abort on the new
> socket that frees the association's queues. Transport and association
> references do not keep those queues alive. With mdelay() instrumentation
> widening the race, KASAN reported a slab-use-after-free in
> sctp_chunk_abandoned() from the T3 retransmit path.
>
> Recheck the association's socket after taking its BH lock and defer
> mismatched timer callbacks through the existing retry path. Pass the
> locked socket to the IPv4 and IPv6 ICMP handlers instead of rereading it,
> and treat a mismatch like a busy socket before processing ICMP errors.
> Skip socket error reporting after migration and check PMTU only under
> the owning socket's lock.
>
> Use READ_ONCE() for socket pointer reads in these paths and receive/backlog
> processing, including transport lookup, paired with WRITE_ONCE() in
> sctp_assoc_migrate(). Take the new socket reference before publishing it.
> The cached socket is protected by BH context and the endpoint's
> RCU-deferred sock_put().
>
> This issue was discovered by an LLM.
>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Yong Liu <pkfxxxing@xxxxxxxxx>

Acked-by: Xin Long <lucien.xin@xxxxxxxxx>