From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1869435BDAD for ; Wed, 1 Apr 2026 04:19:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775017178; cv=none; b=RQ/kiDuV8lpGHpIxaGs22wbd2yCjj9NkKuM3KmKv2edKsjeEx0WVXQitxhWOXJssVIG/GaTb6z4PnxGV3ksH7spH49qETh7R+wTexZKP4juuasjqJTtYSBnP+96P72v6t4AWn7WDBg+G40vkLa9h5dIhUFaq3QywJbux+882J28= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775017178; c=relaxed/simple; bh=Xvd1LcX3lj4iVmPIf6vyiuh8vdYoE6izvFfaKScNjkI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=TMNbZ/NP1Vu512gisEJZixDEFDMjgV4HfJjvcd9XgUB+0Mj13PrOZu8RwxuQ0xTosJiTslqdPVVh62UQmWUjxK2Ud9P+WK8Bh2A0HrWDTs7+vQLyZaxM2AyNVi9Ug/HFngIZRsbLHyXNMxWFF1Uqw255EAm9CAAfWd0OAVImjF4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=bDJeW9ux; arc=none smtp.client-ip=209.85.210.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bDJeW9ux" Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-7d7fdb922a5so5346841a34.3 for ; Tue, 31 Mar 2026 21:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775017176; x=1775621976; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=dFONURkaqW7NTmmG72z2KFu2mOMfbPaei0blX1R+FTo=; b=bDJeW9uxl7HclUYx/Zb38APCy2NlhrWY3XXlGUr93+m7wJc2ESC59G8hyp99XXrZk4 3r6olg4V9EpFY+uKdHBDN/Ui1pEWfJ8/grwWSTqj2iNO/a21xkQfbDGFz+Ps7ox5MkxS ZmVQOoscC6n6eGolTRUL88b7vZdhwkRWQWUo9CfoAPFHXbEJKKsNQRsrBjbIZpQxysSb ndw4V5hPIGtIsEKoOe2H8GC1ic0F2UwRDm+4PbLI+ljmidJTqL22ezvwJqM468RgT6gC cLLeNsb2uBrgU/QICbffasfpzp3X06CTpj/GAROxdYynSeJs3Ig8ZMayq7FYhGpxKueI 6NJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775017176; x=1775621976; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=dFONURkaqW7NTmmG72z2KFu2mOMfbPaei0blX1R+FTo=; b=EVCX5AfM/jqyiZesiSKFoubCSnlNHyTJxj6vkI/Lt1LRgNwqAV60GmDRKdzkL9Wy66 EYGJw024DY4otKiPdsBAWzmnr0I3U7UpBxyrSSIGAVmedVZxjEDzl/O4I2YU6B8PfdpX CVTHc9esx6t7ljm91JPwXbesG3TwwnWwzGkKZjYtpTBtT03y8wtKGmfzCaPoStsU6wn7 83hrFbEA/LcJsRg1lnRROcg7DzKneDFLKbBifP2nPHEWk4KtWQN/lFyJO4Gsl3gmhTY3 RSbyFOLCgBqpIZW13z7ya6XpYE+Xutrr7HXOc/hpib91LwasKIVkCWvzivJV7utnnPYI BoOw== X-Forwarded-Encrypted: i=1; AJvYcCVUXwUS85TM31gsAE67JUodYctip4nDHRCTs7h5S+ZRmzrvfW8z7oKe5nxZEuJA/lHlDspj2nClkcADeX4=@vger.kernel.org X-Gm-Message-State: AOJu0YyWMYd7orlKBHRADCuV9C8zpOI0faOE2DSd+2SNesskTn8Uxzf0 5DPMvZHwLUDcWhxxZQQbFWgMaV8acGTE0tzLw7VSrnN35k/9AaWQVrDn X-Gm-Gg: ATEYQzwGIO0vErxivMZ08V+BjnAXZNQ5d86xte4Aw/vjRbk2HOHzOdoNZ8vTtja9Via XYMG84u1rOdZJxFGYeipl6sE59h1LSfR8b807qHHMmFss1/MzkBkdU2QxlicmkeZDxsF8tnnAPI mfWGb7CbpoGfktc1m72XbLl/nR7MlvflVvgHnJLB/Ydq60yYJCl1Dq/qWw9BooeIBjuunpO2K1K 52Alft+bLhS3z8gubmMz/JGCEBTdbhsT/U1qXCrU/nfGV3rZD/6Fh3OZmxMbH4HCBKwdzTw/CEj Z5ZmK0AgNh6ODM8bSFLVE9jbPD+XoW0j0zptQlkR/YxhUzT9g9syQcmJe1/NEFDMTZNzA5+pdC+ NwLJR1eurnZARpF2T/3W4MxN2THnrh7FY2DxCrwxYGXb8L84JF+WOzcuC3eGKRm1/tYcMaTpNSn GS2017zAUmE43dnjmbKGzU4h5WfYksS9W8I8yU0HLUJ7wcSAJgh4DRvhIJkdA= X-Received: by 2002:a05:6830:43a9:b0:7d7:fada:89ca with SMTP id 46e09a7af769-7db99343898mr1622685a34.15.1775017176031; Tue, 31 Mar 2026 21:19:36 -0700 (PDT) Received: from localhost (static-23-234-115-121.cust.tzulo.com. [23.234.115.121]) by smtp.gmail.com with UTF8SMTPSA id 46e09a7af769-7da0a335440sm9588380a34.4.2026.03.31.21.19.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Mar 2026 21:19:34 -0700 (PDT) From: Sam Edwards X-Google-Original-From: Sam Edwards To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Maxime Coquelin , Alexandre Torgue , "Russell King (Oracle)" , Maxime Chevallier , Ovidiu Panait , Vladimir Oltean , Baruch Siach , Serge Semin , Giuseppe Cavallaro , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sam Edwards Subject: [PATCH net v4 0/2] stmmac crash/stall fixes when under memory pressure Date: Tue, 31 Mar 2026 21:19:27 -0700 Message-ID: <20260401041929.12392-1-CFSworks@gmail.com> X-Mailer: git-send-email 2.52.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi netdev, This is v4 of my series containing a pair of bugfixes for the stmmac driver's receive pipeline. These issues occur when stmmac_rx_refill() does not (fully) succeed, which happens more frequently when free memory is low. The first patch closes Bugzilla bug #221010 [1], where stmmac_rx() can circle around to a still-dirty descriptor (with a NULL buffer pointer), mistake it for a filled descriptor (due to OWN=0), and attempt to dereference the buffer. In testing that patch, I discovered a second issue: starvation of available RX buffers causes the NIC to stop sending interrupts; if the driver stops polling, it will wait indefinitely for an interrupt that will never come. (Note: the first patch makes this issue more prominent -- mostly because it lets the system survive long enough to exhibit it -- but doesn't *cause* it.) The second patch addresses that problem as well. Both patches are minimal, appropriate for stable, and designated to `net`. My focus is on small, obviously-correct, easy-to-explain changes: I'll follow up with another patch/series (something like [2]) for `net-next` that fixes the ring in a more robust way. The tx and zc paths seem to have similar low-memory bugs, to be addressed in separate series. Regards, Sam --- [1] https://bugzilla.kernel.org/show_bug.cgi?id=221010 [2] https://lore.kernel.org/netdev/20260316021009.262358-4-CFSworks@gmail.com/ v4: - Changed patch 2 to tolerate dirty stragglers up to a critical threshold (the same threshold tolerated by the zero-copy path), to avoid nuisance looping during OOM conditions (thanks Jakub) v3: https://lore.kernel.org/netdev/20260328192503.520689-1-CFSworks@gmail.com/T/ - Rebased on latest net/main - Changed patch 2 to require that stmmac_rx_refill() *fully* succeeds before exiting polling, to reduce the chance of rx drops. - DID NOT use the CIRC_SPACE() macro as suggested by Russell: I fear that the perspective shift (first think of the dirty descriptors as the "work" that refill "consumes" -- therefore the "space" is how much stmmac_rx() may loop) is too counterintuitive for a stable fix, but I'll do it in v4 if reviewers insist. - Updated the recipients for the series, which was invalidated in v2 due to the `Fixes:` v2: https://lore.kernel.org/netdev/20260319184031.8596-1-CFSworks@gmail.com/T/ - Completely rewrote the commit message of patch 1, now assuming the reader is generally familiar with DMA but wholly unfamiliar with the stmmac device (thanks Jakub!) - Added missing `Fixes:` to patch 2 - Moved patch 2's `int budget = limit;` decl per the reverse-xmas-tree rule - Dropped patch 3: this was a code improvement not appropriate for stable - Generated the series with --subject-prefix='PATCH net' v1: https://lore.kernel.org/netdev/20260316021009.262358-1-CFSworks@gmail.com/ Sam Edwards (2): net: stmmac: Prevent NULL deref when RX memory exhausted net: stmmac: Prevent indefinite RX stall on buffer exhaustion drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) -- 2.52.0