]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netfilter: nft_last: copy content when cloning expression
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 28 Feb 2023 16:09:03 +0000 (17:09 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2023 07:50:23 +0000 (08:50 +0100)
[ Upstream commit dafd11ef0024bc86de9f1269c02999d3deadf207 ]

If the ruleset contains last timestamps, restore them accordingly.
Otherwise, listing after restoration shows never used items.

Fixes: c3ddef9edc13 ("netfilter: nft_last: move stateful fields out of expression data")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/netfilter/nft_last.c

index bb15a55dad5c018a0b18876e72c11d1d12b9e80c..eaa54964cf23ce5674cc2fdc83fd7f6d5aa2a89c 100644 (file)
@@ -104,11 +104,15 @@ static void nft_last_destroy(const struct nft_ctx *ctx,
 static int nft_last_clone(struct nft_expr *dst, const struct nft_expr *src)
 {
        struct nft_last_priv *priv_dst = nft_expr_priv(dst);
+       struct nft_last_priv *priv_src = nft_expr_priv(src);
 
        priv_dst->last = kzalloc(sizeof(*priv_dst->last), GFP_ATOMIC);
        if (!priv_dst->last)
                return -ENOMEM;
 
+       priv_dst->last->set = priv_src->last->set;
+       priv_dst->last->jiffies = priv_src->last->jiffies;
+
        return 0;
 }