netfilter: allow to turn off xtables compat layer
Subsystems (3)
Florian Westphal
maintainerPATCH 1/1 netfilter: allow to turn off xtables compat layer
The compat layer needs to parse untrusted input (the ruleset) to translate it to a 64bit compatible format.
We had a number of bugs in this department in the past, so allow users to turn this feature off.
Add CONFIG_NETFILTER_XTABLES_COMPAT kconfig knob and make it default to y to keep existing behaviour.
--- include/linux/netfilter/x_tables.h | 12 ++++++------ include/linux/netfilter_arp/arp_tables.h | 2 +- include/linux/netfilter_ipv4/ip_tables.h | 2 +- include/linux/netfilter_ipv6/ip6_tables.h | 2 +- net/bridge/netfilter/ebt_limit.c | 4 ++-- net/bridge/netfilter/ebt_mark.c | 4 ++-- net/bridge/netfilter/ebt_mark_m.c | 4 ++-- net/bridge/netfilter/ebtables.c | 12 ++++++------ net/ipv4/netfilter/arp_tables.c | 16 ++++++++-------- net/ipv4/netfilter/ip_tables.c | 16 ++++++++-------- net/ipv4/netfilter/ipt_CLUSTERIP.c | 8 ++++---- net/ipv6/netfilter/ip6_tables.c | 16 ++++++++-------- net/netfilter/Kconfig | 10 ++++++++++ net/netfilter/x_tables.c | 16 ++++++++-------- net/netfilter/xt_limit.c | 6 +++--- 15 files changed, 70 insertions(+), 60 deletions(-)
include/linux/netfilter/x_tables.h +6 -6
@@ -158,7 +158,7 @@ struct xt_match {/* Called when entry of this type deleted. */ void (*destroy)(const struct xt_mtdtor_param *); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* Called when userspace align differs from kernel space one */ void (*compat_from_user)(void *dst,const void *src);int (*compat_to_user)(void __user *dst,const void *src);
@@ -169,7 +169,7 @@ struct xt_match {const char *table;unsigned int matchsize;unsigned int usersize; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT unsigned int compatsize;#endif unsigned int hooks;
@@ -199,7 +199,7 @@ struct xt_target {/* Called when entry of this type deleted. */ void (*destroy)(const struct xt_tgdtor_param *); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* Called when userspace align differs from kernel space one */ void (*compat_from_user)(void *dst,const void *src);int (*compat_to_user)(void __user *dst,const void *src);
@@ -210,7 +210,7 @@ struct xt_target {const char *table;unsigned int targetsize;unsigned int usersize; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT unsigned int compatsize;#endif unsigned int hooks;
@@ -448,7 +448,7 @@ xt_get_per_cpu_counter(struct xt_counters *cnt, unsigned int cpu)struct nf_hook_ops *xt_hook_ops_alloc (const struct xt_table *,nf_hookfn *); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT #include <net/compat.h> struct compat_xt_entry_match {
@@ -529,5 +529,5 @@ int xt_compat_check_entry_offsets(const void *base, const char *elems,unsigned int target_offset, unsigned int next_offset); -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_NETFILTER_XTABLES_COMPAT */ #endif /* _X_TABLES_H */
include/linux/netfilter_arp/arp_tables.h +1 -1
@@ -59,7 +59,7 @@ extern unsigned int arpt_do_table(struct sk_buff *skb,const struct nf_hook_state *state, struct xt_table *table); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT #include <net/compat.h> struct compat_arpt_entry {
include/linux/netfilter_ipv4/ip_tables.h +1 -1
@@ -72,7 +72,7 @@ extern unsigned int ipt_do_table(struct sk_buff *skb,const struct nf_hook_state *state, struct xt_table *table); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT #include <net/compat.h> struct compat_ipt_entry {
include/linux/netfilter_ipv6/ip6_tables.h +1 -1
@@ -36,7 +36,7 @@ extern unsigned int ip6t_do_table(struct sk_buff *skb,const struct nf_hook_state *state, struct xt_table *table); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT #include <net/compat.h> struct compat_ip6t_entry {
net/bridge/netfilter/ebt_limit.c +2 -2
@@ -87,7 +87,7 @@ static int ebt_limit_mt_check(const struct xt_mtchk_param *par) } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* * no conversion function needed -- * only avg/burst have meaningful values in userspace.
@@ -107,7 +107,7 @@ static struct xt_match ebt_limit_mt_reg __read_mostly = { .checkentry = ebt_limit_mt_check, .matchsize = sizeof(struct ebt_limit_info), .usersize = offsetof(struct ebt_limit_info , prev), -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize = sizeof(struct ebt_compat_limit_info), #endif .me = THIS_MODULE,
net/bridge/netfilter/ebt_mark.c +2 -2
@@ -53,7 +53,7 @@ static int ebt_mark_tg_check(const struct xt_tgchk_param *par)return -EINVAL ;return 0 ; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct compat_ebt_mark_t_info { compat_ulong_t mark; compat_uint_t target;
@@ -87,7 +87,7 @@ static struct xt_target ebt_mark_tg_reg __read_mostly = { .target = ebt_mark_tg, .checkentry = ebt_mark_tg_check, .targetsize =sizeof (struct ebt_mark_t_info ), -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize =sizeof (struct compat_ebt_mark_t_info ), .compat_from_user = mark_tg_compat_from_user, .compat_to_user = mark_tg_compat_to_user,
net/bridge/netfilter/ebt_mark_m.c +2 -2
@@ -37,7 +37,7 @@ static int ebt_mark_mt_check(const struct xt_mtchk_param *par) } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct compat_ebt_mark_m_info { compat_ulong_t mark, mask; uint8_t invert, bitmask;
@@ -75,7 +75,7 @@ static struct xt_match ebt_mark_mt_reg __read_mostly = { .match = ebt_mark_mt, .checkentry = ebt_mark_mt_check, .matchsize =sizeof (struct ebt_mark_m_info ), -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize =sizeof (struct compat_ebt_mark_m_info ), .compat_from_user = mark_mt_compat_from_user, .compat_to_user = mark_mt_compat_to_user,
net/bridge/netfilter/ebtables.c +6 -6
@@ -47,7 +47,7 @@ struct ebt_pernet {static unsigned int ebt_pernet_id__read_mostly ;static DEFINE_MUTEX (ebt_mutex); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT static void ebt_standard_compat_from_user (void *dst,const void *src) {int v = *(compat_int_t *)src;
@@ -73,7 +73,7 @@ static struct xt_target ebt_standard_target = { .revision = 0, .family = NFPROTO_BRIDGE, .targetsize =sizeof (int ), -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize =sizeof (compat_int_t), .compat_from_user = ebt_standard_compat_from_user, .compat_to_user = ebt_standard_compat_to_user,
@@ -1480,7 +1480,7 @@ static int copy_everything_to_user(struct ebt_table *t, void __user *user, ebt_entry_to_user, entries, tmp.entries); } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* 32 bit-userspace compatibility definitions. */ struct compat_ebt_replace { char name[EBT_TABLE_MAXNAMELEN];
@@ -2345,7 +2345,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)if (!ns_capable (net->user_ns,CAP_NET_ADMIN ))return -EPERM ; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* try real handler in case userland supplied needed padding */ if (in_compat_syscall() && ((cmd != EBT_SO_GET_INFO && cmd != EBT_SO_GET_INIT_INFO) ||
@@ -2412,7 +2412,7 @@ static int do_ebt_set_ctl(struct sock *sk, int cmd, sockptr_t arg,switch (cmd) {case EBT_SO_SET_ENTRIES : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_do_replace (net, arg, len);else
@@ -2420,7 +2420,7 @@ static int do_ebt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, ret =do_replace (net, arg, len);break ;case EBT_SO_SET_COUNTERS : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_update_counters (net, arg, len);else
net/ipv4/netfilter/arp_tables.c +8 -8
@@ -713,7 +713,7 @@ static int copy_entries_to_user(unsigned int total_size,return ret; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT static void compat_standard_from_user (void *dst,const void *src) {int v = *(compat_int_t *)src;
@@ -800,7 +800,7 @@ static int get_info(struct net *net, void __user *user, const int *len)return -EFAULT ; name[XT_TABLE_MAXNAMELEN -1 ] ='\0' ; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ())xt_compat_lock (NFPROTO_ARP );#endif
@@ -808,7 +808,7 @@ static int get_info(struct net *net, void __user *user, const int *len)if (!IS_ERR (t)) {struct arpt_getinfo info;const struct xt_table_info *private = t->private; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct xt_table_info tmp;if (in_compat_syscall ()) {
@@ -835,7 +835,7 @@ static int get_info(struct net *net, void __user *user, const int *len)module_put (t->me); }else ret =PTR_ERR (t); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ())xt_compat_unlock (NFPROTO_ARP );#endif
@@ -1044,7 +1044,7 @@ static int do_add_counters(struct net *net, sockptr_t arg, unsigned int len)return ret; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct compat_arpt_replace { char name[XT_TABLE_MAXNAMELEN]; u32 valid_hooks;
@@ -1412,7 +1412,7 @@ static int do_arpt_set_ctl(struct sock *sk, int cmd, sockptr_t arg,switch (cmd) {case ARPT_SO_SET_REPLACE : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_do_replace (sock_net (sk), arg, len);else
@@ -1444,7 +1444,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *lenbreak ;case ARPT_SO_GET_ENTRIES : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_get_entries (sock_net (sk), user, len);else
@@ -1559,7 +1559,7 @@ static struct xt_target arpt_builtin_tg[] __read_mostly = { .name = XT_STANDARD_TARGET, .targetsize = sizeof(int), .family =NFPROTO_ARP , -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize =sizeof (compat_int_t), .compat_from_user = compat_standard_from_user, .compat_to_user = compat_standard_to_user,
net/ipv4/netfilter/ip_tables.c +8 -8
@@ -868,7 +868,7 @@ copy_entries_to_user(unsigned int total_size,return ret; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT static void compat_standard_from_user (void *dst,const void *src) {int v = *(compat_int_t *)src;
@@ -957,7 +957,7 @@ static int get_info(struct net *net, void __user *user, const int *len)return -EFAULT ; name[XT_TABLE_MAXNAMELEN -1 ] ='\0' ; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ())xt_compat_lock (AF_INET );#endif
@@ -965,7 +965,7 @@ static int get_info(struct net *net, void __user *user, const int *len)if (!IS_ERR (t)) {struct ipt_getinfo info;const struct xt_table_info *private = t->private; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct xt_table_info tmp;if (in_compat_syscall ()) {
@@ -993,7 +993,7 @@ static int get_info(struct net *net, void __user *user, const int *len)module_put (t->me); }else ret =PTR_ERR (t); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ())xt_compat_unlock (AF_INET );#endif
@@ -1199,7 +1199,7 @@ do_add_counters(struct net *net, sockptr_t arg, unsigned int len)return ret; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct compat_ipt_replace { char name[XT_TABLE_MAXNAMELEN]; u32 valid_hooks;
@@ -1621,7 +1621,7 @@ do_ipt_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len)switch (cmd) {case IPT_SO_SET_REPLACE : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_do_replace (sock_net (sk), arg, len);else
@@ -1654,7 +1654,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)break ;case IPT_SO_GET_ENTRIES : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_get_entries (sock_net (sk), user, len);else
@@ -1829,7 +1829,7 @@ static struct xt_target ipt_builtin_tg[] __read_mostly = { .name = XT_STANDARD_TARGET, .targetsize = sizeof(int), .family =NFPROTO_IPV4 , -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize =sizeof (compat_int_t), .compat_from_user = compat_standard_from_user, .compat_to_user = compat_standard_to_user,
net/ipv4/netfilter/ipt_CLUSTERIP.c +4 -4
@@ -541,7 +541,7 @@ static void clusterip_tg_destroy(const struct xt_tgdtor_param *par)nf_ct_netns_put (par->net, par->family); } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct compat_ipt_clusterip_tgt_info { u_int32_t flags;
@@ -553,7 +553,7 @@ struct compat_ipt_clusterip_tgt_infou_int32_t hash_initval;compat_uptr_t config; }; -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_NETFILTER_XTABLES_COMPAT */ static struct xt_target clusterip_tg_reg__read_mostly = { .name ="CLUSTERIP" ,
@@ -563,9 +563,9 @@ static struct xt_target clusterip_tg_reg __read_mostly = { .destroy = clusterip_tg_destroy, .targetsize = sizeof(struct ipt_clusterip_tgt_info), .usersize = offsetof(struct ipt_clusterip_tgt_info , config), -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize = sizeof(struct compat_ipt_clusterip_tgt_info), -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_NETFILTER_XTABLES_COMPAT */ .me = THIS_MODULE };
net/ipv6/netfilter/ip6_tables.c +8 -8
@@ -884,7 +884,7 @@ copy_entries_to_user(unsigned int total_size,return ret; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT static void compat_standard_from_user (void *dst,const void *src) {int v = *(compat_int_t *)src;
@@ -973,7 +973,7 @@ static int get_info(struct net *net, void __user *user, const int *len)return -EFAULT ; name[XT_TABLE_MAXNAMELEN -1 ] ='\0' ; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ())xt_compat_lock (AF_INET6 );#endif
@@ -981,7 +981,7 @@ static int get_info(struct net *net, void __user *user, const int *len)if (!IS_ERR (t)) {struct ip6t_getinfo info;const struct xt_table_info *private = t->private; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct xt_table_info tmp;if (in_compat_syscall ()) {
@@ -1009,7 +1009,7 @@ static int get_info(struct net *net, void __user *user, const int *len)module_put (t->me); }else ret =PTR_ERR (t); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ())xt_compat_unlock (AF_INET6 );#endif
@@ -1215,7 +1215,7 @@ do_add_counters(struct net *net, sockptr_t arg, unsigned int len)return ret; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct compat_ip6t_replace { char name[XT_TABLE_MAXNAMELEN]; u32 valid_hooks;
@@ -1630,7 +1630,7 @@ do_ip6t_set_ctl(struct sock *sk, int cmd, sockptr_t arg, unsigned int len)switch (cmd) {case IP6T_SO_SET_REPLACE : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_do_replace (sock_net (sk), arg, len);else
@@ -1663,7 +1663,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)break ;case IP6T_SO_GET_ENTRIES : -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) ret =compat_get_entries (sock_net (sk), user, len);else
@@ -1840,7 +1840,7 @@ static struct xt_target ip6t_builtin_tg[] __read_mostly = { .name = XT_STANDARD_TARGET, .targetsize = sizeof(int), .family =NFPROTO_IPV6 , -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize =sizeof (compat_int_t), .compat_from_user = compat_standard_from_user, .compat_to_user = compat_standard_to_user,
net/netfilter/Kconfig +10 -0
@@ -728,6 +728,16 @@ config NETFILTER_XTABLES if NETFILTER_XTABLES +config NETFILTER_XTABLES_COMPAT + bool "Netfilter Xtables 32bit support" + depends on COMPAT + default y + help + This option provides a translation layer to run 32bit arp,ip(6),ebtables + binaries on 64bit kernels. + + If unsure, say N. + comment "Xtables combined modules" config NETFILTER_XT_MARK
net/netfilter/x_tables.c +8 -8
@@ -52,7 +52,7 @@ struct xt_af {struct mutex mutex;struct list_head match;struct list_head target; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct mutex compat_mutex;struct compat_delta *compat_tab;unsigned int number;/* number of slots in compat_tab[] */
@@ -647,7 +647,7 @@ static bool error_tg_ok(unsigned int usersize, unsigned int kernsize,return usersize == kernsize &&strnlen (msg, msglen) < msglen; } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT int xt_compat_add_offset (u_int8_t af,unsigned int offset,int delta) {struct xt_af *xp = &xt[af];
@@ -850,7 +850,7 @@ int xt_compat_check_entry_offsets(const void *base, const char *elems, __alignof__(struct compat_xt_entry_match)); }EXPORT_SYMBOL (xt_compat_check_entry_offsets); -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_NETFILTER_XTABLES_COMPAT */ /** * xt_check_entry_offsets - validate arp/ip/ip6t_entry
@@ -868,7 +868,7 @@ EXPORT_SYMBOL(xt_compat_check_entry_offsets);* match structures are aligned, and that the last structure ends where * the target structure begins. * -* Also see xt_compat_check_entry_offsets for CONFIG_COMPAT version. +* Also see xt_compat_check_entry_offsets for CONFIG_NETFILTER_XTABLES_COMPAT version. * * The arp/ip/ip6t_entry structure @base must have passed following tests: * - it must point to a valid memory location
@@ -1059,7 +1059,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len,void *mem;u64 size; -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT if (in_compat_syscall ()) {/* structures only differ in size due to alignment */ struct compat_xt_counters_info compat_tmp;
@@ -1106,7 +1106,7 @@ void *xt_copy_counters(sockptr_t arg, unsigned int len, }EXPORT_SYMBOL_GPL (xt_copy_counters); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT int xt_compat_target_offset (const struct xt_target *target) {u_int16_t csize = target->compatsize ? : target->targetsize;
@@ -1276,7 +1276,7 @@ void xt_table_unlock(struct xt_table *table) }EXPORT_SYMBOL_GPL (xt_table_unlock); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT void xt_compat_lock (u_int8_t af) {mutex_lock (&xt[af].compat_mutex);
@@ -1913,7 +1913,7 @@ static int __init xt_init(void)for (i =0 ; i <NFPROTO_NUMPROTO ; i++) {mutex_init (&xt[i].mutex); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT mutex_init (&xt[i].compat_mutex); xt[i].compat_tab =NULL ;#endif
net/netfilter/xt_limit.c +3 -3
@@ -134,7 +134,7 @@ static void limit_mt_destroy(const struct xt_mtdtor_param *par)kfree (info->master); } -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT struct compat_xt_rateinfo { u_int32_t avg; u_int32_t burst;
@@ -176,7 +176,7 @@ static int limit_mt_compat_to_user(void __user *dst, const void *src) };return copy_to_user (dst, &cm,sizeof (cm)) ? -EFAULT :0 ; } -#endif /* CONFIG_COMPAT */ +#endif /* CONFIG_NETFILTER_XTABLES_COMPAT */ static struct xt_match limit_mt_reg__read_mostly = { .name ="limit" ,
@@ -186,7 +186,7 @@ static struct xt_match limit_mt_reg __read_mostly = { .checkentry = limit_mt_check, .destroy = limit_mt_destroy, .matchsize =sizeof (struct xt_rateinfo ), -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT .compatsize =sizeof (struct compat_xt_rateinfo ), .compat_from_user = limit_mt_compat_from_user, .compat_to_user = limit_mt_compat_to_user,
Signature · 1 line
2.26.3
Quoted 8 lines · Florian Westphal
The compat layer needs to parse untrusted input (the ruleset) to translate it to a 64bit compatible format.
We had a number of bugs in this department in the past, so allow users to turn this feature off.
+++
b/include/linux/netfilter/x_tables.h
include/linux/netfilter/x_tables.h struct xt_match { · line 164
Quoted 8 lines
include/linux/netfilter/x_tables.h +1
-1@@ -158,7 +158,7 @@ struct xt_match {/* Called when entry of this type deleted. */ void (*destroy)(const struct xt_mtdtor_param *); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* Called when userspace align differs from kernel space one */ void (*compat_from_user)(void *dst,const void *src);int (*compat_to_user)(void __user *dst,const void *src);
There are not a lot of '\.compat_to_user' instaces anymore. It would appear we managed to throw out most of the flexing structs over the past 15 years.
Perhaps the remaining one (struct xt_rateinfo) could be respecified as a v1, with the plan to ditch the v0.
Then the entire xtables_compat code could go as well.
Pablo Neira Ayuso
maintainerQuoted 23 lines · Jan Engelhardt
Quoted 8 lines · Florian Westphal
The compat layer needs to parse untrusted input (the ruleset) to translate it to a 64bit compatible format.
We had a number of bugs in this department in the past, so allow users to turn this feature off.
+++
b/include/linux/netfilter/x_tables.hinclude/linux/netfilter/x_tables.h struct xt_match { · line 164
Quoted 8 lines
include/linux/netfilter/x_tables.h +1
-1@@ -158,7 +158,7 @@ struct xt_match {/* Called when entry of this type deleted. */ void (*destroy)(const struct xt_mtdtor_param *); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* Called when userspace align differs from kernel space one */ void (*compat_from_user)(void *dst,const void *src);int (*compat_to_user)(void __user *dst,const void *src);There are not a lot of '\.compat_to_user' instaces anymore. It would appear we managed to throw out most of the flexing structs over the past 15 years.
Quoted 4 lines
Perhaps the remaining one (struct
xt_rateinfo) could be respecified as a v1, with the plan to ditch the v0.Then the entire
xtables_compatcode could go as well.
If the remaining matches and targets that rely on this get a new revision to fix their structure layout issues, then this entire layer could be peeled off.
Florian Westphal
maintainerQuoted 24 lines · Pablo Neira Ayuso
Quoted 23 lines · Jan Engelhardt
Quoted 8 lines · Florian Westphal
The compat layer needs to parse untrusted input (the ruleset) to translate it to a 64bit compatible format.
We had a number of bugs in this department in the past, so allow users to turn this feature off.
+++
b/include/linux/netfilter/x_tables.hinclude/linux/netfilter/x_tables.h struct xt_match { · line 164
Quoted 8 lines
include/linux/netfilter/x_tables.h +1
-1@@ -158,7 +158,7 @@ struct xt_match {/* Called when entry of this type deleted. */ void (*destroy)(const struct xt_mtdtor_param *); -#ifdef CONFIG_COMPAT +#ifdef CONFIG_NETFILTER_XTABLES_COMPAT /* Called when userspace align differs from kernel space one */ void (*compat_from_user)(void *dst,const void *src);int (*compat_to_user)(void __user *dst,const void *src);There are not a lot of '\.compat_to_user' instaces anymore. It would appear we managed to throw out most of the flexing structs over the past 15 years.
Quoted 8 lines
Quoted 4 lines
Perhaps the remaining one (struct
xt_rateinfo) could be respecified as a v1, with the plan to ditch the v0.Then the entire
xtables_compatcode could go as well.If the remaining matches and targets that rely on this get a new revision to fix their structure layout issues, then this entire layer could be peeled off.
Hmm, no, because the blob format itself (match, target structures, ip(6)t_entry have different alignment requirements.
Also, ipt_get_entries has padding on x86_64 in the middle of the structure that is not there in on i686.
Even the 'compat_to_user' helpers can't be removed because they are needed by the standard target, see compat_standard_to_user()).
We could simplify things a bit though, if we only consider the matches, then ebt mark and xt_limit are the only users; at least the xt_match compat callback could be removed.
Quoted 8 lines · Florian Westphal
The compat layer needs to parse untrusted input (the ruleset) to translate it to a 64bit compatible format.
We had a number of bugs in this department in the past, so allow users to turn this feature off.
Add
CONFIG_NETFILTER_XTABLES_COMPATkconfig knob and make it default to y to keep existing behaviour.
Applied, thanks.