nftables/0080-rule-fix-element-cache-update-in-__do_add_setelems.patch
2023-02-27 14:33:43 -05:00

44 lines
1.6 KiB
Diff

From 0e284af80adefc8d8738c7191eff0ca7c6ad64a6 Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Wed, 27 Apr 2022 14:46:47 +0200
Subject: [PATCH] rule: fix element cache update in __do_add_setelems()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2073287
Upstream Status: nftables commit e68938f2bf89f
commit e68938f2bf89fcc9a99e12c9b7a10c1838f2a133
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date: Thu Apr 30 16:30:15 2020 +0200
rule: fix element cache update in __do_add_setelems()
The set->init and expr arguments might actually refer to the same list
of elements. Skip set element cache update introduced by dd44081d91ce
("segtree: Fix add and delete of element in same batch") otherwise
list_splice_tail_init() actually operates with the same list as
arguments. Valgrind reports this problem as a memleak since the result
of this operation was an empty set element list.
Fixes: dd44081d91ce ("segtree: Fix add and delete of element in same batch")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/rule.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/rule.c b/src/rule.c
index b2aa1d7..9ae6d19 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -1512,7 +1512,7 @@ static int __do_add_setelems(struct netlink_ctx *ctx, struct set *set,
return -1;
if (!set_is_anonymous(set->flags) &&
- set->init != NULL &&
+ set->init != NULL && set->init != expr &&
set->flags & NFT_SET_INTERVAL &&
set->desc.field_count <= 1) {
interval_map_decompose(expr);
--
2.34.1