linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Juliusz Chroboczek" <jch@irif.fr>,
	"David Ahern" <dsahern@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 4.19 052/109] icmp: don't send out ICMP messages with a source address of 0.0.0.0
Date: Mon, 28 Jun 2021 10:32:08 -0400	[thread overview]
Message-ID: <20210628143305.32978-53-sashal@kernel.org> (raw)
In-Reply-To: <20210628143305.32978-1-sashal@kernel.org>

From: Toke Høiland-Jørgensen <toke@redhat.com>

[ Upstream commit 321827477360934dc040e9d3c626bf1de6c3ab3c ]

When constructing ICMP response messages, the kernel will try to pick a
suitable source address for the outgoing packet. However, if no IPv4
addresses are configured on the system at all, this will fail and we end up
producing an ICMP message with a source address of 0.0.0.0. This can happen
on a box routing IPv4 traffic via v6 nexthops, for instance.

Since 0.0.0.0 is not generally routable on the internet, there's a good
chance that such ICMP messages will never make it back to the sender of the
original packet that the ICMP message was sent in response to. This, in
turn, can create connectivity and PMTUd problems for senders. Fortunately,
RFC7600 reserves a dummy address to be used as a source for ICMP
messages (192.0.0.8/32), so let's teach the kernel to substitute that
address as a last resort if the regular source address selection procedure
fails.

Below is a quick example reproducing this issue with network namespaces:

ip netns add ns0
ip l add type veth peer netns ns0
ip l set dev veth0 up
ip a add 10.0.0.1/24 dev veth0
ip a add fc00:dead:cafe:42::1/64 dev veth0
ip r add 10.1.0.0/24 via inet6 fc00:dead:cafe:42::2
ip -n ns0 l set dev veth0 up
ip -n ns0 a add fc00:dead:cafe:42::2/64 dev veth0
ip -n ns0 r add 10.0.0.0/24 via inet6 fc00:dead:cafe:42::1
ip netns exec ns0 sysctl -w net.ipv4.icmp_ratelimit=0
ip netns exec ns0 sysctl -w net.ipv4.ip_forward=1
tcpdump -tpni veth0 -c 2 icmp &
ping -w 1 10.1.0.1 > /dev/null
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on veth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
IP 10.0.0.1 > 10.1.0.1: ICMP echo request, id 29, seq 1, length 64
IP 0.0.0.0 > 10.0.0.1: ICMP net 10.1.0.1 unreachable, length 92
2 packets captured
2 packets received by filter
0 packets dropped by kernel

With this patch the above capture changes to:
IP 10.0.0.1 > 10.1.0.1: ICMP echo request, id 31127, seq 1, length 64
IP 192.0.0.8 > 10.0.0.1: ICMP net 10.1.0.1 unreachable, length 92

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Reported-by: Juliusz Chroboczek <jch@irif.fr>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 include/uapi/linux/in.h | 3 +++
 net/ipv4/icmp.c         | 7 +++++++
 2 files changed, 10 insertions(+)

diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h
index 48e8a225b985..2a66ab49f14d 100644
--- a/include/uapi/linux/in.h
+++ b/include/uapi/linux/in.h
@@ -280,6 +280,9 @@ struct sockaddr_in {
 /* Address indicating an error return. */
 #define	INADDR_NONE		((unsigned long int) 0xffffffff)
 
+/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */
+#define	INADDR_DUMMY		((unsigned long int) 0xc0000008)
+
 /* Network number for local host loopback. */
 #define	IN_LOOPBACKNET		127
 
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index b048125ea099..dde6cf82e9f0 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -744,6 +744,13 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info,
 		icmp_param.data_len = room;
 	icmp_param.head_len = sizeof(struct icmphdr);
 
+	/* if we don't have a source address at this point, fall back to the
+	 * dummy address instead of sending out a packet with a source address
+	 * of 0.0.0.0
+	 */
+	if (!fl4.saddr)
+		fl4.saddr = htonl(INADDR_DUMMY);
+
 	icmp_push_reply(&icmp_param, &fl4, &ipc, &rt);
 ende:
 	ip_rt_put(rt);
-- 
2.30.2


  parent reply	other threads:[~2021-06-28 14:56 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-28 14:31 [PATCH 4.19 000/109] 4.19.196-rc1 review Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 001/109] net: ieee802154: fix null deref in parse dev addr Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 002/109] HID: quirks: Set INCREMENT_USAGE_ON_DUPLICATE for Saitek X65 Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 003/109] HID: hid-sensor-hub: Return error for hid_set_field() failure Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 004/109] HID: Add BUS_VIRTUAL to hid_connect logging Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 005/109] HID: usbhid: fix info leak in hid_submit_ctrl Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 006/109] ARM: OMAP2+: Fix build warning when mmc_omap is not built Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 007/109] gfs2: Prevent direct-I/O write fallback errors from getting lost Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 008/109] HID: gt683r: add missing MODULE_DEVICE_TABLE Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 009/109] gfs2: Fix use-after-free in gfs2_glock_shrink_scan Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 010/109] scsi: target: core: Fix warning on realtime kernels Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 011/109] ethernet: myri10ge: Fix missing error code in myri10ge_probe() Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 012/109] scsi: scsi_devinfo: Add blacklist entry for HPE OPEN-V Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 013/109] nvme-loop: reset queue count to 1 in nvme_loop_destroy_io_queues() Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 014/109] nvme-loop: clear NVME_LOOP_Q_LIVE when nvme_loop_configure_admin_queue() fails Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 015/109] nvme-loop: check for NVME_LOOP_Q_LIVE in nvme_loop_destroy_admin_queue() Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 016/109] net: ipconfig: Don't override command-line hostnames or domains Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 017/109] rtnetlink: Fix missing error code in rtnl_bridge_notify() Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 018/109] net/x25: Return the correct errno code Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 019/109] net: " Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 020/109] fib: " Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 021/109] dmaengine: ALTERA_MSGDMA depends on HAS_IOMEM Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 022/109] dmaengine: QCOM_HIDMA_MGMT " Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 023/109] dmaengine: stedma40: add missing iounmap() on error in d40_probe() Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 024/109] afs: Fix an IS_ERR() vs NULL check Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 025/109] mm/memory-failure: make sure wait for page writeback in memory_failure Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 026/109] batman-adv: Avoid WARN_ON timing related checks Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 027/109] net: ipv4: fix memory leak in netlbl_cipsov4_add_std Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 028/109] net: rds: fix memory leak in rds_recvmsg Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 029/109] udp: fix race between close() and udp_abort() Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 030/109] rtnetlink: Fix regression in bridge VLAN configuration Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 031/109] net/mlx5e: Remove dependency in IPsec initialization flows Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 032/109] net/mlx5e: Block offload of outer header csum for UDP tunnels Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 033/109] netfilter: synproxy: Fix out of bounds when parsing TCP options Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 034/109] sch_cake: Fix out of bounds when parsing TCP options and header Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 035/109] alx: Fix an error handling path in 'alx_probe()' Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 036/109] net: stmmac: dwmac1000: Fix extended MAC address registers definition Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 037/109] net: add documentation to socket.c Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 038/109] net: make get_net_ns return error if NET_NS is disabled Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 039/109] qlcnic: Fix an error handling path in 'qlcnic_probe()' Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 040/109] netxen_nic: Fix an error handling path in 'netxen_nic_probe()' Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 041/109] net: qrtr: fix OOB Read in qrtr_endpoint_post Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 042/109] ptp: ptp_clock: Publish scaled_ppm_to_ppb Sasha Levin
