Blame SOURCES/0080-rule-fix-element-cache-update-in-__do_add_setelems.patch

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