aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2010-10-19 05:59:13 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2010-10-19 13:04:16 -0400
commit24fb009bae18f2ef712800ee9b2f52c177d9d3f9 (patch)
treef34c7612e242c878ac09d20bde0ac773c8fccf4e
parent3c45603024c8dd5321f9504b351df3cb825e5951 (diff)
Staging: batman-adv: protect against ogm packet overflow by checking table length
Reported-by: Sam Yeung <sam.cwyeung@gmail.com> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Sven Eckelmann <sven.eckelmann@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/batman-adv/translation-table.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/staging/batman-adv/translation-table.c b/drivers/staging/batman-adv/translation-table.c
index 12b23259c385..681ccbda3eac 100644
--- a/drivers/staging/batman-adv/translation-table.c
+++ b/drivers/staging/batman-adv/translation-table.c
@@ -59,6 +59,7 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)
59 struct hna_global_entry *hna_global_entry; 59 struct hna_global_entry *hna_global_entry;
60 struct hashtable_t *swaphash; 60 struct hashtable_t *swaphash;
61 unsigned long flags; 61 unsigned long flags;
62 int required_bytes;
62 63
63 spin_lock_irqsave(&bat_priv->hna_lhash_lock, flags); 64 spin_lock_irqsave(&bat_priv->hna_lhash_lock, flags);
64 hna_local_entry = 65 hna_local_entry =
@@ -74,8 +75,12 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr)
74 /* only announce as many hosts as possible in the batman-packet and 75 /* only announce as many hosts as possible in the batman-packet and
75 space in batman_packet->num_hna That also should give a limit to 76 space in batman_packet->num_hna That also should give a limit to
76 MAC-flooding. */ 77 MAC-flooding. */
77 if ((bat_priv->num_local_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) 78 required_bytes = (bat_priv->num_local_hna + 1) * ETH_ALEN;
78 / ETH_ALEN) || 79 required_bytes += BAT_PACKET_LEN;
80
81 if ((required_bytes > ETH_DATA_LEN) ||
82 (atomic_read(&bat_priv->aggregation_enabled) &&
83 required_bytes > MAX_AGGREGATION_BYTES) ||
79 (bat_priv->num_local_hna + 1 > 255)) { 84 (bat_priv->num_local_hna + 1 > 255)) {
80 bat_dbg(DBG_ROUTES, bat_priv, 85 bat_dbg(DBG_ROUTES, bat_priv,
81 "Can't add new local hna entry (%pM): " 86 "Can't add new local hna entry (%pM): "