netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: ipset: Add list flush to cancel_gc
@ 2024-04-17 13:51 Alexander Maltsev
  2024-04-22  8:32 ` Jozsef Kadlecsik
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Maltsev @ 2024-04-17 13:51 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Jozsef Kadlecsik, Alexander Maltsev

Flushing list in cancel_gc drops references to other lists right away,
without waiting for RCU to destroy list. Fixes race when referenced
ipsets can't be destroyed while referring list is scheduled for destroy.

Signed-off-by: Alexander Maltsev <keltar.gw@gmail.com>
---
 kernel/net/netfilter/ipset/ip_set_list_set.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/net/netfilter/ipset/ip_set_list_set.c b/kernel/net/netfilter/ipset/ip_set_list_set.c
index cc2e5b9..0d15f4f 100644
--- a/kernel/net/netfilter/ipset/ip_set_list_set.c
+++ b/kernel/net/netfilter/ipset/ip_set_list_set.c
@@ -552,6 +552,9 @@ list_set_cancel_gc(struct ip_set *set)
 
 	if (SET_WITH_TIMEOUT(set))
 		timer_shutdown_sync(&map->gc);
+
+	/* Flush list to drop references to other ipsets */
+	list_set_flush(set);
 }
 
 static const struct ip_set_type_variant set_variant = {
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] netfilter: ipset: Add list flush to cancel_gc
  2024-04-17 13:51 [PATCH] netfilter: ipset: Add list flush to cancel_gc Alexander Maltsev
@ 2024-04-22  8:32 ` Jozsef Kadlecsik
  0 siblings, 0 replies; 2+ messages in thread
From: Jozsef Kadlecsik @ 2024-04-22  8:32 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Alexander Maltsev; +Cc: netfilter-devel

On Wed, 17 Apr 2024, Alexander Maltsev wrote:

> Flushing list in cancel_gc drops references to other lists right away,
> without waiting for RCU to destroy list. Fixes race when referenced
> ipsets can't be destroyed while referring list is scheduled for destroy.
> 
> Signed-off-by: Alexander Maltsev <keltar.gw@gmail.com>
> ---
>  kernel/net/netfilter/ipset/ip_set_list_set.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/kernel/net/netfilter/ipset/ip_set_list_set.c b/kernel/net/netfilter/ipset/ip_set_list_set.c
> index cc2e5b9..0d15f4f 100644
> --- a/kernel/net/netfilter/ipset/ip_set_list_set.c
> +++ b/kernel/net/netfilter/ipset/ip_set_list_set.c
> @@ -552,6 +552,9 @@ list_set_cancel_gc(struct ip_set *set)
>  
>  	if (SET_WITH_TIMEOUT(set))
>  		timer_shutdown_sync(&map->gc);
> +
> +	/* Flush list to drop references to other ipsets */
> +	list_set_flush(set);
>  }
>  
>  static const struct ip_set_type_variant set_variant = {

Looks good, Pablo please apply to the nf-next tree. Thanks!

Acked-by: Jozsef Kadlecsik <kadlec@netfilter.org>

Best regards,
Jozsef
-- 
E-mail  : kadlec@blackhole.kfki.hu, kadlecsik.jozsef@wigner.hu
PGP key : https://wigner.hu/~kadlec/pgp_public_key.txt
Address : Wigner Research Centre for Physics
          H-1525 Budapest 114, POB. 49, Hungary

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-22  8:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-17 13:51 [PATCH] netfilter: ipset: Add list flush to cancel_gc Alexander Maltsev
2024-04-22  8:32 ` Jozsef Kadlecsik

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).