Commit 1a58f84e authored by Florian Westphal's avatar Florian Westphal Committed by Pablo Neira Ayuso

netfilter: nft_limit: fix stateful object memory leak

We need to provide a destroy callback to release the extra fields.

Fixes: 3b9e2ea6 ("netfilter: nft_limit: move stateful fields out of expression data")
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarPablo Neira Ayuso <pablo@netfilter.org>
parent 6069da44
...@@ -340,11 +340,20 @@ static int nft_limit_obj_pkts_dump(struct sk_buff *skb, ...@@ -340,11 +340,20 @@ static int nft_limit_obj_pkts_dump(struct sk_buff *skb,
return nft_limit_dump(skb, &priv->limit, NFT_LIMIT_PKTS); return nft_limit_dump(skb, &priv->limit, NFT_LIMIT_PKTS);
} }
static void nft_limit_obj_pkts_destroy(const struct nft_ctx *ctx,
struct nft_object *obj)
{
struct nft_limit_priv_pkts *priv = nft_obj_data(obj);
nft_limit_destroy(ctx, &priv->limit);
}
static struct nft_object_type nft_limit_obj_type; static struct nft_object_type nft_limit_obj_type;
static const struct nft_object_ops nft_limit_obj_pkts_ops = { static const struct nft_object_ops nft_limit_obj_pkts_ops = {
.type = &nft_limit_obj_type, .type = &nft_limit_obj_type,
.size = NFT_EXPR_SIZE(sizeof(struct nft_limit_priv_pkts)), .size = NFT_EXPR_SIZE(sizeof(struct nft_limit_priv_pkts)),
.init = nft_limit_obj_pkts_init, .init = nft_limit_obj_pkts_init,
.destroy = nft_limit_obj_pkts_destroy,
.eval = nft_limit_obj_pkts_eval, .eval = nft_limit_obj_pkts_eval,
.dump = nft_limit_obj_pkts_dump, .dump = nft_limit_obj_pkts_dump,
}; };
...@@ -378,11 +387,20 @@ static int nft_limit_obj_bytes_dump(struct sk_buff *skb, ...@@ -378,11 +387,20 @@ static int nft_limit_obj_bytes_dump(struct sk_buff *skb,
return nft_limit_dump(skb, priv, NFT_LIMIT_PKT_BYTES); return nft_limit_dump(skb, priv, NFT_LIMIT_PKT_BYTES);
} }
static void nft_limit_obj_bytes_destroy(const struct nft_ctx *ctx,
struct nft_object *obj)
{
struct nft_limit_priv *priv = nft_obj_data(obj);
nft_limit_destroy(ctx, priv);
}
static struct nft_object_type nft_limit_obj_type; static struct nft_object_type nft_limit_obj_type;
static const struct nft_object_ops nft_limit_obj_bytes_ops = { static const struct nft_object_ops nft_limit_obj_bytes_ops = {
.type = &nft_limit_obj_type, .type = &nft_limit_obj_type,
.size = sizeof(struct nft_limit_priv), .size = sizeof(struct nft_limit_priv),
.init = nft_limit_obj_bytes_init, .init = nft_limit_obj_bytes_init,
.destroy = nft_limit_obj_bytes_destroy,
.eval = nft_limit_obj_bytes_eval, .eval = nft_limit_obj_bytes_eval,
.dump = nft_limit_obj_bytes_dump, .dump = nft_limit_obj_bytes_dump,
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment