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, "Thomas Gleixner" <tglx@linutronix.de>,
	syzbot+039399a9b96297ddedca@syzkaller.appspotmail.com,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	"Sasha Levin" <sashal@kernel.org>
Subject: [PATCH 5.15 07/84] net: veth: clear GRO when clearing XDP even when down
Date: Mon,  4 Mar 2024 21:23:40 +0000	[thread overview]
Message-ID: <20240304211542.585279842@linuxfoundation.org> (raw)
In-Reply-To: <20240304211542.332206551@linuxfoundation.org>

5.15-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Jakub Kicinski <kuba@kernel.org>

[ Upstream commit fe9f801355f0b47668419f30f1fac1cf4539e736 ]

veth sets NETIF_F_GRO automatically when XDP is enabled,
because both features use the same NAPI machinery.

The logic to clear NETIF_F_GRO sits in veth_disable_xdp() which
is called both on ndo_stop and when XDP is turned off.
To avoid the flag from being cleared when the device is brought
down, the clearing is skipped when IFF_UP is not set.
Bringing the device down should indeed not modify its features.

Unfortunately, this means that clearing is also skipped when
XDP is disabled _while_ the device is down. And there's nothing
on the open path to bring the device features back into sync.
IOW if user enables XDP, disables it and then brings the device
up we'll end up with a stray GRO flag set but no NAPI instances.

We don't depend on the GRO flag on the datapath, so the datapath
won't crash. We will crash (or hang), however, next time features
are sync'ed (either by user via ethtool or peer changing its config).
The GRO flag will go away, and veth will try to disable the NAPIs.
But the open path never created them since XDP was off, the GRO flag
was a stray. If NAPI was initialized before we'll hang in napi_disable().
If it never was we'll crash trying to stop uninitialized hrtimer.

Move the GRO flag updates to the XDP enable / disable paths,
instead of mixing them with the ndo_open / ndo_close paths.

Fixes: d3256efd8e8b ("veth: allow enabling NAPI even without XDP")
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Reported-by: syzbot+039399a9b96297ddedca@syzkaller.appspotmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-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>
---
 drivers/net/veth.c | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 984a153804096..85c3e12f83627 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1079,14 +1079,6 @@ static int veth_enable_xdp(struct net_device *dev)
 				veth_disable_xdp_range(dev, 0, dev->real_num_rx_queues, true);
 				return err;
 			}
-
-			if (!veth_gro_requested(dev)) {
-				/* user-space did not require GRO, but adding XDP
-				 * is supposed to get GRO working
-				 */
-				dev->features |= NETIF_F_GRO;
-				netdev_features_change(dev);
-			}
 		}
 	}
 
@@ -1106,18 +1098,9 @@ static void veth_disable_xdp(struct net_device *dev)
 	for (i = 0; i < dev->real_num_rx_queues; i++)
 		rcu_assign_pointer(priv->rq[i].xdp_prog, NULL);
 
-	if (!netif_running(dev) || !veth_gro_requested(dev)) {
+	if (!netif_running(dev) || !veth_gro_requested(dev))
 		veth_napi_del(dev);
 
-		/* if user-space did not require GRO, since adding XDP
-		 * enabled it, clear it now
-		 */
-		if (!veth_gro_requested(dev) && netif_running(dev)) {
-			dev->features &= ~NETIF_F_GRO;
-			netdev_features_change(dev);
-		}
-	}
-
 	veth_disable_xdp_range(dev, 0, dev->real_num_rx_queues, false);
 }
 
@@ -1497,6 +1480,14 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 		}
 
 		if (!old_prog) {
+			if (!veth_gro_requested(dev)) {
+				/* user-space did not require GRO, but adding
+				 * XDP is supposed to get GRO working
+				 */
+				dev->features |= NETIF_F_GRO;
+				netdev_features_change(dev);
+			}
+
 			peer->hw_features &= ~NETIF_F_GSO_SOFTWARE;
 			peer->max_mtu = max_mtu;
 		}
