netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Quartulli <a@unstable.cc>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Sven Eckelmann <sven.eckelmann@open-mesh.com>,
	Marek Lindner <mareklindner@neomailbox.ch>,
	Antonio Quartulli <a@unstable.cc>
Subject: [PATCH 6/8] batman-adv: Fix integer overflow in batadv_iv_ogm_calc_tq
Date: Wed, 18 May 2016 13:04:50 +0800	[thread overview]
Message-ID: <1463547892-11290-7-git-send-email-a@unstable.cc> (raw)
In-Reply-To: <1463547892-11290-1-git-send-email-a@unstable.cc>

From: Sven Eckelmann <sven.eckelmann@open-mesh.com>

The undefined behavior sanatizer detected an signed integer overflow in a
setup with near perfect link quality

    UBSAN: Undefined behaviour in net/batman-adv/bat_iv_ogm.c:1246:25
    signed integer overflow:
    8713350 * 255 cannot be represented in type 'int'

The problems happens because the calculation of mixed unsigned and signed
integers resulted in an integer multiplication.

      batadv_ogm_packet::tq (u8 255)
    * tq_own (u8 255)
    * tq_asym_penalty (int 134; max 255)
    * tq_iface_penalty (int 255; max 255)

The tq_iface_penalty, tq_asym_penalty and inv_asym_penalty can just be
changed to unsigned int because they are not expected to become negative.

Fixes: c039876892e3 ("batman-adv: add WiFi penalty")
Signed-off-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
---
 net/batman-adv/bat_iv_ogm.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
index 1b5bbafc0fa3..ce2f203048d3 100644
--- a/net/batman-adv/bat_iv_ogm.c
+++ b/net/batman-adv/bat_iv_ogm.c
@@ -1180,9 +1180,10 @@ static bool batadv_iv_ogm_calc_tq(struct batadv_orig_node *orig_node,
 	u8 total_count;
 	u8 orig_eq_count, neigh_rq_count, neigh_rq_inv, tq_own;
 	unsigned int neigh_rq_inv_cube, neigh_rq_max_cube;
-	int tq_asym_penalty, inv_asym_penalty, if_num;
+	int if_num;
+	unsigned int tq_asym_penalty, inv_asym_penalty;
 	unsigned int combined_tq;
-	int tq_iface_penalty;
+	unsigned int tq_iface_penalty;
 	bool ret = false;
 
 	/* find corresponding one hop neighbor */
-- 
2.8.2

  parent reply	other threads:[~2016-05-18  5:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1463547892-11290-1-git-send-email-a@unstable.cc>
2016-05-18  5:04 ` [PATCH 1/8] batman-adv: fix skb deref after free Antonio Quartulli
2016-05-18  5:04 ` [PATCH 2/8] batman-adv: Avoid nullptr derefence in batadv_v_neigh_is_sob Antonio Quartulli
2016-05-18  5:04 ` [PATCH 3/8] batman-adv: Fix refcnt leak in batadv_v_neigh_* Antonio Quartulli
2016-05-18  5:04 ` [PATCH 4/8] batman-adv: Fix unexpected free of bcast_own on add_if error Antonio Quartulli
2016-05-18  5:04 ` [PATCH 5/8] batman-adv: make sure ELP/OGM orig MAC is updated on address change Antonio Quartulli
2016-05-18  5:04 ` Antonio Quartulli [this message]
2016-05-18  5:04 ` [PATCH 7/8] batman-adv: Avoid duplicate neigh_node additions Antonio Quartulli
2016-05-18  5:04 ` [PATCH 8/8] batman-adv: initialize ELP orig address on secondary interfaces Antonio Quartulli
     [not found] ` <1463547892-11290-1-git-send-email-a-2CpIooy/SPIKlTDg6p0iyA@public.gmane.org>
2016-05-18  8:00   ` pull request: batman-adv 20160518 Sven Eckelmann
2016-05-19 18:51 ` David Miller

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=1463547892-11290-7-git-send-email-a@unstable.cc \
    --to=a@unstable.cc \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=mareklindner@neomailbox.ch \
    --cc=netdev@vger.kernel.org \
    --cc=sven.eckelmann@open-mesh.com \
    /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).