Netfilter/IPVS fixes for net
Subsystems (4)
Pablo Neira Ayuso
maintainercover Netfilter/IPVS fixes for net
Hi David,
The following patchset contains Netfilter/IPVS fixes for net:
1) Missing structure initialization in ebtables causes splat with 32-bit user level on a 64-bit kernel, from Francesco Ruggeri.
2) Missing dependency on nf_defrag in IPVS IPv6 codebase, from Andrea Claudi.
3) Fix possible use-after-free from release path of target extensions.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks!
----------------------------------------------------------------
The following changes since commit cf657d22ee1f0e887326a92169f2e28dc932fd10:
net/x25: do not hold the cpu too long in x25_new_lci() (2019-02-11 13:20:14 -0800)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 753c111f655e38bbd52fc01321266633f022ebe2:
netfilter: nft_compat: use-after-free when deleting targets (2019-02-13 18:14:54 +0100)
----------------------------------------------------------------
Andrea Claudi (1):
ipvs: fix dependency on nf_defrag_ipv6
Francesco Ruggeri (1):
netfilter: compat: initialize all fields in xt_init
Pablo Neira Ayuso (1):
netfilter: nft_compat: use-after-free when deleting targets
net/netfilter/ipvs/Kconfig | 1 + net/netfilter/ipvs/ip_vs_core.c | 10 ++++------ net/netfilter/ipvs/ip_vs_ctl.c | 10 ++++++++++ net/netfilter/nft_compat.c | 3 ++- net/netfilter/x_tables.c | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/3 netfilter: compat: initialize all fields in xt_init
From: Francesco Ruggeri <[email protected]>
If a non zero value happens to be in xt[NFPROTO_BRIDGE].cur at init time, the following panic can be caused by running
% ebtables -t broute -F BROUTING
from a 32-bit user level on a 64-bit kernel. This patch replaces kmalloc_array with kcalloc when allocating xt.
[ 474.680846] BUG: unable to handle kernel paging request at 0000000009600920 [ 474.687869] PGD 2037006067 P4D 2037006067 PUD 2038938067 PMD 0 [ 474.693838] Oops: 0000 [#1] SMP [ 474.697055] CPU: 9 PID: 4662 Comm: ebtables Kdump: loaded Not tainted 4.19.17-11302235.AroraKernelnext.fc18.x86_64 #1 [ 474.707721] Hardware name: Supermicro X9DRT/X9DRT, BIOS 3.0 06/28/2013 [ 474.714313] RIP: 0010:xt_compat_calc_jump+0x2f/0x63 [x_tables] [ 474.720201] Code: 40 0f b6 ff 55 31 c0 48 6b ff 70 48 03 3d dc 45 00 00 48 89 e5 8b 4f 6c 4c 8b 47 60 ff c9 39 c8 7f 2f 8d 14 08 d1 fa 48 63 fa <41> 39 34 f8 4c 8d 0c fd 00 00 00 00 73 05 8d 42 01 eb e1 76 05 8d [ 474.739023] RSP: 0018:ffffc9000943fc58 EFLAGS: 00010207 [ 474.744296] RAX: 0000000000000000 RBX: ffffc90006465000 RCX: 0000000002580249 [ 474.751485] RDX: 00000000012c0124 RSI: fffffffff7be17e9 RDI: 00000000012c0124 [ 474.758670] RBP: ffffc9000943fc58 R08: 0000000000000000 R09: ffffffff8117cf8f [ 474.765855] R10: ffffc90006477000 R11: 0000000000000000 R12: 0000000000000001 [ 474.773048] R13: 0000000000000000 R14: ffffc9000943fcb8 R15: ffffc9000943fcb8 [ 474.780234] FS: 0000000000000000(0000) GS:ffff88a03f840000(0063) knlGS:00000000f7ac7700 [ 474.788612] CS: 0010 DS: 002b ES: 002b CR0: 0000000080050033 [ 474.794632] CR2: 0000000009600920 CR3: 0000002037422006 CR4: 00000000000606e0 [ 474.802052] Call Trace: [ 474.804789] compat_do_replace+0x1fb/0x2a3 [ebtables] [ 474.810105] compat_do_ebt_set_ctl+0x69/0xe6 [ebtables] [ 474.815605] ? try_module_get+0x37/0x42 [ 474.819716] compat_nf_setsockopt+0x4f/0x6d [ 474.824172] compat_ip_setsockopt+0x7e/0x8c [ 474.828641] compat_raw_setsockopt+0x16/0x3a [ 474.833220] compat_sock_common_setsockopt+0x1d/0x24 [ 474.838458] __compat_sys_setsockopt+0x17e/0x1b1 [ 474.843343] ? __check_object_size+0x76/0x19a [ 474.847960] __ia32_compat_sys_socketcall+0x1cb/0x25b [ 474.853276] do_fast_syscall_32+0xaf/0xf6 [ 474.857548] entry_SYSENTER_compat+0x6b/0x7a
--- net/netfilter/x_tables.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/x_tables.c +1 -1
@@ -1899,7 +1899,7 @@ static int __init xt_init(void)seqcount_init (&per_cpu (xt_recseq, i)); } - xt =kmalloc_array (NFPROTO_NUMPROTO ,sizeof (struct xt_af ),GFP_KERNEL ); + xt =kcalloc (NFPROTO_NUMPROTO ,sizeof (struct xt_af ),GFP_KERNEL );if (!xt)return -ENOMEM ;
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/3 ipvs: fix dependency on nf_defrag_ipv6
In reply to Pablo Neira AyusoFrom: Andrea Claudi <[email protected]>
ipvs relies on nf_defrag_ipv6 module to manage IPv6 fragmentation, but lacks proper Kconfig dependencies and does not explicitly request defrag features.
As a result, if netfilter hooks are not loaded, when IPv6 fragmented packet are handled by ipvs only the first fragment makes through.
Fix it properly declaring the dependency on Kconfig and registering netfilter hooks on ip_vs_add_service() and ip_vs_new_dest().
--- net/netfilter/ipvs/Kconfig | 1 + net/netfilter/ipvs/ip_vs_core.c | 10 ++++------ net/netfilter/ipvs/ip_vs_ctl.c | 10 ++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-)
net/netfilter/ipvs/Kconfig +1 -0
@@ -29,6 +29,7 @@ config IP_VS_IPV6 bool "IPv6 support for IPVS" depends on IPV6 = y || IP_VS = IPV6 select IP6_NF_IPTABLES + select NF_DEFRAG_IPV6 ---help--- Add IPv6 support to IPVS.
net/netfilter/ipvs/ip_vs_core.c +4 -6
@@ -1536,14 +1536,12 @@ ip_vs_try_to_schedule(struct netns_ipvs *ipvs, int af, struct sk_buff *skb,/* sorry, all this trouble for a no-hit :) */ IP_VS_DBG_PKT (12 , af, pp, skb, iph->off,"ip_vs_in: packet continues traversal as normal" ); -if (iph->fragoffs) { -/* Fragment that couldn't be mapped to a conn entry -* is missing module nf_defrag_ipv6 -*/ -IP_VS_DBG_RL ("Unhandled frag, load nf_defrag_ipv6\n" ); + +/* Fragment couldn't be mapped to a conn entry */ +if (iph->fragoffs)IP_VS_DBG_PKT (7 , af, pp, skb, iph->off,"unhandled fragment" ); - } + *verdict =NF_ACCEPT ;return 0 ; }
net/netfilter/ipvs/ip_vs_ctl.c +10 -0
@@ -43,6 +43,7 @@#ifdef CONFIG_IP_VS_IPV6 #include <net/ipv6.h> #include <net/ip6_route.h> +#include <net/netfilter/ipv6/nf_defrag_ipv6.h> #endif #include <net/route.h> #include <net/sock.h>
@@ -895,6 +896,7 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest, {struct ip_vs_dest *dest;unsigned int atype, i; +int ret =0 ;EnterFunction (2 );
@@ -905,6 +907,10 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest, atype & IPV6_ADDR_LINKLOCAL) && !__ip_vs_addr_is_local_v6(svc->ipvs->net, &udest->addr.in6)) return -EINVAL; + + ret =nf_defrag_ipv6_enable (svc->ipvs->net); +if (ret) +return ret; } else#endif {
@@ -1228,6 +1234,10 @@ ip_vs_add_service(struct netns_ipvs *ipvs, struct ip_vs_service_user_kern *u, ret = -EINVAL ; goto out_err; } + + ret =nf_defrag_ipv6_enable (ipvs->net); +if (ret) + goto out_err; }#endif
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 3/3 netfilter: nft_compat: use-after-free when deleting targets
In reply to Pablo Neira AyusoFetch pointer to module before target object is released.
--- net/netfilter/nft_compat.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/netfilter/nft_compat.c +2 -1
@@ -315,6 +315,7 @@ nft_target_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr) {struct xt_target *target = expr->ops->data;void *info =nft_expr_priv (expr); +struct module *me = target->me;struct xt_tgdtor_param par; par.net = ctx->net;
@@ -325,7 +326,7 @@ nft_target_destroy(const struct nft_ctx *ctx, const struct nft_expr *expr) par.target->destroy (&par); if (nft_xt_put(container_of(expr->ops, struct nft_xt, ops))) -module_put (target->me); +module_put (me); } static int nft_extension_dump_info(struct sk_buff *skb, int attr,
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Wed, 13 Feb 2019 18:47:55 +0100
Quoted 5 lines
The following patchset contains Netfilter/IPVS fixes for net:
1) Missing structure initialization in ebtables causes splat with 32-bit user level on a 64-bit kernel, from Francesco Ruggeri.
Quoted 8 lines
2) Missing dependency on
nf_defragin IPVS IPv6 codebase, from Andrea Claudi.3) Fix possible use-after-free from release path of target extensions.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Pulled, thanks Pablo.