Received: from dvalin.narfation.org (dvalin.narfation.org [213.160.73.56]) (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 7EE1A403AF4 for ; Fri, 26 Jun 2026 16:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=213.160.73.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782490372; cv=none; b=Rt4YiWupeTCZAbXtqDJ9rYq6fqD4g0IMp6EQ6GeRn6jjJ5N4P2ivzyEdaFPve2xBUNZhFCcomIOspdNi2yUNSkLfMu3Ej9CrIIQJEBRAsyLe+l9/gtm1HMOL8nPyM9S57Kxoeex58XOBy2lUm3cq5P93Aqhq4n63a8g6LSUQpFk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782490372; c=relaxed/simple; bh=b/cMUYkK8LJY0Ye7xt0XGhRLtsmOU5Uc/VHUk9ek4ms=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HGMfigVg9JCH2wRJAOGV7uon/Sd19tvO9hu+fLljMqSNcOnujnJTQno0kXfNOXLY7n7+lpDSkoGxQxCsJFu0y1lW/jsfGd2dJ+96F/GZyWsE8Epq8kM34yOMYA1hvxuchLiLSEb69DrsG1uPdPLbugYgcjfI4U6BJHMjWjZWu1Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=narfation.org; spf=pass smtp.mailfrom=narfation.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.b=CSx5sbtO; arc=none smtp.client-ip=213.160.73.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=narfation.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=narfation.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=narfation.org header.i=@narfation.org header.b="CSx5sbtO" Received: by dvalin.narfation.org (Postfix) id CBAD020539; Fri, 26 Jun 2026 16:12:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1782490366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jP1OnSR0jM4Q7fzRykzfNKKvUo2cr4tdUn8aaEsSYqY=; b=CSx5sbtOQsP8gF5Qn5MObvSOP50EZiMGcbxrQ54y0nNHkv0SiSQH82v/9+qR/jsYgC1fD0 41emqHr39spT8MhccX51LN1Hi7hLVy+9YreHIRz41U4uazM/jpUN0NspRUN65us7AUVpHG Un3uRzrvgGa+dMyTnKMhx6RZB5RFbnQ= From: Sven Eckelmann To: stable@vger.kernel.org Cc: Sven Eckelmann Subject: [PATCH 7.1 10/26] batman-adv: prevent ELP transmission interval underflow Date: Fri, 26 Jun 2026 18:12:25 +0200 Message-ID: <20260626161241.124988-11-sven@narfation.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260626161241.124988-1-sven@narfation.org> References: <20260626161241.124988-1-sven@narfation.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit commit 5e50d4b8ae3ea622122d3c6a38d7f6fe68dfddca upstream. batadv_v_elp_start_timer() enqeues a delayed work. The time when it starts is randomly chosen between (elp_interval - BATADV_JITTER) and (elp_interval + BATADV_JITTER). The configured elp_interval must therefore be larger or equal to BATADV_JITTER to avoid that it causes an underflow of the unsigned integer. If this would happen, then a "fast" ELP interval would turn into a "day long" delay. At the same time, it must not be larger than the maximum value the variable can store. Cc: stable@kernel.org Fixes: a10800829040 ("batman-adv: Add elp_interval hardif genl configuration") [ Context ] Signed-off-by: Sven Eckelmann --- net/batman-adv/netlink.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index 78c651f634cd3..8114454f42cfc 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -917,7 +917,13 @@ static int batadv_netlink_set_hardif(struct sk_buff *skb, #ifdef CONFIG_BATMAN_ADV_BATMAN_V if (info->attrs[BATADV_ATTR_ELP_INTERVAL]) { + u32 elp_interval; + attr = info->attrs[BATADV_ATTR_ELP_INTERVAL]; + elp_interval = nla_get_u32(attr); + + elp_interval = min_t(u32, elp_interval, INT_MAX); + elp_interval = max_t(u32, elp_interval, BATADV_JITTER); atomic_set(&hard_iface->bat_v.elp_interval, nla_get_u32(attr)); } -- 2.47.3