From patchwork Fri Dec 10 12:26:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ignacy_Gaw=C4=99dzki?= X-Patchwork-Id: 12669531 X-Patchwork-Delegate: kuba@kernel.org 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 EDBFAC433FE for ; Fri, 10 Dec 2021 13:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241481AbhLJNMp (ORCPT ); Fri, 10 Dec 2021 08:12:45 -0500 Received: from str75-3-78-193-33-39.fbxo.proxad.net ([78.193.33.39]:42334 "EHLO mail.qult.net" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S241437AbhLJNMo (ORCPT ); Fri, 10 Dec 2021 08:12:44 -0500 X-Greylist: delayed 2587 seconds by postgrey-1.27 at vger.kernel.org; Fri, 10 Dec 2021 08:12:44 EST Received: from zenon.in.qult.net ([192.168.64.1]) by mail.qult.net with esmtp (Exim 4.90_1) (envelope-from ) id 1mveyR-0003vf-Bn for netdev@vger.kernel.org; Fri, 10 Dec 2021 13:26:03 +0100 Received: from ig by zenon.in.qult.net with local (Exim 4.94.2) (envelope-from ) id 1mveyO-00FZgc-Ge for netdev@vger.kernel.org; Fri, 10 Dec 2021 13:26:00 +0100 Date: Fri, 10 Dec 2021 13:26:00 +0100 From: Ignacy =?utf-8?b?R2F3xJlkemtp?= To: netdev@vger.kernel.org Subject: [PATCH] netfilter: fix regression in looped (broad|multi)cast's MAC handing Message-ID: <20211210122600.mrduxdw2uwpwoqbr@zenon.in.qult.net> MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In 5648b5e1169f, the test for non-empty MAC header introduced in 2c38de4c1f8da7 has been replaced with a test for a set MAC header, which breaks the case when the MAC header has been reset (using skb_reset_mac_header), as is the case with looped-back multicast packets. This patch adds a test for a non-empty MAC header in addition to the test for a set MAC header. The same two tests are also implemented in nfnetlink_log.c, where the initial code of 2c38de4c1f8da7 has not been touched, but where supposedly the same situation may happen. Signed-off-by: Ignacy Gawędzki --- net/netfilter/nfnetlink_log.c | 3 ++- net/netfilter/nfnetlink_queue.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index 691ef4cffdd9..7f83f9697fc1 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c @@ -556,7 +556,8 @@ __build_packet_message(struct nfnl_log_net *log, goto nla_put_failure; if (indev && skb->dev && - skb->mac_header != skb->network_header) { + skb_mac_header_was_set(skb) && + skb_mac_header_len(skb) != 0) { struct nfulnl_msg_packet_hw phw; int len; diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index 4acc4b8e9fe5..959527708e38 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -560,7 +560,8 @@ nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue, goto nla_put_failure; if (indev && entskb->dev && - skb_mac_header_was_set(entskb)) { + skb_mac_header_was_set(entskb) && + skb_mac_header_len(entskb) != 0) { struct nfqnl_msg_packet_hw phw; int len;