Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1034608ybi; Fri, 2 Aug 2019 08:17:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPoHrGkRnY3HWqw7F0uTsVg7FwS8Ch7Q/zLx+IwQdTI5FIHRf3dzeC5S4KHrzyyD/I1VXf X-Received: by 2002:a17:902:7686:: with SMTP id m6mr131768878pll.239.1564759021545; Fri, 02 Aug 2019 08:17:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564759021; cv=none; d=google.com; s=arc-20160816; b=c88PmLxNZarzNT2q3xqnC5s9Mly7JWTm4m09/r3HaESDjyB+/6IDWbAWE5KzJaQlCx hmvzJ9yq+aCxqkuNnH+qqhHhFbbVfIoY67pnEKCfCcowbyn2kvx+TqR87toWIDVfBE6W BhZgmo/O/yH+qZBAXMC1NmvLiRWD7jG/d3d1zKIFklqiRXQPhXJNFsdEpJ8acweiNSWd PzmFOiHBTN4zGypfyRy9KN1SRUhrNnVQzNgnwdugvEuO2Yz8Rm+v4LjtrkUTWMwzS79V ruGUuwsZJ+Sy7FYdrfJ+jpz5SgHeHrgODbVMkVT3My9kAVsyUYZcDb+oALQkegsBVhk3 XX+Q== 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=vGyopcUC4LUUbG8QKtMNpeN9MJpLvkz7dEjinPruKeE=; b=GkP9dxAOmmwWddAdZx2KIbiarm2hij4V+4GR9A7kCiYJMipUA+Z6BWdKmx2AMGqvsb E+9T808m7CiGqV6KhqixPOhVwr1iS0GPHT44/m8Ns94HMk6mgnVrHbfpwHv5S8rl/T/r jmG1dzULvpoIHu12TsvRIDOQpB6vAbpmF7Jvpfq7Ns+jo4+dCv2Fuix0YVMlOJEIw87C EFtiVI2MonkFKoUAfGrYynREXBi+0PP401Xi01AwgCdh3Qkrjr/vqquLO37RkWo6Ym/9 OIhEFc6xlGu54LgDPFO3+7dFr6lLRhpvcnDNPK0h99j7fvbXHRUz7vsN561IeDGmhs2Q K8mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SQ1GHBbU; 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 v24si213320pgn.64.2019.08.02.08.16.20; Fri, 02 Aug 2019 08:17:01 -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=SQ1GHBbU; 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 S2390522AbfHBJdo (ORCPT + 99 others); Fri, 2 Aug 2019 05:33:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:33090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390487AbfHBJdi (ORCPT ); Fri, 2 Aug 2019 05:33:38 -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 73669217D7; Fri, 2 Aug 2019 09:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738417; bh=F9f8+XQ9K6uxWrdp5WlnfE4VLwtyVaBH0OGVXCRB8DI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SQ1GHBbUyBHl5fBsBkwVnIgE07e2ORLpZSZGEy2AA0GI2yJBGFJQC6oIbpLWjdDnn nZ5DT48784YaTP1aGSJbggwvp62ajH3Q7A1hYg4Z+dtjiLXrpaxckS8qLyOd3DQZSp XtHLQRqAjyWB15X+lsjeHhjBWH7044iyrHk3XvbQ= 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.4 088/158] ipv4: dont set IPv6 only flags to IPv4 addresses Date: Fri, 2 Aug 2019 11:28:29 +0200 Message-Id: <20190802092222.217259673@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@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 @@ -67,6 +67,11 @@ #include "fib_lookup.h" +#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, @@ -453,6 +458,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) &&