From patchwork Thu Mar 19 13:00:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 229111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74F08C4332B for ; Thu, 19 Mar 2020 13:13:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4C11421974 for ; Thu, 19 Mar 2020 13:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623630; bh=fzdg16jit59N7FXifsHK8DKb7NghhFYVaQ6brJqnmTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Q8a+F/4p+zbZ19nFD6hnsDJPf4rw9iQcwFe3fW5kIS65g61zEPEkOqcegplOG8dJU X/SAo4TQpLMjLP5QVgSCqOlzbS33UcJy7rnM3iaJ5oRdLNQ7KKk4tnK0ReJz11L9RK u33ahni+17+2i4/+t4nZWpbCL7M2WOg7leOLuJ0A= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729202AbgCSNNt (ORCPT ); Thu, 19 Mar 2020 09:13:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:32968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727710AbgCSNNs (ORCPT ); Thu, 19 Mar 2020 09:13:48 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B28620722; Thu, 19 Mar 2020 13:13:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623627; bh=fzdg16jit59N7FXifsHK8DKb7NghhFYVaQ6brJqnmTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gGgTz9uv5N4Rzxyh03YL9PUBjxLedWC/oB0TA26cRsuaoz8cFWYHjs2eHn7sX/rTv haEt/ccnsOAvrZQBwplnCblQvL+LmMmVGihCz5DoEygrgcXuUDeaYEYJe2TWyiTzCd h3JqxN3bCKA/BbPkI6ByA6/6ctTE03vJz4kK/JMQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , =?utf-8?q?Linus_L?= =?utf-8?q?=C3=BCssing?= , Sven Eckelmann , Simon Wunderlich Subject: [PATCH 4.9 77/90] batman-adv: Use explicit tvlv padding for ELP packets Date: Thu, 19 Mar 2020 14:00:39 +0100 Message-Id: <20200319123952.254552777@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123928.635114118@linuxfoundation.org> References: <20200319123928.635114118@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sven Eckelmann commit f4156f9656feac21f4de712fac94fae964c5d402 upstream. The announcement messages of batman-adv COMPAT_VERSION 15 have the possibility to announce additional information via a dynamic TVLV part. This part is optional for the ELP packets and currently not parsed by the Linux implementation. Still out-of-tree versions are using it to transport things like neighbor hashes to optimize the rebroadcast behavior. Since the ELP broadcast packets are smaller than the minimal ethernet packet, it often has to be padded. This is often done (as specified in RFC894) with octets of zero and thus work perfectly fine with the TVLV part (making it a zero length and thus empty). But not all ethernet compatible hardware seems to follow this advice. To avoid ambiguous situations when parsing the TVLV header, just force the 4 bytes (TVLV length + padding) after the required ELP header to zero. Fixes: d6f94d91f766 ("batman-adv: ELP - adding basic infrastructure") Reported-by: Linus Lüssing Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/bat_v_elp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -335,21 +335,23 @@ out: */ int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface) { + static const size_t tvlv_padding = sizeof(__be32); struct batadv_elp_packet *elp_packet; unsigned char *elp_buff; u32 random_seqno; size_t size; int res = -ENOMEM; - size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN; + size = ETH_HLEN + NET_IP_ALIGN + BATADV_ELP_HLEN + tvlv_padding; hard_iface->bat_v.elp_skb = dev_alloc_skb(size); if (!hard_iface->bat_v.elp_skb) goto out; skb_reserve(hard_iface->bat_v.elp_skb, ETH_HLEN + NET_IP_ALIGN); - elp_buff = skb_put(hard_iface->bat_v.elp_skb, BATADV_ELP_HLEN); + elp_buff = skb_put(hard_iface->bat_v.elp_skb, + BATADV_ELP_HLEN + tvlv_padding); elp_packet = (struct batadv_elp_packet *)elp_buff; - memset(elp_packet, 0, BATADV_ELP_HLEN); + memset(elp_packet, 0, BATADV_ELP_HLEN + tvlv_padding); elp_packet->packet_type = BATADV_ELP; elp_packet->version = BATADV_COMPAT_VERSION;