stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	patches@lists.linux.dev, Jonas Gorski <jonas.gorski@gmail.com>,
	Ido Schimmel <idosch@nvidia.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	David Ahern <dsahern@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.10 81/92] ipv4: Fix route deletion when nexthop info is not specified
Date: Mon,  5 Dec 2022 20:10:34 +0100	[thread overview]
Message-ID: <20221205190806.150192993@linuxfoundation.org> (raw)
In-Reply-To: <20221205190803.464934752@linuxfoundation.org>

From: Ido Schimmel <idosch@nvidia.com>

[ Upstream commit d5082d386eee7e8ec46fa8581932c81a4961dcef ]

When the kernel receives a route deletion request from user space it
tries to delete a route that matches the route attributes specified in
the request.

If only prefix information is specified in the request, the kernel
should delete the first matching FIB alias regardless of its associated
FIB info. However, an error is currently returned when the FIB info is
backed by a nexthop object:

 # ip nexthop add id 1 via 192.0.2.2 dev dummy10
 # ip route add 198.51.100.0/24 nhid 1
 # ip route del 198.51.100.0/24
 RTNETLINK answers: No such process

Fix by matching on such a FIB info when legacy nexthop attributes are
not specified in the request. An earlier check already covers the case
where a nexthop ID is specified in the request.

Add tests that cover these flows. Before the fix:

 # ./fib_nexthops.sh -t ipv4_fcnal
 ...
 TEST: Delete route when not specifying nexthop attributes           [FAIL]

 Tests passed:  11
 Tests failed:   1

After the fix:

 # ./fib_nexthops.sh -t ipv4_fcnal
 ...
 TEST: Delete route when not specifying nexthop attributes           [ OK ]

 Tests passed:  12
 Tests failed:   0

No regressions in other tests:

 # ./fib_nexthops.sh
 ...
 Tests passed: 228
 Tests failed:   0

 # ./fib_tests.sh
 ...
 Tests passed: 186
 Tests failed:   0

Cc: stable@vger.kernel.org
Reported-by: Jonas Gorski <jonas.gorski@gmail.com>
Tested-by: Jonas Gorski <jonas.gorski@gmail.com>
Fixes: 493ced1ac47c ("ipv4: Allow routes to use nexthop objects")
Fixes: 6bf92d70e690 ("net: ipv4: fix route with nexthop object delete warning")
Fixes: 61b91eb33a69 ("ipv4: Handle attempt to delete multipath route when fib_info contains an nh reference")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Nikolay Aleksandrov <razor@blackwall.org>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20221124210932.2470010-1-idosch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/ipv4/fib_semantics.c                    |  8 +++++---
 tools/testing/selftests/net/fib_nexthops.sh | 11 +++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index f62b1739f63b..52ec0c43e6b8 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -887,9 +887,11 @@ int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
 		return 1;
 	}
 
-	/* cannot match on nexthop object attributes */
-	if (fi->nh)
-		return 1;
+	if (fi->nh) {
+		if (cfg->fc_oif || cfg->fc_gw_family || cfg->fc_mp)
+			return 1;
+		return 0;
+	}
 
 	if (cfg->fc_oif || cfg->fc_gw_family) {
 		struct fib_nh *nh;
diff --git a/tools/testing/selftests/net/fib_nexthops.sh b/tools/testing/selftests/net/fib_nexthops.sh
index 050c1e0f1b0f..7ece4131dc6f 100755
--- a/tools/testing/selftests/net/fib_nexthops.sh
+++ b/tools/testing/selftests/net/fib_nexthops.sh
@@ -950,6 +950,17 @@ ipv4_fcnal()
 	run_cmd "$IP ro add 172.16.101.0/24 nhid 21"
 	run_cmd "$IP ro del 172.16.101.0/24 nexthop via 172.16.1.7 dev veth1 nexthop via 172.16.1.8 dev veth1"
 	log_test $? 2 "Delete multipath route with only nh id based entry"
+
+	run_cmd "$IP nexthop add id 22 via 172.16.1.6 dev veth1"
+	run_cmd "$IP ro add 172.16.102.0/24 nhid 22"
+	run_cmd "$IP ro del 172.16.102.0/24 dev veth1"
+	log_test $? 2 "Delete route when specifying only nexthop device"
+
+	run_cmd "$IP ro del 172.16.102.0/24 via 172.16.1.6"
+	log_test $? 2 "Delete route when specifying only gateway"
+
+	run_cmd "$IP ro del 172.16.102.0/24"
+	log_test $? 0 "Delete route when not specifying nexthop attributes"
 }
 
 ipv4_grp_fcnal()
