From nobody Sat Dec 4 08:45:21 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 6189818C8D4B; Sat, 4 Dec 2021 08:45:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J5jv60QZSz3kH7; Sat, 4 Dec 2021 08:45:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E26CB2103B; Sat, 4 Dec 2021 08:45:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B48jLbM010690; Sat, 4 Dec 2021 08:45:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B48jLg9010689; Sat, 4 Dec 2021 08:45:21 GMT (envelope-from git) Date: Sat, 4 Dec 2021 08:45:21 GMT Message-Id: <202112040845.1B48jLg9010689@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 6d4baa0d011c - main - if_pflog: fix packet length List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 6d4baa0d011cb3e78b4b08415568e71c0aab00fe Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638607522; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=9rPGgoHMbR/XyR09beDlzCF3XpLxG36mYlA1GqD6lMk=; b=Xx0fMeFyHyP9IL4BOEh6JvdHFaNtj0XICLQLtHcY5ktyuZle5hBtGJVQaeoDsx+8pMfOZU NfBGrfQerYyqNZFFuv9cq8m7whLKhf50ki8LN9kVcud0e2PmyHC5f8yDIvWTh3QuK0wJG0 ShB3Wl/7IXcBf/svV/WYbmejnGzawRcPhIdSQYOOVTv9YzFDEpUikkWt5ELND8RYhkUZoe 05siqWT1QMAekk89yFqXyCXVAfGHu7d8w8aLkhswZelNIM5srDNMl1qdrEKMftFplU2jQh toAlWAvcWPt1FwbvNvg64WY1Dug5EnP2f+lfJOCGY63GYAaoFmtTAcwtVrqFBw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638607522; a=rsa-sha256; cv=none; b=l0yZFmQNurv2gy4bM3LyzTazF28NaIeQkCfYiYvqvvL4xyvIurA+bkWRnB/Eq1Cm5HMeaL ZJW1izzKYgT6aP2w0z9HewTRRZ7AK1HT0WyuB/ba+j9+Bnhhaxb0L92mUDPDBZEdMCrHGX 0o34IdV78+2WZ2usMZWxI0LlxT1H/ZiYdb4qSH9FuylIpFEVZUbV2nbwEyd3jgt8Zyq2AR YLXCjNoaXeMCz/AEGJQY0KSJ5tyhpptDObTjCD4vCbv24iOTs0QUlSDB9Y26w9zUOoUQKq vefbS3KrUc6MtNEEpWNozcIyMeR2MGzZvEdE24ZVFYDkrq2Irxo47Xle012vCg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6d4baa0d011cb3e78b4b08415568e71c0aab00fe commit 6d4baa0d011cb3e78b4b08415568e71c0aab00fe Author: Kristof Provost AuthorDate: 2021-12-02 07:22:34 +0000 Commit: Kristof Provost CommitDate: 2021-12-04 07:42:55 +0000 if_pflog: fix packet length There were two issues with the new pflog packet length. The first is that the length is expected to be a multiple of sizeof(long), but we'd assumed it had to be a multiple of sizeof(uint32_t). The second is that there's some broken software out there (such as Wireshark) that makes incorrect assumptions about the amount of padding. That is, Wireshark assumes there's always three bytes of padding, rather than however much is needed to get to a multiple of sizeof(long). Fix this by adding extra padding, and a fake field to maintain Wireshark's assumption. Reported by: Ozkan KIRIK Tested by: Ozkan KIRIK MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D33236 --- sys/net/if_pflog.h | 8 ++++++-- sys/netpfil/pf/if_pflog.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/net/if_pflog.h b/sys/net/if_pflog.h index c77d8da1440a..93a69a2bb3a5 100644 --- a/sys/net/if_pflog.h +++ b/sys/net/if_pflog.h @@ -31,6 +31,8 @@ #ifndef _NET_IF_PFLOG_H_ #define _NET_IF_PFLOG_H_ +#include + #define PFLOGIFS_MAX 16 #define PFLOG_RULESET_NAME_SIZE 16 @@ -51,11 +53,13 @@ struct pfloghdr { u_int8_t dir; u_int8_t pad[3]; u_int32_t ridentifier; + u_int8_t reserve; /* Appease broken software like Wireshark. */ + u_int8_t pad2[3]; }; -#define PFLOG_HDRLEN sizeof(struct pfloghdr) +#define PFLOG_HDRLEN BPF_WORDALIGN(offsetof(struct pfloghdr, pad2)) /* minus pad, also used as a signature */ -#define PFLOG_REAL_HDRLEN offsetof(struct pfloghdr, pad) +#define PFLOG_REAL_HDRLEN offsetof(struct pfloghdr, pad2) #ifdef _KERNEL struct pf_rule; diff --git a/sys/netpfil/pf/if_pflog.c b/sys/netpfil/pf/if_pflog.c index 4853c1301d6f..261c9f2a4087 100644 --- a/sys/netpfil/pf/if_pflog.c +++ b/sys/netpfil/pf/if_pflog.c @@ -215,7 +215,7 @@ pflog_packet(struct pfi_kkif *kif, struct mbuf *m, sa_family_t af, u_int8_t dir, return (0); bzero(&hdr, sizeof(hdr)); - hdr.length = PFLOG_HDRLEN; + hdr.length = PFLOG_REAL_HDRLEN; hdr.af = af; hdr.action = rm->action; hdr.reason = reason;