From f6ad231d698c7c091371264d8d1881cbb9cf0ba1 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Sun, 19 May 2019 18:58:40 +0200 Subject: nft: keep original cache in case of ERESTART Phil Sutter says: "The problem is that data in h->obj_list potentially sits in cache, too. At least rules have to be there so insert with index works correctly. If the cache is flushed before regenerating the batch, use-after-free occurs which crashes the program." This patch keeps around the original cache until we have refreshed the batch. Fixes: 862818ac3a0de ("xtables: add and use nft_build_cache") Signed-off-by: Pablo Neira Ayuso --- iptables/nft.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'iptables/nft.h') diff --git a/iptables/nft.h b/iptables/nft.h index dc0797d3..43eb8a39 100644 --- a/iptables/nft.h +++ b/iptables/nft.h @@ -48,7 +48,8 @@ struct nft_handle { struct list_head err_list; struct nft_family_ops *ops; const struct builtin_table *tables; - struct nft_cache __cache; + unsigned int cache_index; + struct nft_cache __cache[2]; struct nft_cache *cache; bool have_cache; bool restore; -- cgit v1.2.3