stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: stable@vger.kernel.org
Cc: Sven Eckelmann <sven@narfation.org>,
	Simon Wunderlich <sw@simonwunderlich.de>
Subject: [PATCH 4.14 04/15] batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq
Date: Mon, 16 Mar 2020 23:30:21 +0100	[thread overview]
Message-ID: <20200316223032.6236-5-sven@narfation.org> (raw)
In-Reply-To: <20200316223032.6236-1-sven@narfation.org>

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 <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/bat_iv_ogm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 8b3f9441b3a0..1dda8949734e 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1220,7 +1220,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
 	orig_node->last_seen = jiffies;
 
 	/* find packet count of corresponding one hop neighbor */
-	spin_lock_bh(&orig_node->bat_iv.ogm_cnt_lock);
+	spin_lock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock);
 	if_num = if_incoming->if_num;
 	orig_eq_count = orig_neigh_node->bat_iv.bcast_own_sum[if_num];
 	neigh_ifinfo = batadv_neigh_ifinfo_new(neigh_node, if_outgoing);
@@ -1230,7 +1230,7 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
 	} else {
 		neigh_rq_count = 0;
 	}
-	spin_unlock_bh(&orig_node->bat_iv.ogm_cnt_lock);
+	spin_unlock_bh(&orig_neigh_node->bat_iv.ogm_cnt_lock);
 
 	/* pay attention to not get a value bigger than 100 % */
 	if (orig_eq_count > neigh_rq_count)
-- 
2.20.1


  parent reply	other threads:[~2020-03-16 22:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-16 22:30 [PATCH 4.14 00/15] batman-adv: Pending fixes Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 01/15] batman-adv: Avoid spurious warnings from bat_v neigh_cmp implementation Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 02/15] batman-adv: Always initialize fragment header priority Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 03/15] batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible Sven Eckelmann
2020-03-16 22:30 ` Sven Eckelmann [this message]
2020-03-16 22:30 ` [PATCH 4.14 05/15] batman-adv: Fix internal interface indices types Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 06/15] batman-adv: update data pointers after skb_cow() Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 07/15] batman-adv: Avoid race in TT TVLV allocator helper Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 08/15] batman-adv: Fix TT sync flags for intermediate TT responses Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 09/15] batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 10/15] batman-adv: Fix debugfs path for renamed hardif Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 11/15] batman-adv: Fix debugfs path for renamed softif Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 12/15] batman-adv: Fix duplicated OGMs on NETDEV_UP Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 13/15] batman-adv: Avoid free/alloc race when handling OGM2 buffer Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 14/15] batman-adv: Avoid free/alloc race when handling OGM buffer Sven Eckelmann
2020-03-16 22:30 ` [PATCH 4.14 15/15] batman-adv: Don't schedule OGM for disabled interface Sven Eckelmann
2020-03-17 10:14 ` [PATCH 4.14 00/15] batman-adv: Pending fixes Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200316223032.6236-5-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=stable@vger.kernel.org \
    --cc=sw@simonwunderlich.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).