[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250922194819.182809-3-d-tatianin@yandex-team.ru>
Date: Mon, 22 Sep 2025 22:48:18 +0300
From: Daniil Tatianin <d-tatianin@...dex-team.ru>
To: Pablo Neira Ayuso <pablo@...filter.org>
Cc: Daniil Tatianin <d-tatianin@...dex-team.ru>,
Jozsef Kadlecsik <kadlec@...filter.org>,
Florian Westphal <fw@...len.de>,
Phil Sutter <phil@....cc>,
"David S. Miller" <davem@...emloft.net>,
David Ahern <dsahern@...nel.org>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>,
netfilter-devel@...r.kernel.org,
coreteam@...filter.org,
linux-kernel@...r.kernel.org,
netdev@...r.kernel.org
Subject: [PATCH 2/3] netfilter/x_tables: introduce a helper for freeing entry offsets
Analogous to xt_free_table_info, add a helper so that the users of
xt_alloc_entry_offsets don't have to assume the way the array was
allocated. This also allows us to cleanly change how the array is
allocated internally in the following commit.
Signed-off-by: Daniil Tatianin <d-tatianin@...dex-team.ru>
---
include/linux/netfilter/x_tables.h | 1 +
net/ipv4/netfilter/arp_tables.c | 4 ++--
net/ipv4/netfilter/ip_tables.c | 4 ++--
net/ipv6/netfilter/ip6_tables.c | 4 ++--
net/netfilter/x_tables.c | 6 ++++++
5 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h
index 77c778d84d4c..f695230eb89c 100644
--- a/include/linux/netfilter/x_tables.h
+++ b/include/linux/netfilter/x_tables.h
@@ -274,6 +274,7 @@ int xt_check_entry_offsets(const void *base, const char *elems,
int xt_check_table_hooks(const struct xt_table_info *info, unsigned int valid_hooks);
unsigned int *xt_alloc_entry_offsets(unsigned int size);
+void xt_free_entry_offsets(unsigned int *offsets);
bool xt_find_jump_offset(const unsigned int *offsets,
unsigned int target, unsigned int size);
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index 1cdd9c28ab2d..bc164c2e22b0 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -570,7 +570,7 @@ static int translate_table(struct net *net,
ret = -ELOOP;
goto out_free;
}
- kvfree(offsets);
+ xt_free_entry_offsets(offsets);
/* Finally, each sanity check must pass */
i = 0;
@@ -593,7 +593,7 @@ static int translate_table(struct net *net,
return ret;
out_free:
- kvfree(offsets);
+ xt_free_entry_offsets(offsets);
return ret;
}
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 23c8deff8095..1ffd871456e1 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -708,7 +708,7 @@ translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
ret = -ELOOP;
goto out_free;
}
- kvfree(offsets);
+ xt_free_entry_offsets(offsets);
/* Finally, each sanity check must pass */
i = 0;
@@ -731,7 +731,7 @@ translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
return ret;
out_free:
- kvfree(offsets);
+ xt_free_entry_offsets(offsets);
return ret;
}
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index d585ac3c1113..0f2999155bde 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -725,7 +725,7 @@ translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
ret = -ELOOP;
goto out_free;
}
- kvfree(offsets);
+ xt_free_entry_offsets(offsets);
/* Finally, each sanity check must pass */
i = 0;
@@ -748,7 +748,7 @@ translate_table(struct net *net, struct xt_table_info *newinfo, void *entry0,
return ret;
out_free:
- kvfree(offsets);
+ xt_free_entry_offsets(offsets);
return ret;
}
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index c98f4b05d79d..5ea95c56f3a0 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -970,6 +970,12 @@ unsigned int *xt_alloc_entry_offsets(unsigned int size)
}
EXPORT_SYMBOL(xt_alloc_entry_offsets);
+void xt_free_entry_offsets(unsigned int *offsets)
+{
+ kvfree(offsets);
+}
+EXPORT_SYMBOL(xt_free_entry_offsets);
+
/**
* xt_find_jump_offset - check if target is a valid jump offset
*
--
2.34.1
Powered by blists - more mailing lists