* [PATCH] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled
@ 2017-04-20 9:44 Paolo Abeni
2017-04-22 11:16 ` Julian Anastasov
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2017-04-20 9:44 UTC (permalink / raw)
To: netfilter-devel
Cc: lvs-devel, Wensong Zhang, Simon Horman, Julian Anastasov, netdev
When creating a new ipvs service, ipv6 addresses are always accepted
if CONFIG_IP_VS_IPV6 is enabled. On dest creation the address family
is not explicitly checked.
This allows the user-space to configure ipvs services even if the
system is booted with ipv6.disable=1. On specific configuration, ipvs
can try to call ipv6 routing code at setup time, causing the kernel to
oops due to fib6_rules_ops being NULL.
This change addresses the issue adding a check for the ipv6
module being enabled while validating ipv6 service operations and
adding the same validation for dest operations.
According to git history, this issue is apparently present since
the introduction of ipv6 support, and the oops can be triggered
since commit 09571c7ae30865ad ("IPVS: Add function to determine
if IPv6 address is local")
Fixes: 09571c7ae30865ad ("IPVS: Add function to determine if IPv6 address is local")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
net/netfilter/ipvs/ip_vs_ctl.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 5aeb0dd..4d753be 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -3078,6 +3078,17 @@ static int ip_vs_genl_dump_services(struct sk_buff *skb,
return skb->len;
}
+static bool ip_vs_is_af_valid(int af)
+{
+ if (af == AF_INET)
+ return true;
+#ifdef CONFIG_IP_VS_IPV6
+ if (af == AF_INET6 && ipv6_mod_enabled())
+ return true;
+#endif
+ return false;
+}
+
static int ip_vs_genl_parse_service(struct netns_ipvs *ipvs,
struct ip_vs_service_user_kern *usvc,
struct nlattr *nla, int full_entry,
@@ -3104,11 +3115,7 @@ static int ip_vs_genl_parse_service(struct netns_ipvs *ipvs,
memset(usvc, 0, sizeof(*usvc));
usvc->af = nla_get_u16(nla_af);
-#ifdef CONFIG_IP_VS_IPV6
- if (usvc->af != AF_INET && usvc->af != AF_INET6)
-#else
- if (usvc->af != AF_INET)
-#endif
+ if (!ip_vs_is_af_valid(usvc->af))
return -EAFNOSUPPORT;
if (nla_fwmark) {
@@ -3610,6 +3617,11 @@ static int ip_vs_genl_set_cmd(struct sk_buff *skb, struct genl_info *info)
if (udest.af == 0)
udest.af = svc->af;
+ if (!ip_vs_is_af_valid(udest.af)) {
+ ret = -EAFNOSUPPORT;
+ goto out;
+ }
+
if (udest.af != svc->af && cmd != IPVS_CMD_DEL_DEST) {
/* The synchronization protocol is incompatible
* with mixed family services
--
2.9.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled
2017-04-20 9:44 [PATCH] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled Paolo Abeni
@ 2017-04-22 11:16 ` Julian Anastasov
2017-04-24 6:50 ` Paolo Abeni
0 siblings, 1 reply; 5+ messages in thread
From: Julian Anastasov @ 2017-04-22 11:16 UTC (permalink / raw)
To: Paolo Abeni
Cc: netfilter-devel, lvs-devel, Wensong Zhang, Simon Horman, netdev
Hello,
On Thu, 20 Apr 2017, Paolo Abeni wrote:
> When creating a new ipvs service, ipv6 addresses are always accepted
> if CONFIG_IP_VS_IPV6 is enabled. On dest creation the address family
> is not explicitly checked.
>
> This allows the user-space to configure ipvs services even if the
> system is booted with ipv6.disable=1. On specific configuration, ipvs
> can try to call ipv6 routing code at setup time, causing the kernel to
> oops due to fib6_rules_ops being NULL.
>
> This change addresses the issue adding a check for the ipv6
> module being enabled while validating ipv6 service operations and
> adding the same validation for dest operations.
>
> According to git history, this issue is apparently present since
> the introduction of ipv6 support, and the oops can be triggered
> since commit 09571c7ae30865ad ("IPVS: Add function to determine
> if IPv6 address is local")
>
> Fixes: 09571c7ae30865ad ("IPVS: Add function to determine if IPv6 address is local")
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Looks good to me but I see two places that can benefit
from such check:
- in ip_vs_genl_new_daemon() if we do not want to create IPv6 sockets
for the sync protocol in make_send_sock() and make_receive_sock().
Not sure if this can lead to crashes.
- in ip_vs_proc_sync_conn() if we do not want backup server to accept
IPv6 conns because they may be created even when dests are missing.
We may use retc = 10 there. Not fatal but may eat memory for
conns that will not be used.
Regards
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled
2017-04-22 11:16 ` Julian Anastasov
@ 2017-04-24 6:50 ` Paolo Abeni
2017-04-24 7:21 ` Julian Anastasov
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2017-04-24 6:50 UTC (permalink / raw)
To: Julian Anastasov
Cc: netfilter-devel, lvs-devel, Wensong Zhang, Simon Horman, netdev
Hi,
On Sat, 2017-04-22 at 14:16 +0300, Julian Anastasov wrote:
> On Thu, 20 Apr 2017, Paolo Abeni wrote:
>
> > When creating a new ipvs service, ipv6 addresses are always accepted
> > if CONFIG_IP_VS_IPV6 is enabled. On dest creation the address family
> > is not explicitly checked.
> >
> > This allows the user-space to configure ipvs services even if the
> > system is booted with ipv6.disable=1. On specific configuration, ipvs
> > can try to call ipv6 routing code at setup time, causing the kernel to
> > oops due to fib6_rules_ops being NULL.
> >
> > This change addresses the issue adding a check for the ipv6
> > module being enabled while validating ipv6 service operations and
> > adding the same validation for dest operations.
> >
> > According to git history, this issue is apparently present since
> > the introduction of ipv6 support, and the oops can be triggered
> > since commit 09571c7ae30865ad ("IPVS: Add function to determine
> > if IPv6 address is local")
> >
> > Fixes: 09571c7ae30865ad ("IPVS: Add function to determine if IPv6 address is local")
> > Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> Looks good to me but I see two places that can benefit
> from such check:
I'm sorry for the lag, I was delayed by other notorious issues ;-)
I'm unable to trigger any crash with the patched kernel.
> - in ip_vs_genl_new_daemon() if we do not want to create IPv6 sockets
> for the sync protocol in make_send_sock() and make_receive_sock().
> Not sure if this can lead to crashes.
This one is, AFAICS, safe, because ip_vs_genl_new_daemon() calls
start_sync_thread(), which tries to create a socket of the specified
address family before doing any real action. Such operation will fail
gracefully, and overall we will get an - expected - error to userspace.
> - in ip_vs_proc_sync_conn() if we do not want backup server to accept
> IPv6 conns because they may be created even when dests are missing.
> We may use retc = 10 there. Not fatal but may eat memory for
> conns that will not be used.
If I read the above correct correctly, even that should be safe, for
the same reason: ipv6 socket creation will fail if ipv6 is disabled.
The problem with the patched code is that it tries to resolve ipv6
addresses that are not created/validated by the kernel.
Cheers,
Paolo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled
2017-04-24 6:50 ` Paolo Abeni
@ 2017-04-24 7:21 ` Julian Anastasov
2017-04-24 9:54 ` Simon Horman
0 siblings, 1 reply; 5+ messages in thread
From: Julian Anastasov @ 2017-04-24 7:21 UTC (permalink / raw)
To: Paolo Abeni
Cc: netfilter-devel, lvs-devel, Wensong Zhang, Simon Horman, netdev
Hello,
On Mon, 24 Apr 2017, Paolo Abeni wrote:
> Hi,
>
> The problem with the patched code is that it tries to resolve ipv6
> addresses that are not created/validated by the kernel.
OK. Simon, please apply to ipvs tree.
Acked-by: Julian Anastasov <ja@ssi.bg>
Regards
--
Julian Anastasov <ja@ssi.bg>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled
2017-04-24 7:21 ` Julian Anastasov
@ 2017-04-24 9:54 ` Simon Horman
0 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2017-04-24 9:54 UTC (permalink / raw)
To: Julian Anastasov
Cc: Paolo Abeni, netfilter-devel, lvs-devel, Wensong Zhang, netdev
On Mon, Apr 24, 2017 at 10:21:30AM +0300, Julian Anastasov wrote:
>
> Hello,
>
> On Mon, 24 Apr 2017, Paolo Abeni wrote:
>
> > Hi,
> >
> > The problem with the patched code is that it tries to resolve ipv6
> > addresses that are not created/validated by the kernel.
>
> OK. Simon, please apply to ipvs tree.
>
> Acked-by: Julian Anastasov <ja@ssi.bg>
Thanks, done.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-04-24 9:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-20 9:44 [PATCH] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled Paolo Abeni
2017-04-22 11:16 ` Julian Anastasov
2017-04-24 6:50 ` Paolo Abeni
2017-04-24 7:21 ` Julian Anastasov
2017-04-24 9:54 ` Simon Horman
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).