All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Brian Witte <brianwitte@mailfence.com>
Cc: netfilter-devel@vger.kernel.org, pablo@netfilter.org,
	kadlec@blackhole.kfki.hu,
	syzbot+ff16b505ec9152e5f448@syzkaller.appspotmail.com
Subject: Re: [PATCH v2 nf-next] netfilter: nf_tables: use dedicated spinlock for reset operations
Date: Sun, 1 Feb 2026 14:20:20 +0100	[thread overview]
Message-ID: <aX9TFNlIzLU9J99z@strlen.de> (raw)
In-Reply-To: <20260201062517.263087-1-brianwitte@mailfence.com>

Brian Witte <brianwitte@mailfence.com> wrote:
> Replace commit_mutex with a dedicated reset_lock spinlock for reset
> operations. This fixes a circular locking dependency between
> commit_mutex, nfnl_subsys_ipset, and nlk_cb_mutex-NETFILTER when nft
> reset, ipset list, and iptables-nft with set match run concurrently:
> 
>   CPU0 (nft reset):        nlk_cb_mutex -> commit_mutex
>   CPU1 (ipset list):       nfnl_subsys_ipset -> nlk_cb_mutex
>   CPU2 (iptables -m set):  commit_mutex -> nfnl_subsys_ipset
> 
> Using a spinlock instead of a mutex means we stay in the RCU read-side
> critical section throughout, eliminating the try_module_get/module_put
> and rcu_read_unlock/rcu_read_lock dance that was needed to handle the
> sleeping mutex.
> 
> Reported-by: syzbot+ff16b505ec9152e5f448@syzkaller.appspotmail.com
> Fixes: https://syzkaller.appspot.com/bug?extid=ff16b505ec9152e5f448

'Fixes' tag should point at the commit adding the bug.

Fixes: bd662c4218f9 netfilter: nf_tables: Add locking for NFT_MSG_GETOBJ_RESET requests
Fixes: 3d483faa6663 netfilter: nf_tables: Add locking for NFT_MSG_GETSETELEM_RESET requests
Fixes: 3cb03edb4de3 netfilter: nf_tables: Add locking for NFT_MSG_GETRULE_RESET requests

No need to resend, I can mangle this locally.

> -	mutex_lock(&nft_net->commit_mutex);
> +	spin_lock(&nft_net->reset_lock);
>  	ret = nf_tables_dump_rules(skb, cb);
> -	mutex_unlock(&nft_net->commit_mutex);
> +	spin_unlock(&nft_net->reset_lock);

I *think* its fine, because concurrent resets make no sense.

In case we get reports wrt. long spin time the lock/unlock
pairs will have to be pushed down, like in the previous version.

  reply	other threads:[~2026-02-01 13:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-01  6:25 [PATCH v2 nf-next] netfilter: nf_tables: use dedicated spinlock for reset operations Brian Witte
2026-02-01 13:20 ` Florian Westphal [this message]
2026-02-01 14:20   ` Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aX9TFNlIzLU9J99z@strlen.de \
    --to=fw@strlen.de \
    --cc=brianwitte@mailfence.com \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=syzbot+ff16b505ec9152e5f448@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.