Received: by 10.213.65.68 with SMTP id h4csp268071imn; Fri, 23 Mar 2018 04:20:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELvevsYuMXynOkE0XJGK2GaPgWla2u6YfTtmKmjWlE+wHeZEun8WGLOGcvRv4ixW36OLOa13 X-Received: by 10.99.154.18 with SMTP id o18mr21108866pge.344.1521804019883; Fri, 23 Mar 2018 04:20:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804019; cv=none; d=google.com; s=arc-20160816; b=U0cNzSHn/0faNaV/VJEzoE0GCDqaEOBY693QiwaoC1aS5omolCHh9Oe8e7icpLqgFS M8tKVY7LGs4u0+4DErfwWGCuJUY0bsd7OQMApGO0QPFpd3FydlfUh8Fw1kRjBy+VnmBM Or3vnG9UpZkd6CTUgPify7poqy/WbkFL0AZ3BLXqUm2vvRPjbp2nEWtX1Issr/QD1w0n fkXZ+8CM/na8nvYCitE/0BDfpCgC7TDiUw90LsorsdzTCSutUAH0yXLtjWFkqB0Kd4d7 HWJgOKDH4xp/3TKGQgPyktR6JNEIJpUqt7qG7gq7hUVj/KldnNKRpJ9vxL3YaR8LfXqg DyTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=1+l3JcTgKCNiV1gPaQCzKwyWyHwI/LYNhd8lRL/PQBY=; b=ZheA1p4gaj3Wal4X+Fo59JT5eMVAceBJow0Ek8mxz5XrYoabwCJWLJYfAnpjQstjkr Mdx3A35HtwpD8ykIySKxDJBwEERPJlxfh+PRGoy58oA93Y5GF8lJG12UoVIQGcvhy9Xn jbYj6YKxe7Y6mKNVbBdkeD5nk2Lx2HaLtngwpeZ+JhTyLy5NhfZB6mrlBhGXTGPWJkXh knyol9NPSlTQM6Y7aunVlDYcRkdgE2jq3ov7lzwE3x7c5Izf7EqKH+NX6GuZ4mMXdATe Db4N8dV1V4Ixz27KlDooB/veF0KzJtmiJezr6TMMv6FEEtszogV7LxWp45Bwo0DropmP 8hqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3-v6si8031209plr.192.2018.03.23.04.20.05; Fri, 23 Mar 2018 04:20:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932452AbeCWKIy (ORCPT + 99 others); Fri, 23 Mar 2018 06:08:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41842 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755655AbeCWKIv (ORCPT ); Fri, 23 Mar 2018 06:08:51 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A2015EBC; Fri, 23 Mar 2018 10:08:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , Julian Anastasov , Simon Horman , Sasha Levin Subject: [PATCH 4.9 090/177] ipvs: explicitly forbid ipv6 service/dest creation if ipv6 mod is disabled Date: Fri, 23 Mar 2018 10:53:38 +0100 Message-Id: <20180323094209.263628915@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Abeni [ Upstream commit 1442f6f7c1b77de1c508318164a527e240c24a4d ] 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 Acked-by: Julian Anastasov Signed-off-by: Simon Horman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/netfilter/ipvs/ip_vs_ctl.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c @@ -3092,6 +3092,17 @@ nla_put_failure: 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, @@ -3118,11 +3129,7 @@ static int ip_vs_genl_parse_service(stru 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) { @@ -3624,6 +3631,11 @@ static int ip_vs_genl_set_cmd(struct sk_ 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