From nobody Mon Feb 9 13:39:09 2026 Received: from e3i103.smtp2go.com (e3i103.smtp2go.com [158.120.84.103]) (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 022F31ABEC5 for ; Tue, 28 Jan 2025 15:30:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=158.120.84.103 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738078233; cv=none; b=ZNix2M3uE8+bkns9l5aPjPn0uEkndlaqF4llxtwkSz2qg5QSktKY+B8bIMD3I8Fd+Fenr1Yltdb7KRwHTo5HKjVcXcvt3123sB1EUWmG8z7pFY9YejSeEYEnkd/DvB/sZGS/DrnSYr6XO1yXf7pGavf8dcgRrw06oHDGaL+bxRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738078233; c=relaxed/simple; bh=SA2dA2cFh5kIUaABXLBFt0k0NWbeFGJ9IJMwK9IllJ0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=gawqbRBRo5cz/tqkdu59qvfQXDHHTZVa4Thbpg5HOvLvmyUOE7ggy0U7WS0yEYrpR601QSZOtg0J3ut8FXTs23jpxCI4Bq05xeod8zRY4SU4zPcj/G9nnZ+pKpNYnqtXyC5F2WYch3ckX6inPdTpIDG4vRMh7sz6bgfAxb9nJo0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=triplefau.lt; spf=pass smtp.mailfrom=em510616.triplefau.lt; dkim=pass (2048-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b=NmNPuAam; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b=GyTUzXYJ; arc=none smtp.client-ip=158.120.84.103 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=triplefau.lt Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=em510616.triplefau.lt Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=smtpservice.net header.i=@smtpservice.net header.b="NmNPuAam"; dkim=pass (2048-bit key) header.d=triplefau.lt header.i=@triplefau.lt header.b="GyTUzXYJ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smtpservice.net; i=@smtpservice.net; q=dns/txt; s=a1-4; t=1738077323; h=feedback-id : x-smtpcorp-track : date : message-id : to : subject : from : reply-to : sender : list-unsubscribe : list-unsubscribe-post; bh=+xSsdRmbHklVvRjU75VCmBGTMgpvR753FjKrsS8EVyw=; b=NmNPuAamy4FtF4devs9FAIre7+yA7eMn37JB23kFWDVLy/XWxju48GgrkCqyr+OKCJoQt 74vhTahWK4J1S743a8vwUW1yvWvbbhAaksIASdgftiASpQcv+QyGlZ7bpzeXGbr5yB0KC0U wdE/jYuRFkhZ9lKPF4rFEwf40BYgepTW8pN9qOH4MWswkCvcroYTcENdf5xKPvs+k5IMsVS cj6ariKU/tb0CQbqtOA+sWWJ2F8Zu8yF3QsiKWCVg4z2hNhS4EThzM+GnIeFmMVfyg44V5R joYjJ61wmpfqJrmlBm3+kAjrByBXawOrCpUpbIAGEUMN1eWFcRYhXr0h8/Zg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=triplefau.lt; i=@triplefau.lt; q=dns/txt; s=s510616; t=1738077323; h=from : subject : to : message-id : date; bh=+xSsdRmbHklVvRjU75VCmBGTMgpvR753FjKrsS8EVyw=; b=GyTUzXYJl/S7HX7idHUSa+HcEaK5RMlj6SeglsFhU6Dj06roMmV1ctj6mfyFcVaB8f9IR Pbjuma3tdj1qMl87EVHT2vZ8124zTQhNqrsr40au1fy6MnYBRcbH9vbA2tWquvqTYH3IRd0 kXaox849Pude++2n9FzASgnwz4ByPqmtRrtqaheXLWdvly1wk84mgBzfZsFKjsKfSTWU2pa crqIo4xJb43yMvcvkR5fiHyeUhplRG47ZZlbDOKG7YUaBkDC5aIq5bvAH7bKf5uVg74PA+w 5Qek8XlHt128XhKgd6ZEQ/q0YytREQHn59oz4Le/Cz7IHeij9tNz0rXimuUw== Received: from [10.12.239.196] (helo=localhost) by smtpcorp.com with esmtpsa (TLS1.3:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97.1-S2G) (envelope-from ) id 1tcnIs-FnQW0hPqPnK-kBbu; Tue, 28 Jan 2025 15:15:02 +0000 From: Remi Pommarel To: b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Lindner , Simon Wunderlich , Sven Eckelmann , Erick Archer , Kees Cook , Remi Pommarel Subject: [PATCH] batman-adv: Fix incorrect offset in batadv_tt_tvlv_ogm_handler_v1() Date: Tue, 28 Jan 2025 16:11:06 +0100 Message-Id: X-Mailer: git-send-email 2.40.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please forward a copy of this message, including all headers, to Feedback-ID: 510616m:510616apGKSTK:510616sA6pqHVkxx X-smtpcorp-track: qGxVO6OGkY9c.wLMF50yZ-wmN.EIwOgg5XswQ Content-Type: text/plain; charset="utf-8" Since commit 4436df478860 ("batman-adv: Add flex array to struct batadv_tvlv_tt_data"), the introduction of batadv_tvlv_tt_data's flex array member in batadv_tt_tvlv_ogm_handler_v1() put tt_changes at invalid offset. Those TT changes are supposed to be filled from the end of batadv_tvlv_tt_data structure (including vlan_data flexible array), but only the flex array size is taken into account missing completely the size of the fixed part of the structure itself. Fix the tt_change offset computation by using struct_size() instead of flex_array_size() so both flex array member and its container structure sizes are taken into account. Fixes: 4436df478860 ("batman-adv: Add flex array to struct batadv_tvlv_tt_d= ata") Signed-off-by: Remi Pommarel --- net/batman-adv/translation-table.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translatio= n-table.c index 3c0a14a582e4..d4b71d34310f 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -3937,23 +3937,21 @@ static void batadv_tt_tvlv_ogm_handler_v1(struct ba= tadv_priv *bat_priv, struct batadv_tvlv_tt_change *tt_change; struct batadv_tvlv_tt_data *tt_data; u16 num_entries, num_vlan; - size_t flex_size; + size_t tt_data_sz; =20 if (tvlv_value_len < sizeof(*tt_data)) return; =20 tt_data =3D tvlv_value; - tvlv_value_len -=3D sizeof(*tt_data); - num_vlan =3D ntohs(tt_data->num_vlan); =20 - flex_size =3D flex_array_size(tt_data, vlan_data, num_vlan); - if (tvlv_value_len < flex_size) + tt_data_sz =3D struct_size(tt_data, vlan_data, num_vlan); + if (tvlv_value_len < tt_data_sz) return; =20 tt_change =3D (struct batadv_tvlv_tt_change *)((void *)tt_data - + flex_size); - tvlv_value_len -=3D flex_size; + + tt_data_sz); + tvlv_value_len -=3D tt_data_sz; =20 num_entries =3D batadv_tt_entries(tvlv_value_len); =20 --=20 2.40.0