From nobody Thu Jun 30 14:31:32 2022 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 E19EA8727C7; Thu, 30 Jun 2022 14:31:33 +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 4LYgkY2GhHz4tcM; Thu, 30 Jun 2022 14:31:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656599493; 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=ofyVvjW+U4+WtSrzZBBlCWlRaQCMuSfWFh0y0hUJKBA=; b=bZ4eeoza+RpQATST2v7fBmRsK4an3vDFxOI/ZbNORbhHzx/UoBwDk7yB9n4P5JVPx/12Wm ez6W9ss/dxxhoLKFftJh960fvEztgf7A9oP+gkr/+Kel3qkmryCoZHBf7zfHIGAmbEdyMg nJni0rULoa0sjKjUK37TF3U7DbrworIIKuEy6ZId7G4xAlPG0ZzaAGJeD5jNILB2Hd3BW1 hkmjmDTCzGw0t5pE1p+e8qtkWstJEXGq64LEMYperRAwYVmibfzJCi9gTh03JpIpfSwUSz KVn0dX0diZxYjhAuVwsOCpdtpdXdSu0yf06F7xOWg22B28OAk2+BgPOTaWDkHw== 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 1A09E31; Thu, 30 Jun 2022 14:31:33 +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 25UEVWIk074407; Thu, 30 Jun 2022 14:31:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25UEVWK8074406; Thu, 30 Jun 2022 14:31:32 GMT (envelope-from git) Date: Thu, 30 Jun 2022 14:31:32 GMT Message-Id: <202206301431.25UEVWK8074406@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 333670372ffe - main - pf: Make sure that pfi_update_status() always zeros counters 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 333670372ffe2f1c562e1088a7779eb709006ba2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1656599493; 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=ofyVvjW+U4+WtSrzZBBlCWlRaQCMuSfWFh0y0hUJKBA=; b=l4g5qsSaiGbp/ovPR0a4G4guaKB+5egvuNaZtgk+/F+LQQ8fx+67ZQ59JHAWeQzSyLxVjs YkeG/zC2BVNnYIJ/2T9RtG0uKIAcflHtr+JP7yw7YItEnyWNfIpbWp19+E4brQGQviqPWb xiNcNolUR55fNwGV7M16P9W9RGlhKoX51roSj8qm2BK46ouguEVcaMO9dmaqy0GutvcqyA q+lysVYGAmrPPwhlM/sYBQJyI5J39nD7CIKuagZQcJJbecXhUzMsjBqKZAyywbLnMoUfzP gIXKb5+oW7c9TgAexaCiFZQBjGSEqEjVMBxSHOk3GO7y0y/vOKyYJSuWbfjZlw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1656599493; a=rsa-sha256; cv=none; b=mdV0t5PXhL9eQA18emtRHbV6+SsI/SVPgq4yQbbLQLaoj8jxnmqPpRfhKD79w0MKja/iDm QNSoPHHcrwaJSCV2wIXWr4REM+JZo/oYkBhu/Te7ppx4fcJmtiXDG3kZzMU5EczC+2TScR sQwfB7PWurMafh/819XxFwoEe0YlqXMe2UeUmiVMgSSDZDisK0FK6k/JcP3PElffAwldV+ gFxGRnYS6o1Xc/k17Na+PtNoiXbhgfH57RGe30lZYeotcZlFDPcuvufaYsBiuc2WIut1Vd ucCIqBS2BpZ5Ayp2mF9QVbrvQtclcR7JXwiTX6PuLM8Q0/GyKDftLnNX6+oyVg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=333670372ffe2f1c562e1088a7779eb709006ba2 commit 333670372ffe2f1c562e1088a7779eb709006ba2 Author: Mark Johnston AuthorDate: 2022-06-30 14:19:23 +0000 Commit: Mark Johnston CommitDate: 2022-06-30 14:31:26 +0000 pf: Make sure that pfi_update_status() always zeros counters pfi_update_status() can return early if the status interface doesn't exist. But in this case pf_getstatus() was copying uninitialized stack memory into the output nvlist. Reported by: Jenkins (KMSAN job) Reviewed by: kp MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35659 --- sys/netpfil/pf/pf_if.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/sys/netpfil/pf/pf_if.c b/sys/netpfil/pf/pf_if.c index cdde753c41b3..02c46db409b6 100644 --- a/sys/netpfil/pf/pf_if.c +++ b/sys/netpfil/pf/pf_if.c @@ -803,6 +803,11 @@ pfi_update_status(const char *name, struct pf_status *pfs) CK_STAILQ_HEAD(, ifg_member) ifg_members; int i, j, k; + if (pfs) { + bzero(pfs->pcounters, sizeof(pfs->pcounters)); + bzero(pfs->bcounters, sizeof(pfs->bcounters)); + } + strlcpy(key.pfik_name, name, sizeof(key.pfik_name)); p = RB_FIND(pfi_ifhead, &V_pfi_ifs, (struct pfi_kkif *)&key); if (p == NULL) @@ -818,10 +823,6 @@ pfi_update_status(const char *name, struct pf_status *pfs) CK_STAILQ_INIT(&ifg_members); CK_STAILQ_INSERT_TAIL(&ifg_members, &p_member, ifgm_next); } - if (pfs) { - bzero(pfs->pcounters, sizeof(pfs->pcounters)); - bzero(pfs->bcounters, sizeof(pfs->bcounters)); - } CK_STAILQ_FOREACH(ifgm, &ifg_members, ifgm_next) { if (ifgm->ifgm_ifp == NULL || ifgm->ifgm_ifp->if_pf_kif == NULL) continue;