From nobody Sun Dec 12 18:11:48 2021 X-Original-To: dev-commits-src-all@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 83D6618C855C; Sun, 12 Dec 2021 18:11:50 +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 4JBt5108CSz3k2b; Sun, 12 Dec 2021 18:11:48 +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 BB0EE25B8E; Sun, 12 Dec 2021 18:11:48 +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 1BCIBm5c064950; Sun, 12 Dec 2021 18:11:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BCIBmX6064949; Sun, 12 Dec 2021 18:11:48 GMT (envelope-from git) Date: Sun, 12 Dec 2021 18:11:48 GMT Message-Id: <202112121811.1BCIBmX6064949@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Kristof Provost Subject: git: 80c2f5fc0aed - stable/13 - if_pflog: fix packet length List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 80c2f5fc0aedda284babe1bffbddb4fc29314ff0 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639332709; 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=bjB52WcVahqp9s29TocVwbT28slrA87puzj/vkMfKHk=; b=ZQdoRJQk/elzQefNsjYF09izolC30KM3fXkmXXPVQiIJHfXLdRFrFvzm4k/q64uxJG/2h6 uK4rep0Gfu08JlHW8McHjuTmVHuEiVyRl6QmaWBmGN5Yvplz5g/gxvqNqQ5iLWfdSmojlt E+Ofy4ab2KthuM0w/3wGcLjAGLAPbz7psVypYKgNnj8eA0BSldjs5z6K1KbFJA/BRhkT6p eyPgzT8fVgutnb8B+FqWSIIBw/i4akytwuVRc1gtWkHRBG2tj5UjZ6q+ud4OEZzNMGh2Gf ODyHpkV4VwrY3Vj1m1cKd1wLnFMTy5Lkj9jSjuijpyu6zE+QBcnzPwPTW2agFA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639332709; a=rsa-sha256; cv=none; b=sd9qMugYPTQoD8KZrmstNl7hXvdo94rIH6fWASUS220fF5ohn3Y9ej3zno3MyWenSntBAP CDGHKpxf/TkCSvpWME69PaCeiZbPo7v5ifwjlahczy7m2pnPz5yiH6alj+X51MGiCZvO9C 6CHyj5pK3JinASaqq/25kXJzu/xQlMQSPz3jftA7i2LBGtBC1whceWeO7IeN4ktGa4vvi6 83KHKrrimc/33GToR9P1Xau2TQ+OaTwYiR54iuyGeAZUPnkc2Pf/OYX1jWFs/gVzZWgg3J KSKL6RgamM2O5EdMZ9DFO3cWqLdUDJHWcZ3SO/AKQ9Q2hn5nw2dw7jT0K6TFzg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=80c2f5fc0aedda284babe1bffbddb4fc29314ff0 commit 80c2f5fc0aedda284babe1bffbddb4fc29314ff0 Author: Kristof Provost AuthorDate: 2021-12-02 07:22:34 +0000 Commit: Kristof Provost CommitDate: 2021-12-11 09:38:50 +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 (cherry picked from commit 6d4baa0d011cb3e78b4b08415568e71c0aab00fe) --- 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;