Skip to content

Fix for iptables-nft-restore under pressure

Phil Sutter netfilter-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4nft: cache: Fix nft_release_cache() under stressiptables/nft-cache.c+8 -25 replies
2/4nft: cache: Make nft_rebuild_cache() respect fake cacheiptables/nft-cache.c iptables/nft.h+10 -42 replies
3/4nft: cache: Simplify chain list allocationiptables/nft-cache.c+19 -270 replies
4/4nft: cache: Review flush_cache()iptables/nft-cache.c+11 -92 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [iptables PATCH 0/4] Fix for iptables-nft-restore under pressure

Using a rather simple test-case, it is possible to provoke NULL-pointer derefs in iptables-nft-restore.

Said test-case involves a rule set with a thousand custom chains in each table, a thousand rules in each builtin chain and one rule in each custom chain - details are not important though, it is enough to have reasonably large tables to cause delays.

The test script simply starts ten instances of iptables-nft-restore in background and ten instances in a loop in foreground, all reading above rule set.

Critical detail is iptables-nft-restore pushing to kernel at each COMMIT line, so nft_rebuild_cache() may run multiple times during a single restore.

The actual fix is contained in patch one. Patch two is actually a performance optimization, the behaviour it changes is not wrong per se. Patches three and four are fall-out from the first one.

Phil Sutter (4):
nft: cache: Fix nft_release_cache() under stress
nft: cache: Make nft_rebuild_cache() respect fake cache
nft: cache: Simplify chain list allocation
nft: cache: Review flush_cache()

 iptables/nft-cache.c | 87 +++++++++++++++++++++++---------------------
 iptables/nft.h       |  3 +-
 2 files changed, 48 insertions(+), 42 deletions(-)
Signature · 1 line
2.25.1