From nobody Tue May 28 20:31:26 2024 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 4Vpkgf3bcRz5L6B1; Tue, 28 May 2024 20:31:26 +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 4Vpkgf214cz4jnM; Tue, 28 May 2024 20:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716928286; 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=mTWm56XuDhbA9C4ndx5TxMIezQfGHp6AyewdbLJ2OEs=; b=HQGL0Ri5Lz2bTvbj6erqwXxEvG3z9RM0klM4bdDznS6sYgBwtz821G6DH2cufLFpU7mLIb x815v7+np3250KOBKRCwModWnkDdg4Lxi8vIbkpPmSfc8IBFtSPdWtwRUUTNuCOXKO00gy V6vDB5f2ft2S3Fyf1VuanCyZfMBdxcrey0vXouVz8COXFGm5fNLEenl2kR97db9h/LAhAO udYULXNUfoh2cTWsQoNa8FmOi5Odi4/XnYrHSsGbcskkWCNx7HpZy1GHind8+hvJTcs+ep OFgBbsKNtxgkDAsBaP4IgZJEJqhgD1MIxnAwteR5ONViJhRAtk14doCa8WfkcQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716928286; a=rsa-sha256; cv=none; b=BRNmWD3QONh3pESwmPInVaFz4XmfNXTmyJk3I+21ZDRtpPM2Z0Dno865kICf8iSFeSF+AF mqJnPkL7SW3jQtTirS0AInw+sKOgPrnZ6Oz+9gQKdzqaQNmbM1VOf1AE95FA1qph1Xxmr2 h9YirOTKP22yiRj3yDQVHgXEIst9igwF3jN3MzFgPg2DZ4EnK3I5G3AMPmY8c0VcwsG5k3 0dPT5PykUrKY3wkn9glRkczZiBVQfjZlsUty2NxStBfjW2dgvB0V1DeU5GmR3FTRNDTvjX m4tI7FY8pvaUee3IAqNZp3V4Z0G+ZFR5MG8WEZiuKEeicuXh+xgK2VKXZnjMIA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716928286; 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=mTWm56XuDhbA9C4ndx5TxMIezQfGHp6AyewdbLJ2OEs=; b=f3J/2wEQQPElZWDbMpCCBVowwii7jSamxU8Ire6nJ+h+1r7Hayfp/NucR+5IloQcm5ACa9 XgczNaf37LP7uZ8q2VZsKrV3tMrzqJod/LyuSlIJ1Pj3QRmJNO9A3cFnpFIM/J4PodyYJ5 7Or1W+Qok9LSIbGuDtYGUTNxCTebDOoOfF1vUeQu6kgCcBg1VFojo3Xmrf1Pr/x3knSnOA TaPRritjew3S3RCEU8hgBYyzW7I1c8bGJv4A6GnD9lqUFaQhsSfZXeswL2hbsxGBSw7BBr Gqnd7Pv651a83UhIPWDfYMvHqMAEZ0k7+aXoTOy/7sFrCF1CWU+AXmKYQxXKQw== 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 4Vpkgf1ccCzRcd; Tue, 28 May 2024 20:31:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44SKVQX6068141; Tue, 28 May 2024 20:31:26 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44SKVQTP068138; Tue, 28 May 2024 20:31:26 GMT (envelope-from git) Date: Tue, 28 May 2024 20:31:26 GMT Message-Id: <202405282031.44SKVQTP068138@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: 6ee3e376823f - main - pf: fix incorrect anchor_call to userspace 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: 6ee3e376823fc16b04ab45663661f27246e7b004 Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=6ee3e376823fc16b04ab45663661f27246e7b004 commit 6ee3e376823fc16b04ab45663661f27246e7b004 Author: Kristof Provost AuthorDate: 2024-05-24 11:20:12 +0000 Commit: Kristof Provost CommitDate: 2024-05-28 20:27:22 +0000 pf: fix incorrect anchor_call to userspace 777a4702c changed how we copy out the anchor_call string, and incorrectly limited it to 8 (4 on 32-bit systems) bytes. Fix that so we get the full anchor path, rather than just the first few characters. PR: 279225 Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/net/pfvar.h | 2 +- sys/netpfil/pf/pf_nl.c | 2 +- sys/netpfil/pf/pf_ruleset.c | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sys/net/pfvar.h b/sys/net/pfvar.h index 88fb99ead84e..d1aa57a941cc 100644 --- a/sys/net/pfvar.h +++ b/sys/net/pfvar.h @@ -2474,7 +2474,7 @@ void pf_init_keth(struct pf_keth_ruleset *); int pf_kanchor_setup(struct pf_krule *, const struct pf_kruleset *, const char *); int pf_kanchor_copyout(const struct pf_kruleset *, - const struct pf_krule *, char *); + const struct pf_krule *, char *, size_t); int pf_kanchor_nvcopyout(const struct pf_kruleset *, const struct pf_krule *, nvlist_t *); void pf_kanchor_remove(struct pf_krule *); diff --git a/sys/netpfil/pf/pf_nl.c b/sys/netpfil/pf/pf_nl.c index 307e1ca1689d..8f0349d6f121 100644 --- a/sys/netpfil/pf/pf_nl.c +++ b/sys/netpfil/pf/pf_nl.c @@ -982,7 +982,7 @@ pf_handle_getrule(struct nlmsghdr *hdr, struct nl_pstate *npt) nlattr_add_u64(nw, PF_RT_STATES_TOTAL, counter_u64_fetch(rule->states_tot)); nlattr_add_u64(nw, PF_RT_SRC_NODES, counter_u64_fetch(rule->src_nodes)); - error = pf_kanchor_copyout(ruleset, rule, anchor_call); + error = pf_kanchor_copyout(ruleset, rule, anchor_call, sizeof(anchor_call)); MPASS(error == 0); nlattr_add_string(nw, PF_RT_ANCHOR_CALL, anchor_call); diff --git a/sys/netpfil/pf/pf_ruleset.c b/sys/netpfil/pf/pf_ruleset.c index 38cc1eae419f..fc0651f8a0e8 100644 --- a/sys/netpfil/pf/pf_ruleset.c +++ b/sys/netpfil/pf/pf_ruleset.c @@ -368,16 +368,16 @@ pf_kanchor_setup(struct pf_krule *r, const struct pf_kruleset *s, int pf_kanchor_copyout(const struct pf_kruleset *rs, const struct pf_krule *r, - char *anchor_call) + char *anchor_call, size_t anchor_call_len) { anchor_call[0] = 0; if (r->anchor == NULL) goto done; if (!r->anchor_relative) { - strlcpy(anchor_call, "/", sizeof(anchor_call)); + strlcpy(anchor_call, "/", anchor_call_len); strlcat(anchor_call, r->anchor->path, - sizeof(anchor_call)); + anchor_call_len); } else { char a[MAXPATHLEN]; char *p; @@ -391,7 +391,7 @@ pf_kanchor_copyout(const struct pf_kruleset *rs, const struct pf_krule *r, p = a; *p = 0; strlcat(anchor_call, "../", - sizeof(anchor_call)); + anchor_call_len); } if (strncmp(a, r->anchor->path, strlen(a))) { printf("pf_anchor_copyout: '%s' '%s'\n", a, @@ -400,12 +400,12 @@ pf_kanchor_copyout(const struct pf_kruleset *rs, const struct pf_krule *r, } if (strlen(r->anchor->path) > strlen(a)) strlcat(anchor_call, r->anchor->path + (a[0] ? - strlen(a) + 1 : 0), sizeof(anchor_call)); + strlen(a) + 1 : 0), anchor_call_len); } if (r->anchor_wildcard) strlcat(anchor_call, anchor_call[0] ? "/*" : "*", - sizeof(anchor_call)); + anchor_call_len); done: @@ -419,7 +419,7 @@ pf_kanchor_nvcopyout(const struct pf_kruleset *rs, const struct pf_krule *r, char anchor_call[MAXPATHLEN] = { 0 }; int ret; - ret = pf_kanchor_copyout(rs, r, anchor_call); + ret = pf_kanchor_copyout(rs, r, anchor_call, sizeof(anchor_call)); MPASS(ret == 0); nvlist_add_string(nvl, "anchor_call", anchor_call);