-- 
2.35.1




  parent reply	other threads:[~2022-12-05 19:36 UTC|newest]

Thread overview: 98+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 19:09 [PATCH 5.10 00/92] 5.10.158-rc1 review Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 01/92] btrfs: sink iterator parameter to btrfs_ioctl_logical_to_ino Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 02/92] btrfs: free btrfs_path before copying inodes to userspace Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 03/92] spi: spi-imx: Fix spi_bus_clk if requested clock is higher than input clock Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 04/92] btrfs: move QUOTA_ENABLED check to rescan_should_stop from btrfs_qgroup_rescan_worker Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 05/92] drm/display/dp_mst: Fix drm_dp_mst_add_affected_dsc_crtcs() return code Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 06/92] kbuild: fix -Wimplicit-function-declaration in license_is_gpl_compatible Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 07/92] drm/amdgpu: update drm_display_info correctly when the edid is read Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 08/92] drm/amdgpu: Partially revert "drm/amdgpu: update drm_display_info correctly when the edid is read" Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 09/92] btrfs: qgroup: fix sleep from invalid context bug in btrfs_qgroup_inherit() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 10/92] iio: health: afe4403: Fix oob read in afe4403_read_raw Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 11/92] iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 12/92] iio: light: rpr0521: add missing Kconfig dependencies Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 13/92] bpf, perf: Use subprog name when reporting subprog ksymbol Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 14/92] scripts/faddr2line: Fix regression in name resolution on ppc64le Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 15/92] ARM: at91: rm9200: fix usb device clock id Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 16/92] libbpf: Handle size overflow for ringbuf mmap Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 17/92] hwmon: (ltc2947) fix temperature scaling Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 18/92] hwmon: (ina3221) Fix shunt sum critical calculation Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 19/92] hwmon: (i5500_temp) fix missing pci_disable_device() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 20/92] hwmon: (ibmpex) Fix possible UAF when ibmpex_register_bmc() fails Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 21/92] bpf: Do not copy spin lock field from user in bpf_selem_alloc Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 22/92] of: property: decrement node refcount in of_fwnode_get_reference_args() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 23/92] ixgbevf: Fix resource leak in ixgbevf_init_module() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 24/92] i40e: Fix error handling in i40e_init_module() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 25/92] fm10k: Fix error handling in fm10k_init_module() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 26/92] iavf: remove redundant ret variable Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 27/92] iavf: Fix error handling in iavf_init_module() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 28/92] e100: switch from pci_ to dma_ API Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 29/92] e100: Fix possible use after free in e100_xmit_prepare Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 30/92] net/mlx5: Fix uninitialized variable bug in outlen_write() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 31/92] net/mlx5e: Fix use-after-free when reverting termination table Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 32/92] can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 33/92] can: cc770: cc770_isa_probe(): add missing free_cc770dev() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 34/92] qlcnic: fix sleep-in-atomic-context bugs caused by msleep Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 35/92] aquantia: Do not purge addresses when setting the number of rings Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 36/92] wifi: cfg80211: fix buffer overflow in elem comparison Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 37/92] wifi: cfg80211: dont allow multi-BSSID in S1G Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 38/92] wifi: mac8021: fix possible oob access in ieee80211_get_rate_duration Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 39/92] net: phy: fix null-ptr-deref while probe() failed Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 40/92] net: net_netdev: Fix error handling in ntb_netdev_init_module() Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 41/92] net/9p: Fix a potential socket leak in p9_socket_open Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 42/92] net: ethernet: nixge: fix NULL dereference Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 43/92] dsa: lan9303: Correct stat name Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 44/92] tipc: re-fetch skb cb after tipc_msg_validate Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 45/92] net: hsr: Fix potential use-after-free Greg Kroah-Hartman
2022-12-05 19:09 ` [PATCH 5.10 46/92] afs: Fix fileserver probe RTT handling Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 47/92] net: tun: Fix use-after-free in tun_detach() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 48/92] packet: do not set TP_STATUS_CSUM_VALID on CHECKSUM_COMPLETE Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 49/92] sctp: fix memory leak in sctp_stream_outq_migrate() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 50/92] net: ethernet: renesas: ravb: Fix promiscuous mode after system resumed Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 51/92] hwmon: (coretemp) Check for null before removing sysfs attrs Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 52/92] hwmon: (coretemp) fix pci device refcount leak in nv1a_ram_new() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 53/92] net/mlx5: DR, Fix uninitialized var warning Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 54/92] riscv: vdso: fix section overlapping under some conditions Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 55/92] error-injection: Add prompt for function error injection Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 56/92] tools/vm/slabinfo-gnuplot: use "grep -E" instead of "egrep" Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 57/92] nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 58/92] x86/bugs: Make sure MSR_SPEC_CTRL is updated properly upon resume from S3 Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 59/92] pinctrl: intel: Save and restore pins in "direct IRQ" mode Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 60/92] net: stmmac: Set MACs flow control register to reflect current settings Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 61/92] mmc: mmc_test: Fix removal of debugfs file Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 62/92] mmc: core: Fix ambiguous TRIM and DISCARD arg Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 63/92] mmc: sdhci-esdhc-imx: correct CQHCI exit halt state check Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 64/92] mmc: sdhci-sprd: Fix no reset data and command after voltage switch Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 65/92] mmc: sdhci: Fix voltage switch delay Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 66/92] drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 67/92] drm/i915: Never return 0 if not all requests retired Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 68/92] tracing: Free buffers when a used dynamic event is removed Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 69/92] io_uring: dont hold uring_lock when calling io_run_task_work* Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 70/92] ASoC: ops: Fix bounds check for _sx controls Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 71/92] pinctrl: single: Fix potential division by zero Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 72/92] iommu/vt-d: Fix PCI device refcount leak in has_external_pci() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 73/92] iommu/vt-d: Fix PCI device refcount leak in dmar_dev_scope_init() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 74/92] parisc: Increase size of gcc stack frame check Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 75/92] xtensa: increase " Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 76/92] parisc: Increase FRAME_WARN to 2048 bytes on parisc Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 77/92] Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 78/92] selftests: net: add delete nexthop route warning test Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 79/92] selftests: net: fix nexthop warning cleanup double ip typo Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 80/92] ipv4: Handle attempt to delete multipath route when fib_info contains an nh reference Greg Kroah-Hartman
2022-12-05 19:10 ` Greg Kroah-Hartman [this message]
2022-12-05 19:10 ` [PATCH 5.10 82/92] Revert "tty: n_gsm: avoid call of sleeping functions from atomic context" Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 83/92] x86/tsx: Add a feature bit for TSX control MSR support Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 84/92] x86/pm: Add enumeration check before spec MSRs save/restore setup Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 85/92] i2c: npcm7xx: Fix error handling in npcm_i2c_init() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 86/92] i2c: imx: Only DMA messages with I2C_M_DMA_SAFE flag set Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 87/92] ACPI: HMAT: remove unnecessary variable initialization Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 88/92] ACPI: HMAT: Fix initiator registration for single-initiator systems Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 89/92] Revert "clocksource/drivers/riscv: Events are stopped during CPU suspend" Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 90/92] char: tpm: Protect tpm_pm_suspend with locks Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 91/92] Input: raydium_ts_i2c - fix memory leak in raydium_i2c_send() Greg Kroah-Hartman
2022-12-05 19:10 ` [PATCH 5.10 92/92] [PATCH 5.10.y stable v2] block: unhash blkdev part inode when the part is deleted Greg Kroah-Hartman
2022-12-05 23:34 ` [PATCH 5.10 00/92] 5.10.158-rc1 review Florian Fainelli
2022-12-06  2:37 ` Shuah Khan
2022-12-06 10:24 ` Pavel Machek
2022-12-06 12:27 ` Rudi Heitbaum
2022-12-07  9:34 ` zhouzhixiu

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=20221205190806.150192993@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=dsahern@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jonas.gorski@gmail.com \
    --cc=kuba@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=razor@blackwall.org \
    --cc=sashal@kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).