Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB530C433F5 for ; Wed, 24 Nov 2021 12:30:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245551AbhKXMdN (ORCPT ); Wed, 24 Nov 2021 07:33:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:42290 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244326AbhKXM1C (ORCPT ); Wed, 24 Nov 2021 07:27:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4442B61215; Wed, 24 Nov 2021 12:16:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1637756197; bh=ugDfog9+kyYY/7Lp+YOX7sp07BZmsfiuCzCdydLZ3EA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LCQs6WEmZWY60/VLY8nq6OrECYeCbix3wI0m5Oe4gmbT++o2PdT9nyJxGZOTWtA/F UDYbOVscE1njTsULfmxQ//lc4aVa3jQO23wfHkzDcLjpTeDoFIHGjenEFOqKLQhx7d IpZ71N3jXBcFProg96ZJwxXUUSoTHn6nYtv2Qcds= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , =?UTF-8?q?Linus=20L=FCssing?= , Simon Wunderlich , Sven Eckelmann Subject: [PATCH 4.9 199/207] batman-adv: Fix own OGM check in aggregated OGMs Date: Wed, 24 Nov 2021 12:57:50 +0100 Message-Id: <20211124115710.392591096@linuxfoundation.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211124115703.941380739@linuxfoundation.org> References: <20211124115703.941380739@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus L?ssing commit d8bf0c01642275c7dca1e5d02c34e4199c200b1f upstream. The own OGM check is currently misplaced and can lead to the following issues: For one thing we might receive an aggregated OGM from a neighbor node which has our own OGM in the first place. We would then not only skip our own OGM but erroneously also any other, following OGM in the aggregate. For another, we might receive an OGM aggregate which has our own OGM in a place other then the first one. Then we would wrongly not skip this OGM, leading to populating the orginator and gateway table with ourself. Fixes: 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic") Signed-off-by: Linus L?ssing Signed-off-by: Simon Wunderlich [ bp: 4.9 backported: adjust context, correct fixes line ] Signed-off-by: Sven Eckelmann Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/bat_v_ogm.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -690,6 +690,12 @@ static void batadv_v_ogm_process(const s ntohl(ogm_packet->seqno), ogm_throughput, ogm_packet->ttl, ogm_packet->version, ntohs(ogm_packet->tvlv_len)); + if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) { + batadv_dbg(BATADV_DBG_BATMAN, bat_priv, + "Drop packet: originator packet from ourself\n"); + return; + } + /* If the troughput metric is 0, immediately drop the packet. No need to * create orig_node / neigh_node for an unusable route. */ @@ -788,11 +794,6 @@ int batadv_v_ogm_packet_recv(struct sk_b if (batadv_is_my_mac(bat_priv, ethhdr->h_source)) return NET_RX_DROP; - ogm_packet = (struct batadv_ogm2_packet *)skb->data; - - if (batadv_is_my_mac(bat_priv, ogm_packet->orig)) - return NET_RX_DROP; - batadv_inc_counter(bat_priv, BATADV_CNT_MGMT_RX); batadv_add_counter(bat_priv, BATADV_CNT_MGMT_RX_BYTES, skb->len + ETH_HLEN);