Skip to content

xfrm: Fix device state teardown races

Jianbo Liu ipsec lkml netdev 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4xfrm: Give GC list nodes their own storageinclude/net/xfrm.h net/xfrm/xfrm_state.c+5 -60 replies
2/4xfrm: Serialize device state teardownnet/xfrm/xfrm_device.c net/xfrm/xfrm_state.c+36 -190 replies
3/4xfrm: Wait for an RCU grace period before freeing device statenet/xfrm/xfrm_state.c+3 -10 replies
4/4Revert "xfrm: serialize state GC with device state flush"net/xfrm/xfrm_state.c+0 -50 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchCarolina Jubran
1/4R-b
2/4R-b
3/4R-b
4/4R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH ipsec 0/4] xfrm: Fix device state teardown races

Three fixes for the teardown of xfrm device offload state and one revert, for ipsec.

xfrm_dev_state_free() runs for the same state from the state GC, from the device flush and from xfrm_state_find(). Commit 89fefad9f971 ("xfrm: serialize state GC with device state flush") serializes the first two with a mutex, but xfrm_state_find() runs under RCU and still races with the flush.

Let only one caller free the device state of an SA, hold a state reference in the flush and wait for an RCU grace period before the free. The mutex is not needed after that, so revert that commit.

1. xfrm: Give GC list nodes their own storage
Stop sharing the GC list nodes with the bydst and bysrc hash nodes. Patch 2 uses gclist on states that RCU readers may still walk.

2. xfrm: Serialize device state teardown
Let only one caller free the device state of an SA.

3. xfrm: Wait for an RCU grace period before freeing device state Let RCU readers of the driver state finish before the free.

4. Revert "xfrm: serialize state GC with device state flush" Remove the mutex that the fixes above make redundant.

Jianbo Liu (4):
xfrm: Give GC list nodes their own storage
xfrm: Serialize device state teardown
xfrm: Wait for an RCU grace period before freeing device state Revert "xfrm: serialize state GC with device state flush"

 include/net/xfrm.h     | 10 +++----
 net/xfrm/xfrm_device.c |  4 +--
 net/xfrm/xfrm_state.c  | 61 ++++++++++++++++++++++++++----------------
 3 files changed, 44 insertions(+), 31 deletions(-)

base-commit: b88c75488ecc768acadb14e980bbfa087b1dbf38

Signature · 1 line
2.39.3