* [PATCH -stable,6.6 0/2] Netfilter fixes for -stable
@ 2024-09-17 20:24 Pablo Neira Ayuso
2024-09-17 20:24 ` [PATCH -stable,6.6 1/2] netfilter: nft_set_pipapo: walk over current view on netlink dump Pablo Neira Ayuso
2024-09-17 20:24 ` [PATCH -stable,6.6 2/2] netfilter: nf_tables: missing iterator type in lookup walk Pablo Neira Ayuso
0 siblings, 2 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2024-09-17 20:24 UTC (permalink / raw)
To: netfilter-devel; +Cc: gregkh, sashal, stable
Hi Greg, Sasha,
This batch contains a backport for fixes for 6.6-stable:
The following list shows the backported patches, I am using original commit
IDs for reference:
1) 29b359cf6d95 ("netfilter: nft_set_pipapo: walk over current view on netlink dump")
2) efefd4f00c96 ("netfilter: nf_tables: missing iterator type in lookup walk")
Please, apply,
Thanks
Pablo Neira Ayuso (2):
netfilter: nft_set_pipapo: walk over current view on netlink dump
netfilter: nf_tables: missing iterator type in lookup walk
include/net/netfilter/nf_tables.h | 13 +++++++++++++
net/netfilter/nf_tables_api.c | 5 +++++
net/netfilter/nft_lookup.c | 1 +
net/netfilter/nft_set_pipapo.c | 6 ++++--
4 files changed, 23 insertions(+), 2 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH -stable,6.6 1/2] netfilter: nft_set_pipapo: walk over current view on netlink dump
2024-09-17 20:24 [PATCH -stable,6.6 0/2] Netfilter fixes for -stable Pablo Neira Ayuso
@ 2024-09-17 20:24 ` Pablo Neira Ayuso
2024-09-17 20:24 ` [PATCH -stable,6.6 2/2] netfilter: nf_tables: missing iterator type in lookup walk Pablo Neira Ayuso
1 sibling, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2024-09-17 20:24 UTC (permalink / raw)
To: netfilter-devel; +Cc: gregkh, sashal, stable
commit 29b359cf6d95fd60730533f7f10464e95bd17c73 upstream.
The generation mask can be updated while netlink dump is in progress.
The pipapo set backend walk iterator cannot rely on it to infer what
view of the datastructure is to be used. Add notation to specify if user
wants to read/update the set.
Based on patch from Florian Westphal.
Fixes: 2b84e215f874 ("netfilter: nft_set_pipapo: .walk does not deal with generations")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/net/netfilter/nf_tables.h | 13 +++++++++++++
net/netfilter/nf_tables_api.c | 5 +++++
net/netfilter/nft_set_pipapo.c | 5 +++--
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 8af2543520b9..1b95c34a4e3d 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -297,9 +297,22 @@ struct nft_set_elem {
void *priv;
};
+/**
+ * enum nft_iter_type - nftables set iterator type
+ *
+ * @NFT_ITER_READ: read-only iteration over set elements
+ * @NFT_ITER_UPDATE: iteration under mutex to update set element state
+ */
+enum nft_iter_type {
+ NFT_ITER_UNSPEC,
+ NFT_ITER_READ,
+ NFT_ITER_UPDATE,
+};
+
struct nft_set;
struct nft_set_iter {
u8 genmask;
+ enum nft_iter_type type:8;
unsigned int count;
unsigned int skip;
int err;
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index fc99a5e91829..da5684e3fd08 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -628,6 +628,7 @@ static void nft_map_deactivate(const struct nft_ctx *ctx, struct nft_set *set)
{
struct nft_set_iter iter = {
.genmask = nft_genmask_next(ctx->net),
+ .type = NFT_ITER_UPDATE,
.fn = nft_mapelem_deactivate,
};
@@ -5392,6 +5393,7 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set,
}
iter.genmask = nft_genmask_next(ctx->net);
+ iter.type = NFT_ITER_UPDATE;
iter.skip = 0;
iter.count = 0;
iter.err = 0;
@@ -5467,6 +5469,7 @@ static void nft_map_activate(const struct nft_ctx *ctx, struct nft_set *set)
{
struct nft_set_iter iter = {
.genmask = nft_genmask_next(ctx->net),
+ .type = NFT_ITER_UPDATE,
.fn = nft_mapelem_activate,
};
@@ -5845,6 +5848,7 @@ static int nf_tables_dump_set(struct sk_buff *skb, struct netlink_callback *cb)
args.skb = skb;
args.reset = reset;
args.iter.genmask = nft_genmask_cur(net);
+ args.iter.type = NFT_ITER_READ;
args.iter.skip = cb->args[0];
args.iter.count = 0;
args.iter.err = 0;
@@ -7246,6 +7250,7 @@ static int nft_set_flush(struct nft_ctx *ctx, struct nft_set *set, u8 genmask)
{
struct nft_set_iter iter = {
.genmask = genmask,
+ .type = NFT_ITER_UPDATE,
.fn = nft_setelem_flush,
};
diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
index e4dd73093048..90f129f1a136 100644
--- a/net/netfilter/nft_set_pipapo.c
+++ b/net/netfilter/nft_set_pipapo.c
@@ -2037,13 +2037,14 @@ static void nft_pipapo_walk(const struct nft_ctx *ctx, struct nft_set *set,
struct nft_set_iter *iter)
{
struct nft_pipapo *priv = nft_set_priv(set);
- struct net *net = read_pnet(&set->net);
const struct nft_pipapo_match *m;
const struct nft_pipapo_field *f;
int i, r;
+ WARN_ON_ONCE(iter->type == NFT_ITER_UNSPEC);
+
rcu_read_lock();
- if (iter->genmask == nft_genmask_cur(net))
+ if (iter->type == NFT_ITER_READ)
m = rcu_dereference(priv->match);
else
m = priv->clone;
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH -stable,6.6 2/2] netfilter: nf_tables: missing iterator type in lookup walk
2024-09-17 20:24 [PATCH -stable,6.6 0/2] Netfilter fixes for -stable Pablo Neira Ayuso
2024-09-17 20:24 ` [PATCH -stable,6.6 1/2] netfilter: nft_set_pipapo: walk over current view on netlink dump Pablo Neira Ayuso
@ 2024-09-17 20:24 ` Pablo Neira Ayuso
1 sibling, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2024-09-17 20:24 UTC (permalink / raw)
To: netfilter-devel; +Cc: gregkh, sashal, stable
commit efefd4f00c967d00ad7abe092554ffbb70c1a793 upstream.
Add missing decorator type to lookup expression and tighten WARN_ON_ONCE
check in pipapo to spot earlier that this is unset.
Fixes: 29b359cf6d95 ("netfilter: nft_set_pipapo: walk over current view on netlink dump")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nft_lookup.c | 1 +
net/netfilter/nft_set_pipapo.c | 3 ++-
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/nft_lookup.c b/net/netfilter/nft_lookup.c
index 7ba4b1454db4..1b9edf2b3393 100644
--- a/net/netfilter/nft_lookup.c
+++ b/net/netfilter/nft_lookup.c
@@ -217,6 +217,7 @@ static int nft_lookup_validate(const struct nft_ctx *ctx,
return 0;
iter.genmask = nft_genmask_next(ctx->net);
+ iter.type = NFT_ITER_UPDATE;
iter.skip = 0;
iter.count = 0;
iter.err = 0;
diff --git a/net/netfilter/nft_set_pipapo.c b/net/netfilter/nft_set_pipapo.c
index 90f129f1a136..22407e7e0b51 100644
--- a/net/netfilter/nft_set_pipapo.c
+++ b/net/netfilter/nft_set_pipapo.c
@@ -2041,7 +2041,8 @@ static void nft_pipapo_walk(const struct nft_ctx *ctx, struct nft_set *set,
const struct nft_pipapo_field *f;
int i, r;
- WARN_ON_ONCE(iter->type == NFT_ITER_UNSPEC);
+ WARN_ON_ONCE(iter->type != NFT_ITER_READ &&
+ iter->type != NFT_ITER_UPDATE);
rcu_read_lock();
if (iter->type == NFT_ITER_READ)
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH -stable,6.6 0/2] Netfilter fixes for -stable
@ 2025-03-18 22:03 Pablo Neira Ayuso
2025-03-18 22:08 ` Pablo Neira Ayuso
0 siblings, 1 reply; 5+ messages in thread
From: Pablo Neira Ayuso @ 2025-03-18 22:03 UTC (permalink / raw)
To: netfilter-devel; +Cc: gregkh, sashal, stable
Hi Greg, Sasha,
This batch contains a backport fix for 6.6-stable.
The following list shows the backported patches, I am using original commit
IDs for reference:
1) 82cfd785c7b3 ("netfilter: nf_tables: bail out if stateful expression provides no .clone")
This is a stable dependency for the next patch.
2) 56fac3c36c8f ("netfilter: nf_tables: allow clone callbacks to sleep")
Please, apply,
Thanks
without this fix, the default set expression is silently ignored when
used from dynamic sets.
Florian Westphal (1):
netfilter: nf_tables: allow clone callbacks to sleep
Pablo Neira Ayuso (1):
netfilter: nf_tables: use timestamp to check for set element timeout
include/net/netfilter/nf_tables.h | 20 ++++++++++++++++----
net/netfilter/nf_tables_api.c | 12 +++++++-----
net/netfilter/nft_connlimit.c | 4 ++--
net/netfilter/nft_counter.c | 4 ++--
net/netfilter/nft_dynset.c | 2 +-
net/netfilter/nft_last.c | 4 ++--
net/netfilter/nft_limit.c | 14 ++++++++------
net/netfilter/nft_quota.c | 4 ++--
net/netfilter/nft_set_hash.c | 8 +++++++-
net/netfilter/nft_set_pipapo.c | 18 +++++++++++-------
net/netfilter/nft_set_rbtree.c | 11 +++++++----
11 files changed, 65 insertions(+), 36 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH -stable,6.6 0/2] Netfilter fixes for -stable
2025-03-18 22:03 [PATCH -stable,6.6 0/2] Netfilter fixes for -stable Pablo Neira Ayuso
@ 2025-03-18 22:08 ` Pablo Neira Ayuso
0 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2025-03-18 22:08 UTC (permalink / raw)
To: netfilter-devel; +Cc: gregkh, sashal, stable
On Tue, Mar 18, 2025 at 11:03:03PM +0100, Pablo Neira Ayuso wrote:
> Hi Greg, Sasha,
>
> This batch contains a backport fix for 6.6-stable.
>
> The following list shows the backported patches, I am using original commit
> IDs for reference:
>
> 1) 82cfd785c7b3 ("netfilter: nf_tables: bail out if stateful expression provides no .clone")
>
> This is a stable dependency for the next patch.
>
> 2) 56fac3c36c8f ("netfilter: nf_tables: allow clone callbacks to sleep")
I posted the wrong patches, sorry. I will resubmit again.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-18 22:08 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-17 20:24 [PATCH -stable,6.6 0/2] Netfilter fixes for -stable Pablo Neira Ayuso
2024-09-17 20:24 ` [PATCH -stable,6.6 1/2] netfilter: nft_set_pipapo: walk over current view on netlink dump Pablo Neira Ayuso
2024-09-17 20:24 ` [PATCH -stable,6.6 2/2] netfilter: nf_tables: missing iterator type in lookup walk Pablo Neira Ayuso
-- strict thread matches above, loose matches on Subject: below --
2025-03-18 22:03 [PATCH -stable,6.6 0/2] Netfilter fixes for -stable Pablo Neira Ayuso
2025-03-18 22:08 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).