xfrm: iptfs: fix use-after-free by held and queued packets
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 0 repliesNew
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | xfrm: iptfs: free held packets on SA delete to fix a netns UAFinclude/ net/ net/ +1 more | +54 | 0 replies | |
| 2/4 | xfrm: iptfs: look up the device of held packets again to fix a UAFnet/ | +21 | 0 replies | |
| 3/4 | xfrm: iptfs: free queued packets on SA delete to fix a netns UAFnet/ | +11 | 0 replies | |
| 4/4 | xfrm: iptfs: don't keep the input device of queued packets to fix a UAFnet/ | +1 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH ipsec 0/4] xfrm: iptfs: fix use-after-free by held and queued packets
IP-TFS keeps packets for later on both sides: received packets in its reorder window and reassembly buffer, and outgoing packets on its output queue until the send timer fires. A kept packet points at its device, and through its SA at its network namespace, without keeping either alive. Each side can be left holding a freed object of each kind, which gives four use-after-frees:
receive, namespace patch 1 receive, device patch 2 transmit, namespace patch 3 transmit, device patch 4
An unprivileged user can trigger all four from a user and network namespace on any kernel with CONFIG_XFRM_IPTFS; no IPsec needs to be configured, as the user creates the SA. The receive device bug gives an addition of a chosen value at a chosen kernel address, enough to gain root. On a configured IP-TFS gateway, the packets queued on transmit are forwarded traffic, which any host can send without credentials.
Packets that arrive through a vti device also keep vti's tunnel pointer in skb->cb while held; that is a separate bug in vti and is not addressed here.
2/4 was discovered by LLM-based static analysis. 1/4 was discovered while testing the patch for 2/4 on a KASAN build. The other two were discovered by more thorough static analysis after that unexpected discovery.
Reproducers: https://github.com/AgusNicco/iptfs-uafs
All 4 untrimmed KASAN reports are also in that repo.
Juan Agustin Niccolini (4):
xfrm: iptfs: free held packets on SA delete to fix a netns UAF
xfrm: iptfs: look up the device of held packets again to fix a UAF
xfrm: iptfs: free queued packets on SA delete to fix a netns UAF
xfrm: iptfs: don't keep the input device of queued packets to fix a
UAF
include/net/xfrm.h | 3 ++ net/xfrm/xfrm_iptfs.c | 83 ++++++++++++++++++++++++++++++++++++++++-- net/xfrm/xfrm_policy.c | 1 + net/xfrm/xfrm_state.c | 3 ++ 4 files changed, 87 insertions(+), 3 deletions(-)
base-commit: 1213df0bc5993e479706c5eba5830243d778f164
Signature · 1 line
2.53.0