@@ -1507,6 +1498,14 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 			if (dev->flags & IFF_UP)
 				veth_disable_xdp(dev);
 
+			/* if user-space did not require GRO, since adding XDP
+			 * enabled it, clear it now
+			 */
+			if (!veth_gro_requested(dev)) {
+				dev->features &= ~NETIF_F_GRO;
+				netdev_features_change(dev);
+			}
+
 			if (peer) {
 				peer->hw_features |= NETIF_F_GSO_SOFTWARE;
 				peer->max_mtu = ETH_MAX_MTU;
-- 
2.43.0




  parent reply	other threads:[~2024-03-04 21:53 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-04 21:23 [PATCH 5.15 00/84] 5.15.151-rc1 review Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 01/84] netfilter: nf_tables: disallow timeout for anonymous sets Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 02/84] mtd: spinand: gigadevice: Fix the get ecc status issue Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 03/84] netlink: Fix kernel-infoleak-after-free in __skb_datagram_iter Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 04/84] net: ip_tunnel: prevent perpetual headroom growth Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 05/84] tun: Fix xdp_rxq_infos queue_index when detaching Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 06/84] cpufreq: intel_pstate: fix pstate limits enforcement for adjust_perf call back Greg Kroah-Hartman
2024-03-04 21:23 ` Greg Kroah-Hartman [this message]
2024-03-04 21:23 ` [PATCH 5.15 08/84] ipv6: fix potential "struct net" leak in inet6_rtm_getaddr() Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 09/84] lan78xx: enable auto speed configuration for LAN7850 if no EEPROM is detected Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 10/84] net: enable memcg accounting for veth queues Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 11/84] veth: try harder when allocating queue memory Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 12/84] net: usb: dm9601: fix wrong return value in dm9601_mdio_read Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 13/84] uapi: in6: replace temporary label with rfc9486 Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 14/84] stmmac: Clear variable when destroying workqueue Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 15/84] Bluetooth: Avoid potential use-after-free in hci_error_reset Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 16/84] Bluetooth: hci_event: Fix wrongly recorded wakeup BD_ADDR Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 17/84] Bluetooth: hci_event: Fix handling of HCI_EV_IO_CAPA_REQUEST Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 18/84] Bluetooth: Enforce validation on max value of connection interval Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 19/84] netfilter: nf_tables: allow NFPROTO_INET in nft_(match/target)_validate() Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 20/84] netfilter: nfnetlink_queue: silence bogus compiler warning Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 21/84] netfilter: core: move ip_ct_attach indirection to struct nf_ct_hook Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 22/84] netfilter: make function op structures const Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 23/84] netfilter: let reset rules clean out conntrack entries Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 24/84] netfilter: bridge: confirm multicast packets before passing them up the stack Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 25/84] rtnetlink: fix error logic of IFLA_BRIDGE_FLAGS writing back Greg Kroah-Hartman
2024-03-04 21:23 ` [PATCH 5.15 26/84] igb: extend PTP timestamp adjustments to i211 Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 27/84] tls: rx: dont store the record type in socket context Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 28/84] tls: rx: dont store the decryption status " Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 29/84] tls: rx: dont issue wake ups when data is decrypted Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 30/84] tls: rx: refactor decrypt_skb_update() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 31/84] tls: hw: rx: use return value of tls_device_decrypted() to carry status Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 32/84] tls: rx: drop unnecessary arguments from tls_setup_from_iter() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 33/84] tls: rx: dont report text length from the bowels of decrypt Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 34/84] tls: rx: wrap decryption arguments in a structure Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 35/84] tls: rx: factor out writing ContentType to cmsg Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 36/84] tls: rx: dont track the async count Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 37/84] tls: rx: move counting TlsDecryptErrors for sync Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 38/84] tls: rx: assume crypto always calls our callback Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 39/84] tls: rx: use async as an in-out argument Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 40/84] tls: decrement decrypt_pending if no async completion will be called Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 41/84] efi/capsule-loader: fix incorrect allocation size Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 42/84] power: supply: bq27xxx-i2c: Do not free non existing IRQ Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 43/84] ALSA: Drop leftover snd-rtctimer stuff from Makefile Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 44/84] fbcon: always restore the old font data in fbcon_do_set_font() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 45/84] afs: Fix endless loop in directory parsing Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 46/84] riscv: Sparse-Memory/vmemmap out-of-bounds fix Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 47/84] tomoyo: fix UAF write bug in tomoyo_write_control() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 48/84] ALSA: firewire-lib: fix to check cycle continuity Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 49/84] gtp: fix use-after-free and null-ptr-deref in gtp_newlink() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 50/84] wifi: nl80211: reject iftype change with mesh ID change Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 51/84] btrfs: dev-replace: properly validate device names Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 52/84] dmaengine: fsl-qdma: fix SoC may hang on 16 byte unaligned read Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 53/84] dmaengine: ptdma: use consistent DMA masks Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 54/84] dmaengine: fsl-qdma: init irq after reg initialization Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 55/84] mmc: core: Fix eMMC initialization with 1-bit bus connection Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 56/84] mmc: sdhci-xenon: add timeout for PHY init complete Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 57/84] mmc: sdhci-xenon: fix PHY init clock stability Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 58/84] riscv: add CALLER_ADDRx support Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 59/84] pmdomain: qcom: rpmhpd: Fix enabled_corner aggregation Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 60/84] x86/cpu/intel: Detect TME keyid bits before setting MTRR mask registers Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 61/84] mptcp: move __mptcp_error_report in protocol.c Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 62/84] mptcp: process pending subflow error on close Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 63/84] mptcp: rename timer related helper to less confusing names Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 64/84] selftests: mptcp: add missing kconfig for NF Filter Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 65/84] selftests: mptcp: add missing kconfig for NF Filter in v6 Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 66/84] mptcp: clean up harmless false expressions Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 67/84] mptcp: add needs_id for netlink appending addr Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 68/84] mptcp: push at DSS boundaries Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 69/84] mptcp: fix possible deadlock in subflow diag Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 70/84] cachefiles: fix memory leak in cachefiles_add_cache() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 71/84] fs,hugetlb: fix NULL pointer dereference in hugetlbs_fill_super Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 72/84] Revert "drm/bridge: lt8912b: Register and attach our DSI device at probe" Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 73/84] af_unix: Drop oob_skb ref before purging queue in GC Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 74/84] gpio: 74x164: Enable output pins after registers are reset Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 75/84] gpiolib: Fix the error path order in gpiochip_add_data_with_key() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 76/84] gpio: fix resource unwinding order in error path Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 77/84] Revert "interconnect: Fix locking for runpm vs reclaim" Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 78/84] Revert "interconnect: Teach lockdep about icc_bw_lock order" Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 79/84] bpf: Add BPF_FIB_LOOKUP_SKIP_NEIGH for bpf_fib_lookup Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 80/84] bpf: Add table ID to bpf_fib_lookup BPF helper Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 81/84] bpf: Derive source IP addr via bpf_*_fib_lookup() Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 82/84] net: tls: fix async vs NIC crypto offload Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 83/84] Revert "tls: rx: move counting TlsDecryptErrors for sync" Greg Kroah-Hartman
2024-03-04 21:24 ` [PATCH 5.15 84/84] mptcp: fix double-free on socket dismantle Greg Kroah-Hartman
2024-03-04 22:50 ` [PATCH 5.15 00/84] 5.15.151-rc1 review SeongJae Park
2024-03-05  4:52 ` Ron Economos
2024-03-05 10:08 ` Naresh Kamboju
2024-03-05 11:30   ` Greg Kroah-Hartman
2024-03-05 10:58 ` Jon Hunter
2024-03-05 11:43 ` Harshit Mogalapalli
2024-03-05 19:05 ` Shuah Khan

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=20240304211542.585279842@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+039399a9b96297ddedca@syzkaller.appspotmail.com \
    --cc=tglx@linutronix.de \
    --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).