lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu,  1 Aug 2019 16:29:00 +0800
From:   Hangbin Liu <liuhangbin@...il.com>
To:     netdev@...r.kernel.org
Cc:     Stefano Brivio <sbrivio@...hat.com>,
        Marcelo Ricardo Leitner <mleitner@...hat.com>,
        David Ahern <dsahern@...il.com>,
        "David S . Miller" <davem@...emloft.net>,
        Hangbin Liu <liuhangbin@...il.com>
Subject: [PATCH net] ipv4/route: do not check saddr dev if iif is LOOPBACK_IFINDEX

Jianlin reported a bug that for IPv4, ip route get from src_addr would fail
if src_addr is not an address on local system.

\# ip route get 1.1.1.1 from 2.2.2.2
RTNETLINK answers: Invalid argument

While IPv6 would get the default route

\# ip -6 route get 1111::1 from 2222::2
1111::1 from 2222::2 via fe80:52:0:4982::1fe dev eth0 proto ra src \
	2620::2cf:e2ff:fe40:37 metric 1024 hoplimit 64 pref medium

Fix it by disabling the __ip_dev_find() check if iif is LOOPBACK_IFINDEX.

Reported-by: Jianlin Shi <jishi@...hat.com>
Signed-off-by: Hangbin Liu <liuhangbin@...il.com>
---
 net/ipv4/route.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 517300d587a7..1be78e8f9e3c 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2512,7 +2512,8 @@ struct rtable *ip_route_output_key_hash_rcu(struct net *net, struct flowi4 *fl4,
 			goto make_route;
 		}
 
-		if (!(fl4->flowi4_flags & FLOWI_FLAG_ANYSRC)) {
+		if (!(fl4->flowi4_flags & FLOWI_FLAG_ANYSRC) &&
+		    fl4->flowi4_iif != LOOPBACK_IFINDEX) {
 			/* It is equivalent to inet_addr_type(saddr) == RTN_LOCAL */
 			if (!__ip_dev_find(net, fl4->saddr, false))
 				goto out;
-- 
2.19.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