2021-06-28 14:31 ` [PATCH 4.19 043/109] ptp: improve max_adj check against unreasonable values Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 044/109] net: cdc_ncm: switch to eth%d interface naming Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 045/109] net: usb: fix possible use-after-free in smsc75xx_bind Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 046/109] net: fec_ptp: fix issue caused by refactor the fec_devtype Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 047/109] net: ipv4: fix memory leak in ip_mc_add1_src Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 048/109] net/af_unix: fix a data-race in unix_dgram_sendmsg / unix_release_sock Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 049/109] be2net: Fix an error handling path in 'be_probe()' Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 050/109] net: hamradio: fix memory leak in mkiss_close Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 051/109] net: cdc_eem: fix tx fixup skb leak Sasha Levin
2021-06-28 14:32 ` Sasha Levin [this message]
2021-06-28 14:32 ` [PATCH 4.19 053/109] net: ethernet: fix potential use-after-free in ec_bhf_remove Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 054/109] ASoC: rt5659: Fix the lost powers for the HDA header Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 055/109] pinctrl: ralink: rt2880: avoid to error in calls is pin is already enabled Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 056/109] radeon: use memcpy_to/fromio for UVD fw upload Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 057/109] hwmon: (scpi-hwmon) shows the negative temperature properly Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 058/109] can: bcm: fix infoleak in struct bcm_msg_head Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 059/109] can: mcba_usb: fix memory leak in mcba_usb Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 060/109] usb: core: hub: Disable autosuspend for Cypress CY7C65632 Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 061/109] tracing: Do not stop recording cmdlines when tracing is off Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 062/109] tracing: Do not stop recording comms if the trace file is being read Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 063/109] tracing: Do no increment trace_clock_global() by one Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 064/109] PCI: Mark TI C667X to avoid bus reset Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 065/109] PCI: Mark some NVIDIA GPUs " Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 066/109] PCI: Add ACS quirk for Broadcom BCM57414 NIC Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 067/109] PCI: Work around Huawei Intelligent NIC VF FLR erratum Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 068/109] ARCv2: save ABI registers across signal handling Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 069/109] dmaengine: pl330: fix wrong usage of spinlock flags in dma_cyclc Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 070/109] cfg80211: make certificate generation more robust Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 071/109] net: bridge: fix vlan tunnel dst null pointer dereference Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 072/109] net: bridge: fix vlan tunnel dst refcnt when egressing Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 073/109] mm/slub: clarify verification reporting Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 074/109] mm/slub.c: include swab.h Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 075/109] net: fec_ptp: add clock rate zero check Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 076/109] tools headers UAPI: Sync linux/in.h copy with the kernel sources Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 077/109] KVM: arm/arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST read Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 078/109] can: bcm/raw/isotp: use per module netdevice notifier Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 079/109] inet: use bigger hash table for IP ID generation Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 080/109] usb: dwc3: debugfs: Add and remove endpoint dirs dynamically Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 081/109] usb: dwc3: core: fix kernel panic when do reboot Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 082/109] x86/fpu: Reset state for all signal restore failures Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 083/109] module: limit enabling module.sig_enforce Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 084/109] drm/nouveau: wait for moving fence after pinning v2 Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 085/109] drm/radeon: wait for moving fence after pinning Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 086/109] ARM: 9081/1: fix gcc-10 thumb2-kernel regression Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 087/109] Makefile: Move -Wno-unused-but-set-variable out of GCC only block Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 088/109] MIPS: generic: Update node names to avoid unit addresses Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 089/109] Revert "PCI: PM: Do not read power state in pci_enable_device_flags()" Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 090/109] mac80211: remove warning in ieee80211_get_sband() Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 091/109] cfg80211: call cfg80211_leave_ocb when switching away from OCB Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 092/109] mac80211: drop multicast fragments Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 093/109] net: ethtool: clear heap allocations for ethtool function Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 094/109] ping: Check return value of function 'ping_queue_rcv_skb' Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 095/109] inet: annotate date races around sk->sk_txhash Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 096/109] net: caif: fix memory leak in ldisc_open Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 097/109] net/packet: annotate accesses to po->bind Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 098/109] net/packet: annotate accesses to po->ifindex Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 099/109] r8152: Avoid memcpy() over-reading of ETH_SS_STATS Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 100/109] sh_eth: " Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 101/109] r8169: " Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 102/109] KVM: selftests: Fix kvm_check_cap() assertion Sasha Levin
2021-06-28 14:32 ` [PATCH 4.19 103/109] net: qed: Fix memcpy() overflow of qed_dcbx_params() Sasha Levin
2021-06-28 14:33 ` [PATCH 4.19 104/109] PCI: Add AMD RS690 quirk to enable 64-bit DMA Sasha Levin
2021-06-28 14:33 ` [PATCH 4.19 105/109] net: ll_temac: Avoid ndo_start_xmit returning NETDEV_TX_BUSY Sasha Levin
2021-06-28 14:33 ` [PATCH 4.19 106/109] pinctrl: stm32: fix the reported number of GPIO lines per bank Sasha Levin
2021-06-28 14:33 ` [PATCH 4.19 107/109] nilfs2: fix memory leak in nilfs_sysfs_delete_device_group Sasha Levin
2021-06-28 14:33 ` [PATCH 4.19 108/109] i2c: robotfuzz-osif: fix control-request directions Sasha Levin
2021-06-28 14:33 ` [PATCH 4.19 109/109] Linux 4.19.196-rc1 Sasha Levin
2021-06-29 10:08 ` [PATCH 4.19 000/109] 4.19.196-rc1 review Naresh Kamboju
2021-06-29 12:11 ` Sudip Mukherjee
2021-06-29 18:19 ` Guenter Roeck
2021-06-30  1:00 ` Samuel Zou
2021-07-01 10:21 ` Pavel Machek

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=20210628143305.32978-53-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=jch@irif.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=toke@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).