netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jozsef Kadlecsik <kadlec@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
	Linkui Xiao <xiaolinkui@kylinos.cn>,
	Florian Westphal <fw@strlen.de>
Subject: [PATCH 0/1] ipset patch to fix race condition between swap/destroy and add/del/test, v3
Date: Mon, 13 Nov 2023 21:13:22 +0100	[thread overview]
Message-ID: <20231113201323.1747378-1-kadlec@netfilter.org> (raw)

Hi Pablo,

[Resend: sorry, patch subject was not updated properly.]

Please apply the next patch to your nf tree, which fixes a race condition:

* There's a race between a fast swap/destroy and a slow kernel side add/del/test element
  operation in ipset. The attached patch fixes it by forcing ip_set_swap() to wait for
  all readers to finish accessing the old set pointers.
  v2: synchronize_rcu() is moved into ip_set_swap() in order not to burden
      ip_set_destroy() unnecessarily when all sets are destroyed.
  v3: Florian Westphal pointed out that all netfilter hooks run with rcu_read_lock() held
      and em_ipset.c wraps the entire ip_set_test() in rcu read lock/unlock pair
      So there's no need to extend the rcu read locked area in ipset itse

Thanks!
Jozsef

The following changes since commit 7153a404fb70d21097af3169354e1e5fda3fbb02:

  Merge tag 'nf-23-09-06' of https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf (2023-09-07 11:47:15 +0200)

are available in the Git repository at:

  git://blackhole.kfki.hu/nf 2c9d59f0074ade

for you to fetch changes up to 2c9d59f0074ade26f2324209383d3699ad1790be:

  netfilter: ipset: fix race condition between swap/destroy and kernel side add/del/test, v3 (2023-11-13 21:10:42 +0100)

----------------------------------------------------------------
Jozsef Kadlecsik (1):
      netfilter: ipset: fix race condition between swap/destroy and kernel side add/del/test, v3

 net/netfilter/ipset/ip_set_core.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

             reply	other threads:[~2023-11-13 20:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 20:13 Jozsef Kadlecsik [this message]
2023-11-13 20:13 ` [PATCH 1/1] netfilter: ipset: fix race condition between swap/destroy and kernel side add/del/test, v3 Jozsef Kadlecsik
2023-11-14 12:28   ` Florian Westphal
  -- strict thread matches above, loose matches on Subject: below --
2023-11-13 20:09 [PATCH 0/1] ipset patch to fix race condition between swap/destroy and " Jozsef Kadlecsik

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=20231113201323.1747378-1-kadlec@netfilter.org \
    --to=kadlec@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=xiaolinkui@kylinos.cn \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).