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 0B92B3FF1B8 for ; Fri, 26 Jun 2026 16:12:20 +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=1782490344; cv=none; b=DOKwYS2fVSmlr9UC93rtcF+jRuwHeCQviYs4bNIw6otNMlvm0JzIsAvLFpM/XdtAYUZpFSVCAUTb9DnMTK2HYZPt04JnCKxghhkUR3IGETKQ0wJ0iSuvYPfFaw4QIpNG+GpYM6CSLNFAYe7d7JS5NrNP418ToL2JnMVK+ohEZBg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782490344; c=relaxed/simple; bh=KvLaZF3mo3ugUvdnvxBp7qGQYKJOf7TBfffXK1/HgP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d5+mKuTm9qM6Q8ZN872ZIFELFelNS8ZanyVpcoo8yvhSnx442qfK4Ib+Rw6EB9GA++9fdB/GC2BGdb8qFG2Oq+sWQWy6vCK+Gs/adRA8l4xxn49HVO0TT/D3w6S40q8UBdK7hc5gWVhJ7h5s50jh7GrxMi1ihq2Fm4qJYfVOZ2A= 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=w64JLBWO; 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="w64JLBWO" Received: by dvalin.narfation.org (Postfix) id 61066203FC; Fri, 26 Jun 2026 16:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=narfation.org; s=20121; t=1782490339; 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=QMJoya9hBWFAlGjTtdvpazJ4bZLR5zpm1JfhkJ9bsuA=; b=w64JLBWOzDtAmKXb5rqPe6cndFln7RVquHX3vI4/St6jmsUVrsOhTM9tpRpXfaormP/OvC F/7k75SPQJJU6OnkUsT3hwDZW5DD0ZiQH29u1+cDRBlmhj6waOAzFBNfaf8w3eFUcQ6nT2 ZZI4DDO7jaxz4FVYvH3N0qEZQ4KJzOE= From: Sven Eckelmann To: stable@vger.kernel.org Cc: Sven Eckelmann Subject: [PATCH 6.18 19/26] batman-adv: tp_meter: annotate last_recv_time access with READ/WRITE_ONCE Date: Fri, 26 Jun 2026 18:12:03 +0200 Message-ID: <20260626161210.124712-20-sven@narfation.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260626161210.124712-1-sven@narfation.org> References: <20260626161210.124712-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 d67c728f07fca2ee6ffdc6dd4421cf2e8691f4d1 upstream. The last_recv_time field for batadv_tp_receiver tracks the jiffies value of the most recent activity and is used to detect timeouts. These accesses are not consistently protected by a lock, so READ_ONCE/WRITE_ONCE must be used to prevent data races caused by compiler optimizations. Cc: stable@kernel.org Fixes: 33a3bb4a3345 ("batman-adv: throughput meter implementation") Signed-off-by: Sven Eckelmann --- net/batman-adv/tp_meter.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index e5387e8f33244..e69bf10e66ac3 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -1183,7 +1183,7 @@ static void batadv_tp_receiver_shutdown(struct timer_list *t) bat_priv = tp_vars->bat_priv; /* if there is recent activity rearm the timer */ - if (!batadv_has_timed_out(tp_vars->last_recv_time, + if (!batadv_has_timed_out(READ_ONCE(tp_vars->last_recv_time), BATADV_TP_RECV_TIMEOUT)) { /* reset the receiver shutdown timer */ batadv_tp_reset_receiver_timer(tp_vars); @@ -1424,7 +1424,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, tp_vars = batadv_tp_list_find_session(bat_priv, icmp->orig, icmp->session, BATADV_TP_RECEIVER); if (tp_vars) { - tp_vars->last_recv_time = jiffies; + WRITE_ONCE(tp_vars->last_recv_time, jiffies); goto out_unlock; } @@ -1455,7 +1455,7 @@ batadv_tp_init_recv(struct batadv_priv *bat_priv, kref_get(&tp_vars->refcount); timer_setup(&tp_vars->timer, batadv_tp_receiver_shutdown, 0); - tp_vars->last_recv_time = jiffies; + WRITE_ONCE(tp_vars->last_recv_time, jiffies); kref_get(&tp_vars->refcount); hlist_add_head_rcu(&tp_vars->list, &bat_priv->tp_list); @@ -1506,7 +1506,7 @@ static void batadv_tp_recv_msg(struct batadv_priv *bat_priv, goto out; } - tp_vars->last_recv_time = jiffies; + WRITE_ONCE(tp_vars->last_recv_time, jiffies); } /* if the packet is a duplicate, it may be the case that an ACK has been -- 2.47.3