diff options
author | Jakub Kicinski <kuba@kernel.org> | 2022-06-23 12:33:24 -0700 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2022-06-23 12:33:24 -0700 |
commit | 93817be8b62c7fa1f1bdc3e8c037a73a60026be9 (patch) | |
tree | 873c207abc783edb4ead73b2b3a8a9b105f94420 /net/ipv4/ping.c | |
parent | ccb9bc1dfa444e3541622ccfff135e83d2a569d1 (diff) | |
parent | 399bd66e219e331976fe6fa6ab81a023c0c97870 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
No conflicts.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/ipv4/ping.c')
-rw-r--r-- | net/ipv4/ping.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 3d6fc6d841b8..b83c2bd9d722 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -316,12 +316,16 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk, pr_debug("ping_check_bind_addr(sk=%p,addr=%pI4,port=%d)\n", sk, &addr->sin_addr.s_addr, ntohs(addr->sin_port)); + if (addr->sin_addr.s_addr == htonl(INADDR_ANY)) + return 0; + tb_id = l3mdev_fib_table_by_index(net, sk->sk_bound_dev_if) ? : tb_id; chk_addr_ret = inet_addr_type_table(net, addr->sin_addr.s_addr, tb_id); - if (!inet_addr_valid_or_nonlocal(net, inet_sk(sk), - addr->sin_addr.s_addr, - chk_addr_ret)) + if (chk_addr_ret == RTN_MULTICAST || + chk_addr_ret == RTN_BROADCAST || + (chk_addr_ret != RTN_LOCAL && + !inet_can_nonlocal_bind(net, isk))) return -EADDRNOTAVAIL; #if IS_ENABLED(CONFIG_IPV6) |