From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Nicolas Dichtel <nicolas.dichtel@6wind.com>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH 4.9 18/19] ping: fix address binding wrt vrf
Date: Mon, 16 May 2022 21:36:31 +0200 [thread overview]
Message-ID: <20220516193614.041243621@linuxfoundation.org> (raw)
In-Reply-To: <20220516193613.497233635@linuxfoundation.org>
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
commit e1a7ac6f3ba6e157adcd0ca94d92a401f1943f56 upstream.
When ping_group_range is updated, 'ping' uses the DGRAM ICMP socket,
instead of an IP raw socket. In this case, 'ping' is unable to bind its
socket to a local address owned by a vrflite.
Before the patch:
$ sysctl -w net.ipv4.ping_group_range='0 2147483647'
$ ip link add blue type vrf table 10
$ ip link add foo type dummy
$ ip link set foo master blue
$ ip link set foo up
$ ip addr add 192.168.1.1/24 dev foo
$ ip addr add 2001::1/64 dev foo
$ ip vrf exec blue ping -c1 -I 192.168.1.1 192.168.1.2
ping: bind: Cannot assign requested address
$ ip vrf exec blue ping6 -c1 -I 2001::1 2001::2
ping6: bind icmp socket: Cannot assign requested address
CC: stable@vger.kernel.org
Fixes: 1b69c6d0ae90 ("net: Introduce L3 Master device abstraction")
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/ipv4/ping.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
--- a/net/ipv4/ping.c
+++ b/net/ipv4/ping.c
@@ -302,6 +302,7 @@ static int ping_check_bind_addr(struct s
struct net *net = sock_net(sk);
if (sk->sk_family == AF_INET) {
struct sockaddr_in *addr = (struct sockaddr_in *) uaddr;
+ u32 tb_id = RT_TABLE_LOCAL;
int chk_addr_ret;
if (addr_len < sizeof(*addr))
@@ -315,7 +316,8 @@ static int ping_check_bind_addr(struct s
pr_debug("ping_check_bind_addr(sk=%p,addr=%pI4,port=%d)\n",
sk, &addr->sin_addr.s_addr, ntohs(addr->sin_port));
- chk_addr_ret = inet_addr_type(net, addr->sin_addr.s_addr);
+ 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 (addr->sin_addr.s_addr == htonl(INADDR_ANY))
chk_addr_ret = RTN_LOCAL;
@@ -355,6 +357,14 @@ static int ping_check_bind_addr(struct s
if (!dev) {
rcu_read_unlock();
return -ENODEV;
+ }
+ }
+
+ if (!dev && sk->sk_bound_dev_if) {
+ dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
+ if (!dev) {
+ rcu_read_unlock();
+ return -ENODEV;
}
}
has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
next prev parent reply other threads:[~2022-05-16 19:39 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-16 19:36 [PATCH 4.9 00/19] 4.9.315-rc1 review Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 01/19] net: Fix features skip in for_each_netdev_feature() Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 02/19] ipv4: drop dst in multicast routing path Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 03/19] netlink: do not reset transport header in netlink_recvmsg() Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 04/19] mac80211_hwsim: call ieee80211_tx_prepare_skb under RCU protection Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 05/19] s390/ctcm: fix variable dereferenced before check Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 06/19] s390/ctcm: fix potential memory leak Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 07/19] s390/lcs: fix variable dereferenced before check Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 08/19] net: sfc: ef10: fix memory leak in efx_ef10_mtd_probe() Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 09/19] hwmon: (f71882fg) Fix negative temperature Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 10/19] ASoC: max98090: Reject invalid values in custom control put() Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 11/19] ASoC: max98090: Generate notifications on changes for custom control Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 12/19] ASoC: ops: Validate input values in snd_soc_put_volsw_range() Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 13/19] usb: cdc-wdm: fix reading stuck on device close Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 14/19] USB: serial: pl2303: add device id for HP LM930 Display Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 15/19] USB: serial: qcserial: add support for Sierra Wireless EM7590 Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 16/19] USB: serial: option: add Fibocom L610 modem Greg Kroah-Hartman
2022-05-16 19:36 ` [PATCH 4.9 17/19] USB: serial: option: add Fibocom MA510 modem Greg Kroah-Hartman
2022-05-16 19:36 ` Greg Kroah-Hartman [this message]
2022-05-16 19:36 ` [PATCH 4.9 19/19] tty/serial: digicolor: fix possible null-ptr-deref in digicolor_uart_probe() Greg Kroah-Hartman
2022-05-17 3:09 ` [PATCH 4.9 00/19] 4.9.315-rc1 review Florian Fainelli
2022-05-17 4:10 ` Shuah Khan
2022-05-17 19:29 ` Guenter Roeck
2022-05-17 21:03 ` Pavel Machek
2022-05-18 8:46 ` Naresh Kamboju
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220516193614.041243621@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=dsahern@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolas.dichtel@6wind.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox