git: 333670372ffe - main - pf: Make sure that pfi_update_status() always zeros counters
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 30 Jun 2022 14:31:32 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=333670372ffe2f1c562e1088a7779eb709006ba2
commit 333670372ffe2f1c562e1088a7779eb709006ba2
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-06-30 14:19:23 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
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;