Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4480980imw; Tue, 19 Jul 2022 07:24:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1trbLOPTNKvyXPXXhjUjBqZHlfTZ0ZAYwuqbp0GlmYHvJexykvvOsuqCsT7lsfoLlkDjx55 X-Received: by 2002:a05:6402:510c:b0:43a:e041:a371 with SMTP id m12-20020a056402510c00b0043ae041a371mr43315172edd.424.1658240681438; Tue, 19 Jul 2022 07:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658240681; cv=none; d=google.com; s=arc-20160816; b=Q+hIAPhXTZUt8A95TdNA9neqJ+Wzk0B6c50yEuZ0UCHmLJFgZUPA8nhSYclx2G/FEE i1lIHymPWdmWFHJDSj1XGHddXG/aZ7qNCnoDi+bqp+xLnI9ws7zD8LGcLbB5spwlufx5 q891Mi/bjkxp8cdv6ZWJEtB1VJbVTnNd4M33ZNlOCF8+6Z4+RIAWRBWPci9XGuB4lzQF W2lQMNV4Ame8kvdFL7dkKsbGRlwhJ/yYUjwGU9Z2cq6k2K9zes4JjI3zzBFS3PAKGSGo tRnKzBTqYeHgF/TNKuEndfAY2dnlyDJz7Rl3uAHz49YqnWYZfKL9ozjrgLSSwpttISoW ecmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y8M5dfdvng67IUJfCeYdfwzeDaOSbrxLySnWiqSPTAA=; b=qF2dNspxJs4ofmYZ7AuMzNlAtnrPdQyb5/qEtrMQN0XAopr6ZYGg4LqEsK0vHp4nFd Ko1wHsxxRhTdI4sgGnoHQxPepVBjwPJRFrVd8ioYEKyB2+ajrE4o96cFL1JVearUHJwg xZjacwI+g5rNTxzTDQ3x+JR1JzAirCJbAzuCKUolAlG0euat24UZaUdC+SbfIpzdSX/L 3fPo1pz1HJNbdAraUVNjyRKL34G0LWKF+zxd7wc0SamY/tM7fYSLjDjyk1ccoP8m895T 6mdBiTpt/CzhXXJrtaGxLwHjpO8KDZxKwhZHJZuyMbuyK10gDXbkzcaGBNTIiVgQpa06 o2NQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0glW1TEm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb38-20020a1709071ca600b0072b193ac94bsi26036521ejc.627.2022.07.19.07.24.13; Tue, 19 Jul 2022 07:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0glW1TEm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242355AbiGSM43 (ORCPT + 99 others); Tue, 19 Jul 2022 08:56:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242282AbiGSMzd (ORCPT ); Tue, 19 Jul 2022 08:55:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC6569A5C2; Tue, 19 Jul 2022 05:22:10 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A999B61632; Tue, 19 Jul 2022 12:22:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B045C341C6; Tue, 19 Jul 2022 12:22:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658233329; bh=Y5ulbQkpBh1mvGqG++QTnnact+0szAuiE1B9TbrCcZI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0glW1TEmAO5ALk9+uVIfC3YB2D6G3ITLM573cYApwG7eZtePNomfIjgFN0CjgHZNF rBVf31fg7XS9E8CJmewGdkVJOhJPaqicVowm1cUhjKtGx2CjWJOAWrrdnEC7wCdBrB PQC9/7aiMe8ZTGryXfniMT997Gbyvp2moqDfLpGo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tom Yan , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 5.18 085/231] netfilter: nf_log: incorrect offset to network header Date: Tue, 19 Jul 2022 13:52:50 +0200 Message-Id: <20220719114721.974291914@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114714.247441733@linuxfoundation.org> References: <20220719114714.247441733@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pablo Neira Ayuso [ Upstream commit 7a847c00eeba9744353ecdfad253143b9115678a ] NFPROTO_ARP is expecting to find the ARP header at the network offset. In the particular case of ARP, HTYPE= field shows the initial bytes of the ethernet header destination MAC address. netdev out: IN= OUT=bridge0 MACSRC=c2:76:e5:71:e1:de MACDST=36:b0:4a:e2:72:ea MACPROTO=0806 ARP HTYPE=14000 PTYPE=0x4ae2 OPCODE=49782 NFPROTO_NETDEV egress hook is also expecting to find the IP headers at the network offset. Fixes: 35b9395104d5 ("netfilter: add generic ARP packet logger") Reported-by: Tom Yan Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/nf_log_syslog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c index 13234641cdb3..7000e069bc07 100644 --- a/net/netfilter/nf_log_syslog.c +++ b/net/netfilter/nf_log_syslog.c @@ -61,7 +61,7 @@ dump_arp_packet(struct nf_log_buf *m, unsigned int logflags; struct arphdr _arph; - ah = skb_header_pointer(skb, 0, sizeof(_arph), &_arph); + ah = skb_header_pointer(skb, nhoff, sizeof(_arph), &_arph); if (!ah) { nf_log_buf_add(m, "TRUNCATED"); return; @@ -90,7 +90,7 @@ dump_arp_packet(struct nf_log_buf *m, ah->ar_pln != sizeof(__be32)) return; - ap = skb_header_pointer(skb, sizeof(_arph), sizeof(_arpp), &_arpp); + ap = skb_header_pointer(skb, nhoff + sizeof(_arph), sizeof(_arpp), &_arpp); if (!ap) { nf_log_buf_add(m, " INCOMPLETE [%zu bytes]", skb->len - sizeof(_arph)); @@ -144,7 +144,7 @@ static void nf_log_arp_packet(struct net *net, u_int8_t pf, nf_log_dump_packet_common(m, pf, hooknum, skb, in, out, loginfo, prefix); - dump_arp_packet(m, loginfo, skb, 0); + dump_arp_packet(m, loginfo, skb, skb_network_offset(skb)); nf_log_buf_close(m); } @@ -829,7 +829,7 @@ static void nf_log_ip_packet(struct net *net, u_int8_t pf, if (in) dump_ipv4_mac_header(m, loginfo, skb); - dump_ipv4_packet(net, m, loginfo, skb, 0); + dump_ipv4_packet(net, m, loginfo, skb, skb_network_offset(skb)); nf_log_buf_close(m); } -- 2.35.1