Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34381 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932848AbeB1PwL (ORCPT ); Wed, 28 Feb 2018 10:52:11 -0500 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Sven Eckelmann" , "Simon Wunderlich" Date: Wed, 28 Feb 2018 15:20:21 +0000 Message-ID: Subject: [PATCH 3.2 027/140] batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq In-Reply-To: Sender: stable-owner@vger.kernel.org List-ID: 3.2.100-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Sven Eckelmann commit 5ba7dcfe77037b67016263ea597a8b431692ecab upstream. The originator node object orig_neigh_node is used to when accessing the bcast_own(_sum) and real_packet_count information. The access to them has to be protected with the spinlock in orig_neigh_node. But the function uses the lock in orig_node instead. This is incorrect because they could be two different originator node objects. Fixes: 0ede9f41b217 ("batman-adv: protect bit operations to count OGMs with spinlock") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich [bwh: Backported to 3.2: - s/bat_iv\.ogm_cnt_lock/ogm_cnt_lock/ - Adjust context] Signed-off-by: Ben Hutchings --- net/batman-adv/bat_iv_ogm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -760,10 +760,10 @@ static int bat_ogm_calc_tq(struct orig_n orig_node->last_valid = jiffies; /* find packet count of corresponding one hop neighbor */ - spin_lock_bh(&orig_node->ogm_cnt_lock); + spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); orig_eq_count = orig_neigh_node->bcast_own_sum[if_incoming->if_num]; neigh_rq_count = neigh_node->real_packet_count; - spin_unlock_bh(&orig_node->ogm_cnt_lock); + spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); /* pay attention to not get a value bigger than 100 % */ total_count = (orig_eq_count > neigh_rq_count ?