From nobody Mon Aug 29 13:07:05 2022 X-Original-To: dev-commits-src-branches@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 4MGW1Q0WR2z4b6Vv; Mon, 29 Aug 2022 13:07:06 +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 4MGW1Q025tz49vG; Mon, 29 Aug 2022 13:07:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661778426; 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=9/dGFfcvj76anI/PYWZ9wBmSIEOTT3vOvJmofmGWBCo=; b=uqsETfw0AYu1oAdSR/zeXXw3j6o7Gwu9EVf5cDqj4ayMGJy5Q73/LmKBv2fbAApdFAt7RF 1BfU+HszcIIQDEI1vFNAoQRPuB2pZ7N10y9VCKU+Ra+YKS+i2QOJIA/D++xJVk+4uBnE7R Yi/Aoszr14ZYYIBEXPGooRDLbk2Hcfa3a3S85We/B4p0w7/l7pP3zHDm6lKcxAaKa4RV/q 7FwNEwmR2eXEL62xhM1Upkl/iWJW0mxzyELh0hkNc83ktvZUJaTbodQyWL8DP2Lir8vQlu hZfjBFGimFqDxseo34meGjALVATLc99g8CPtsL4E/2to02CkM2lhfBrZzaaGzQ== 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 4MGW1P69xGzRGn; Mon, 29 Aug 2022 13:07:05 +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 27TD75hq014717; Mon, 29 Aug 2022 13:07:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27TD75ri014716; Mon, 29 Aug 2022 13:07:05 GMT (envelope-from git) Date: Mon, 29 Aug 2022 13:07:05 GMT Message-Id: <202208291307.27TD75ri014716@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 86bd7f67c31f - stable/12 - pf: Make sure that pfi_update_status() always zeros counters List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 86bd7f67c31f30169e77235e329d72ee98a87a29 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661778426; 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=9/dGFfcvj76anI/PYWZ9wBmSIEOTT3vOvJmofmGWBCo=; b=U0BTbvPfnOeXqTvUIJbjhNNMDmNIigFLHjVBF1U1QHc9ve94ZxY1uvRItuGXl8DI6q/2l9 rrAebV1jIruvvW80dEH8OXSTXwdsp1zmm8B0aJxEkS2VCAjUbUzd15+45FbRg8SsVijUwx FqiFgVaSiMhXb/ddgUSuDLZUfwx8BMN3yC+oQWW78Y/84XP55b4fKKgDF76MJTKQ+Tsjzl ZbZFLAh8lzkP/A7b8v+hE6SKJXoVGppAvByT9JzTDOJkBMrYFaA/h8L83dkiKuCuaW1/wN CT0Bd+FCTNYcMbBzLedJIDUFCanExqcrgaJtcxvedXOKOvmi7JKcgtOob3fHbg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661778426; a=rsa-sha256; cv=none; b=uAfhmNMzpO1hqg4BWsMBsLNiGNuWEE/acOHNEaCJVmMFuJ5NSHzoByPhvkVBbDQR16w0J/ Kj0yxymacTkJWusA9R2V5zjLSWuo6gqUBTIMaKN/M8DO+qI8CIh9oh4ZulSH30GtNsdiS3 W/oxcvrwf8YtHOlGKfnQ85S7ovYjBpgiHFHpHBpEW05RP4MCIwJCy+HcknCk+wkfUF8vsM XJQ/vBQ5VrXFCQATv8pUe9zAjE7AQQy7Bpz8ZrfMXlMGur+iBmF3NOHo5CpNI4dESmJpoj XR9KuDYX1OFXkHQCgtdE8j6FQOt+Nq8bXuE+RUI4uD56awP76wb9YdtYhtcKdg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=86bd7f67c31f30169e77235e329d72ee98a87a29 commit 86bd7f67c31f30169e77235e329d72ee98a87a29 Author: Mark Johnston AuthorDate: 2022-06-30 14:19:23 +0000 Commit: Ed Maste CommitDate: 2022-08-29 13:06:03 +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 (cherry picked from commit 333670372ffe2f1c562e1088a7779eb709006ba2) --- 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 806718863f34..54ac84365180 100644 --- a/sys/netpfil/pf/pf_if.c +++ b/sys/netpfil/pf/pf_if.c @@ -789,6 +789,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) @@ -804,10 +809,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;