From patchwork Fri Oct 15 15:43:35 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 463 Return-Path: Received: from nm2.bullet.mail.ukl.yahoo.com (nm2.bullet.mail.ukl.yahoo.com [217.146.183.219]) by open-mesh.org (Postfix) with SMTP id 189141544AE for ; Fri, 15 Oct 2010 17:45:24 +0200 (CEST) Received: from [217.146.183.214] by nm2.bullet.mail.ukl.yahoo.com with NNFMP; 15 Oct 2010 15:45:24 -0000 Received: from [217.146.183.169] by tm7.bullet.mail.ukl.yahoo.com with NNFMP; 15 Oct 2010 15:45:23 -0000 Received: from [127.0.0.1] by omp1010.mail.ukl.yahoo.com with NNFMP; 15 Oct 2010 15:45:21 -0000 X-Yahoo-Newman-Id: 809629.18269.bm@omp1010.mail.ukl.yahoo.com Received: (qmail 8546 invoked from network); 15 Oct 2010 15:45:21 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.de; h=DKIM-Signature:Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=eKI+VbRqSXi0015Joep9mRdNynOUj+QLl5MOK4Sv0Ds7Va8eNZfw5xoGXSZgTfBupCfF7hWwfcFwrK1vZ9wmUwFg/ahhY7MRt+JaKj8aaDSp9KaTMonK9c/UtJWdwnHnJjrptlzYe1INKBAEQoraJysj7i2P6CM5dcSETl3zocE= ; DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1287157521; bh=EgEnRpe/XnP/liFtir1uYZjHLEVRw6deHh/kOjD+ehk=; h=Received:X-Yahoo-SMTP:X-YMail-OSG:X-Yahoo-Newman-Property:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=sUaPnpx1uXFRASCOvxD2DI0taJZAPur38RRT/72j3MLYDjupKyDmyPtZg5IG+18fcYS5l3joVer3CvtF61FlZaGVgy3J2aaKVxlf8a6YEKIlMuz5qmRXw53pVXvjwcER6YtOLu/RhBiXkf46Y17Ma5HXlGgM9kuZn3fR0S1nf1g= Received: from localhost (lindner_marek@78.225.40.81 with plain) by smtp126.mail.ukl.yahoo.com with SMTP; 15 Oct 2010 08:45:20 -0700 PDT X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- X-YMail-OSG: QZpWLCwVM1myxkDd6OkX3CVR9r1FTGZKeGpzndxUjKpF48y rz5g- X-Yahoo-Newman-Property: ymail-3 From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 15 Oct 2010 17:43:35 +0200 Message-Id: <1287157417-15369-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.1 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 1/3] batman-adv: protect against ogm packet overflow by checking table length X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Oct 2010 15:45:25 -0000 Reported-by: Sam Yeung Signed-off-by: Marek Lindner --- batman-adv/translation-table.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/batman-adv/translation-table.c b/batman-adv/translation-table.c index 9cae140..75c8ce0 100644 --- a/batman-adv/translation-table.c +++ b/batman-adv/translation-table.c @@ -60,6 +60,7 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr) struct hna_global_entry *hna_global_entry; struct hashtable_t *swaphash; unsigned long flags; + int required_bytes; spin_lock_irqsave(&bat_priv->hna_lhash_lock, flags); hna_local_entry = @@ -75,8 +76,12 @@ void hna_local_add(struct net_device *soft_iface, uint8_t *addr) /* only announce as many hosts as possible in the batman-packet and space in batman_packet->num_hna That also should give a limit to MAC-flooding. */ - if ((bat_priv->num_local_hna + 1 > (ETH_DATA_LEN - BAT_PACKET_LEN) - / ETH_ALEN) || + required_bytes = (bat_priv->num_local_hna + 1) * ETH_ALEN; + required_bytes += BAT_PACKET_LEN; + + if ((required_bytes > ETH_DATA_LEN) || + (atomic_read(&bat_priv->aggregation_enabled) && + required_bytes > MAX_AGGREGATION_BYTES) || (bat_priv->num_local_hna + 1 > 255)) { bat_dbg(DBG_ROUTES, bat_priv, "Can't add new local hna entry (%pM): "