Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3818270ybi; Mon, 29 Jul 2019 13:13:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqw84ERNwPztvtfq9uw9oGtmTGIPSdVr5FWdXVI0TwZ8DY7dEG2lMemUqPz5yT13cNcXoQNE X-Received: by 2002:a17:90a:db42:: with SMTP id u2mr114038903pjx.48.1564431203285; Mon, 29 Jul 2019 13:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431203; cv=none; d=google.com; s=arc-20160816; b=S9G2DKG0+JdgECTo0erZCJawPOetiz8QkWzFKWqSP5bljsjrcVGiaQV4NwbgPDbn87 uLbXtjPTiMQsOaIvN5ZyC9oM7/aVpWSr/nRMfRiFwMA6hqszDAzImEqVAIP2sRcjsuy6 W6DFtrtMzd4Vwc2X3rnTUu6BCpfaS1F2OWR4+sX1Top+TP9eAH1W/rw1u1b8AXm7Gi+k 7naJ0kjml2GlkjkuTB3dQ/uCzMdjjdIumMDmjptJgwbM5w8Op+bND+L2TWTlJLZ4GXkx HXnjJ3czIszDYZjlTEhM0yaIFXdu6ZsysGti2MAZBBMlvIlBjO6eX3aaCvHv6r1h395J 8CYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=l9760Izwi57cMtLmvHT/Fb6IX2ebjJr+lK/B6dudSo4=; b=iMA70G0blTwzosnVFkhQFJTJZ1tt+Zdz8sdNDow8EtNvo1d+CfpEzU0uB0maydKMaP +LBy7RSv2dSHwVXDfzWn87NDe9ngly39jOz7E+kE1xEwIfBXrz0yGb+O1tBSirmUsQcR C5+0XEo2nVB/7M3GCHZDdCyfG98hR9RnxKVb11QzqO4FBKJCiQUV4CS4uB7CQZ21jgYJ xe6bmnvS5pyWWTeMJ+TNjLeszvXYe/Y5Ts9ITTgWEs8WJhui8tRyyNsAwdxXmyTEKIEa aYws3OrsrusuJo8zhUnhnsgVf5sPBQn2v2vFM2AfKsMkqgvR3ngmHpgCzNthPKy51qk0 uwJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=D7LNUUvr; 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 p1si24586729plr.103.2019.07.29.13.13.07; Mon, 29 Jul 2019 13:13:23 -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; dkim=pass header.i=@kernel.org header.s=default header.b=D7LNUUvr; 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 S2387644AbfG2Tdh (ORCPT + 99 others); Mon, 29 Jul 2019 15:33:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:47580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730352AbfG2Td1 (ORCPT ); Mon, 29 Jul 2019 15:33:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E871D2171F; Mon, 29 Jul 2019 19:33:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428806; bh=Spq1VlnlnuzsW8NhJTaAcjbOlVC+MolHVVvuLLUYAEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D7LNUUvrF7gBoX2adgndwxTtrrEH8BIYOQjbC2SpuQf+FKXT4NH6sLv8S8vwCAoIn D+RNbWPwlelmPg3iyw/BLiam2pHh9fT/BXQ+YPovGXjkuwz+UCdrlbA0WXm8LTkKvh D7KM06qlVrUIeoyU1sxgWE/ZMpsphWh4VTZlzBTw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matteo Croce , David Ahern , "David S. Miller" Subject: [PATCH 4.14 185/293] ipv4: dont set IPv6 only flags to IPv4 addresses Date: Mon, 29 Jul 2019 21:21:16 +0200 Message-Id: <20190729190838.662412124@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matteo Croce [ Upstream commit 2e60546368165c2449564d71f6005dda9205b5fb ] Avoid the situation where an IPV6 only flag is applied to an IPv4 address: # ip addr add 192.0.2.1/24 dev dummy0 nodad home mngtmpaddr noprefixroute # ip -4 addr show dev dummy0 2: dummy0: mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000 inet 192.0.2.1/24 scope global noprefixroute dummy0 valid_lft forever preferred_lft forever Or worse, by sending a malicious netlink command: # ip -4 addr show dev dummy0 2: dummy0: mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000 inet 192.0.2.1/24 scope global nodad optimistic dadfailed home tentative mngtmpaddr noprefixroute stable-privacy dummy0 valid_lft forever preferred_lft forever Signed-off-by: Matteo Croce Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/devinet.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c @@ -66,6 +66,11 @@ #include #include +#define IPV6ONLY_FLAGS \ + (IFA_F_NODAD | IFA_F_OPTIMISTIC | IFA_F_DADFAILED | \ + IFA_F_HOMEADDRESS | IFA_F_TENTATIVE | \ + IFA_F_MANAGETEMPADDR | IFA_F_STABLE_PRIVACY) + static struct ipv4_devconf ipv4_devconf = { .data = { [IPV4_DEVCONF_ACCEPT_REDIRECTS - 1] = 1, @@ -455,6 +460,9 @@ static int __inet_insert_ifa(struct in_i ifa->ifa_flags &= ~IFA_F_SECONDARY; last_primary = &in_dev->ifa_list; + /* Don't set IPv6 only flags to IPv4 addresses */ + ifa->ifa_flags &= ~IPV6ONLY_FLAGS; + for (ifap = &in_dev->ifa_list; (ifa1 = *ifap) != NULL; ifap = &ifa1->ifa_next) { if (!(ifa1->ifa_flags & IFA_F_SECONDARY) &&