From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 599742F8EBF; Thu, 2 Jul 2026 16:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011568; cv=none; b=Xsp1mgeiT+W3fsc/VFTNrU5ln+KvErfssVN9eo60v2ARQkJxcQoFNy7Zqm6deKqfsPtFpE/WFDPhqb1M6nVCKHx5vpBInZSavs/WzJSc+AOzFT9lf8pWPQjooor1gy8kNKq+4WqdtL3cgE3Z3vWDBEkpyv7J+V8gxYQ2fVSTnbE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783011568; c=relaxed/simple; bh=Kc20u3WOqgPXZzDKGdgsyVQ2/VmKHwONYknQ62hUvJU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ncjPVAxucrRsnYdx59/pbRfVsHmC69us9NGiQU4aMCNLLqNLDuL2+YA7poIPX90hxsmd6uqRY0GPFeBSBQ9RTVbGVUP+2X5lOpjRRxqdlUAb7hN0YA15ANTyszViaXof5mk2HpSJqDbbERFMcPwAp0c2KrDqTbWNkZ84z7/eO9c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zYY4bR0i; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zYY4bR0i" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF52F1F00A3A; Thu, 2 Jul 2026 16:59:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1783011567; bh=GSNnGhgAcx0IBrAFYedQYW/TvLq8KxPnEP3z2jSJ7mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=zYY4bR0i9Sa8hzpKNCUDgkqdhI4ujRUy/WvXx0wTkNYnECHxAhtJYcxmehkAy8ntr OTyC0hhsiGOCA4O2dSHee+uj8g/G7PFoFSeQM2IGIlAL4Acdn1E21EF8/3XzKp7bom YGylPZ7d7fyc2GosdaC7WOWM9TMPPKF4GHAKH52I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable@kernel.org, Sven Eckelmann , Sasha Levin Subject: [PATCH 7.1 005/120] batman-adv: tp_meter: avoid window underflow Date: Thu, 2 Jul 2026 18:20:01 +0200 Message-ID: <20260702155113.076972700@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260702155112.964534952@linuxfoundation.org> References: <20260702155112.964534952@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Sven Eckelmann commit 765947b81fb54b6ebb0bc1cfe55c0fa399e002b8 upstream. In batadv_tp_avail(), win_left is calculated with 32-bit unsigned arithmetic: win_left = win_limit - tp_vars->last_sent; During Fast Recovery, cwnd is inflated and last_sent advances rapidly. When Fast Recovery ends, cwnd drops abruptly back to ss_threshold. If the newly shrunk win_limit is less than last_sent, the unsigned subtraction will underflow, wrapping to a massive positive value. Instead of returning that the window is full (unavailable), it returns that the sender can continue sending. To handle this situation, it must be checked whether the windows end sequence number (win_limit) has to be compared with the last sent sequence number. If it would be before the last sent sequence number, then more acks are needed before the transmission can be started again. Cc: stable@kernel.org Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation") Signed-off-by: Sven Eckelmann Signed-off-by: Sasha Levin --- net/batman-adv/tp_meter.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index 2ff7aa5ed19fb3..d3b8f02ca08b14 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -817,10 +817,15 @@ static void batadv_tp_recv_ack(struct batadv_priv *bat_priv, static bool batadv_tp_avail(struct batadv_tp_vars *tp_vars, size_t payload_len) { + u32 last_sent = READ_ONCE(tp_vars->last_sent); u32 win_left, win_limit; win_limit = atomic_read(&tp_vars->last_acked) + tp_vars->cwnd; - win_left = win_limit - tp_vars->last_sent; + + if (batadv_seq_before(last_sent, win_limit)) + win_left = win_limit - last_sent; + else + win_left = 0; return win_left >= payload_len; } -- 2.53.0