From patchwork Fri Sep 15 18:10:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 13387372 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53CB815EBE for ; Fri, 15 Sep 2023 18:12:50 +0000 (UTC) Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C0D1FD6 for ; Fri, 15 Sep 2023 11:12:49 -0700 (PDT) From: Sebastian Andrzej Siewior DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1694801567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QDVmPfCORO/1Or+oAHB6H3kmDKXMfRRRDUSuxthS2yI=; b=ntKL7rntnkteVTwPNgMifB+eDAUyBkkLe91OlgxEkZAy8UalT0EepTrzDB34dlG+KPdTD9 M6y6LSfN0vVIocOywhE3f46ZP0qwTkobSo/V57RqDpL8Zx6u0tsCYfqjE0nyR5GIlmqA1t nMwgpmrVRyKky5V5SvmiRp8sQrThYwE7nUub/rUj0y8kGyxyUSR+vxr1/H/88u/pIT/uX6 haasSdlxsbRBcEW64/5elQqzaQyfK59FCJKD6r1RIEl2xGJax9lOBoMUxxOQfwqavcTe1L QnLSkXDBndnTFigLJiFQnksRlMVXLZMqGqtRmR4OeVEoTqTEQvTCep6DAC7jmg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1694801567; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QDVmPfCORO/1Or+oAHB6H3kmDKXMfRRRDUSuxthS2yI=; b=GrYff03ElMGvcb2Vd/ZDMn2GLUt1yB6HAsPuj3GUmgFOIRI70ivANlFOo3Y/ksnzxnvKIE XKDqIV6JpkWohJCw== To: netdev@vger.kernel.org Cc: "David S. Miller" , Andreas Oetken , Eric Dumazet , Jakub Kicinski , Lukasz Majewski , Paolo Abeni , Shuah Khan , Thomas Gleixner , Tristram.Ha@microchip.com, Sebastian Andrzej Siewior Subject: [PATCH net 1/5] net: hsr: Properly parse HSRv1 supervisor frames. Date: Fri, 15 Sep 2023 20:10:02 +0200 Message-Id: <20230915181006.2086061-2-bigeasy@linutronix.de> In-Reply-To: <20230915181006.2086061-1-bigeasy@linutronix.de> References: <20230915181006.2086061-1-bigeasy@linutronix.de> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org From: Lukasz Majewski While adding support for parsing the redbox supervision frames, the author added `pull_size' and `total_pull_size' to track the amount of bytes that were pulled from the skb during while parsing the skb so it can be reverted/ pushed back at the end. In the process probably copy&paste error occurred and for the HSRv1 case the ethhdr was used instead of the hsr_tag. Later the hsr_tag was used instead of hsr_sup_tag. The later error didn't matter because both structs have the size so HSRv0 was still working. It broke however HSRv1 parsing because struct ethhdr is larger than struct hsr_tag. Reinstate the old pulling flow and pull first ethhdr, hsr_tag in v1 case followed by hsr_sup_tag. [bigeasy: commit message] Fixes: eafaa88b3eb7 ("net: hsr: Add support for redbox supervision frames")' Suggested-by: Tristram.Ha@microchip.com Signed-off-by: Lukasz Majewski Signed-off-by: Sebastian Andrzej Siewior Reviewed-by: Sebastian Andrzej Siewior --- net/hsr/hsr_framereg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index b77f1189d19d1..6d14d935ee828 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -288,13 +288,13 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) /* And leave the HSR tag. */ if (ethhdr->h_proto == htons(ETH_P_HSR)) { - pull_size = sizeof(struct ethhdr); + pull_size = sizeof(struct hsr_tag); skb_pull(skb, pull_size); total_pull_size += pull_size; } /* And leave the HSR sup tag. */ - pull_size = sizeof(struct hsr_tag); + pull_size = sizeof(struct hsr_sup_tag); skb_pull(skb, pull_size); total_pull_size += pull_size;