In the Linux kernel, the following vulnerability has been resolved:
xfrm: espintcp: fix UAF during close
ZDI reported and analyzed a race condition during close for espintcp sockets:
espintcp_close() frees emsg->skb via kfree_skb() without holding
any socket lock. Concurrently, the xfrm_trans_reinject work queue
invokes esp_output_tcp_finish() -> espintcp_push_skb() ->
espintcp_push_msgs() -> skb_send_sock_locked(), which reads the
same skb as a data source.
Fix this by adding a synchronizercu() call after resetting skprot, since espoutputtcpfinish() runs under RCU and won't use a socket with skprot == &tcpprot. Simply taking the socket lock in espintcpclose() could lead to leaks, if espoutputtcp_finish() re-adds an skb in the slot we just freed. After this, the existing barrier() is no longer needed.