netfilter: nf_tables: fix reset request deadlock
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v5 Latest3 patches 1 replyIn review
- v42 patches 5 repliesSuperseded
- v32 patches 1 replySuperseded
Changes in v5 from the cover letter
- Split counter and quota changes into separate patches
- counter: use global static spinlock wrapping fetch+reset atomically to prevent parallel reset underrun, instead of per-net spinlock taken too late (after fetch)
- Drop struct net from counter priv (no longer needed with global spinlock)
- quota: unchanged from v4, atomic64_xchg() for reset
Patches in v5 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | Revert nf_tables commit_mutex in reset pathnet/ | +42 | 1 reply | |
| 2/3 | netfilter: nft_counter: serialize reset with spinlocknet/ | +16 | 0 replies | |
| 3/3 | netfilter: nft_quota: use atomic64_xchg for resetnet/ | +7 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.
Cover letter [PATCH v5 nf-next 0/3] netfilter: nf_tables: fix reset request deadlock
syzbot reported a possible circular locking dependency between commit_mutex, nfnl_subsys_ipset and nlk_cb_mutex-NETFILTER:
WARNING: possible circular locking dependency detected
syz.3.970/9330 is trying to acquire lock:
ffff888012d4ccd8 (&nft_net->commit_mutex){+.+.}-{4:4}, at: nf_tables_dumpreset_obj+0x6f/0xa0
but task is already holding lock:
ffff88802bce36f0 (nlk_cb_mutex-NETFILTER){+.+.}-{4:4}, at: __netlink_dump_start+0x150/0x990
Chain exists of:
&nft_net->commit_mutex --> nfnl_subsys_ipset --> nlk_cb_mutex-NETFILTER
Possible unsafe locking scenario: CPU0 CPU1
---- ----
lock(nlk_cb_mutex-NETFILTER);
lock(nfnl_subsys_ipset);
lock(nlk_cb_mutex-NETFILTER);
lock(&nft_net->commit_mutex);The bug was introduced by commits that added commit_mutex locking to serialize reset requests.
v5:
- Split counter and quota changes into separate patches
- counter: use global static spinlock wrapping fetch+reset atomically to prevent parallel reset underrun, instead of per-net spinlock taken too late (after fetch)
- Drop struct net from counter priv (no longer needed with global spinlock)
- quota: unchanged from v4, atomic64_xchg() for reset
v4:
- Push spinlock down into nft_counter_reset() instead of holding it across entire dump iteration, per Florian's review
- Store struct net in counter priv to access the per-net spinlock during reset, avoiding skb->sk dereference which is NULL in single-element GET paths such as nft_get_set_elem
- Use atomic64_xchg() for quota reset instead of spinlock, which is simpler per Pablo's suggestion
v3:
- Restructured as 2-patch series per Florian's suggestion:
1. Revert the 3 commits that added commit_mutex locking
2. Add spinlock-based serialization for reset requests
v2:
- Switched to a spinlock in nft_pernet instead of mutex
- Spinlock doesn't sleep, so we stay in RCU read-side critical section
- Removes the try_module_get/module_put and rcu_read_unlock/lock dance
v1:
- Proposed using a dedicated reset_mutex instead of commit_mutex
Brian Witte (3):
Revert nf_tables commit_mutex in reset path
netfilter: nft_counter: serialize reset with spinlock
netfilter: nft_quota: use atomic64_xchg for reset
net/netfilter/nf_tables_api.c | 248 ++++++---------------------------- net/netfilter/nft_counter.c | 20 ++- net/netfilter/nft_quota.c | 12 +- 3 files changed, 65 insertions(+), 215 deletions(-)
Signature · 1 line
2.47.3