ipv4: don't set IPv6 only flags to IPv4 addresses
Subsystems (3)
PATCH 1/1 ipv4: don't set IPv6 only flags to IPv4 addresses
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: <BROADCAST,NOARP,UP,LOWER_UP> 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 foreverOr worse, by sending a malicious netlink command:
# ip -4 addr show dev dummy0
2: dummy0: <BROADCAST,NOARP,UP,LOWER_UP> 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--- net/ipv4/devinet.c | 8 ++++++++ 1 file changed, 8 insertions(+)
net/ipv4/devinet.c +8 -0
@@ -62,6 +62,11 @@#include <net/net_namespace.h> #include <net/addrconf.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 ,
@@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh, ifa->ifa_flags &= ~IFA_F_SECONDARY ; last_primary = &in_dev->ifa_list; +/* Don't set IPv6 only flags to IPv6 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) &&
Signature · 1 line
2.21.0
Quoted 1 line · Matteo Croce
Avoid the situation where an IPV6 only flag is applied to an IPv4 address:
[]
net/ipv4/devinet.c
Quoted 1 line
net/ipv4/devinet.c +0
-0
[]
net/ipv4/devinet.c static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh, · line 476
Quoted 5 lines
net/ipv4/devinet.c +1
-0@@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh, ifa->ifa_flags &= ~IFA_F_SECONDARY ; last_primary = &in_dev->ifa_list; +/* Don't set IPv6 only flags to IPv6 addresses */
umm, IPv4 addresses?
Quoted 6 lines · Joe Perches
Quoted 1 line · Matteo Croce
Avoid the situation where an IPV6 only flag is applied to an IPv4 address:
[]
net/ipv4/devinet.c
Quoted 1 line
net/ipv4/devinet.c +0
-0[]
Quoted 9 lines
net/ipv4/devinet.c static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh, · line 476
Quoted 5 lines
net/ipv4/devinet.c +1
-0@@ -468,6 +473,9 @@ static int __inet_insert_ifa(struct in_ifaddr *ifa, struct nlmsghdr *nlh, ifa->ifa_flags &= ~IFA_F_SECONDARY ; last_primary = &in_dev->ifa_list; +/* Don't set IPv6 only flags to IPv6 addresses */ umm, IPv4 addresses?
Ouch, right.
/* Don't set IPv6 only flags to IPv4 addresses */
Can this be edidet on patchwork instead of spamming with a v2?
Signature · 2 lines
Matteo Croce per aspera ad upstream
David Miller
maintainerFrom: Matteo Croce <[email protected]>
Date: Mon, 1 Jul 2019 18:13:32 +0200
Quoted 1 line
Can this be edidet on patchwork instead of spamming with a v2?
"Spamming"?
It's never spamming, resends make my life SO much easier.