aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-07-23 14:29:53 +0000
committerMark Johnston <markj@FreeBSD.org>2021-07-30 00:32:59 +0000
commit057275e4be560e02b5ba31918dc262beb474188d (patch)
treec86a9510d9e81c916310a7612bb4ea09c070d8af
parent3e148d60295d08a0dc42efcc58a35f00f8e89d54 (diff)
downloadsrc-057275e4be560e02b5ba31918dc262beb474188d.tar.gz
src-057275e4be560e02b5ba31918dc262beb474188d.zip
ktrace: Zero request structures when populating the pool
Otherwise uninitialized pad bytes may be copied into the ktrace log file. Reported by: KMSAN Sponsored by: The FreeBSD Foundation (cherry picked from commit 5c18bf9d5fd7684024e0a55da1e8537d4cfaf0bf)
-rw-r--r--sys/kern/kern_ktrace.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_ktrace.c b/sys/kern/kern_ktrace.c
index 1b9e0942b702..9221a9ceb765 100644
--- a/sys/kern/kern_ktrace.c
+++ b/sys/kern/kern_ktrace.c
@@ -219,7 +219,8 @@ ktrace_init(void *dummy)
sx_init(&ktrace_sx, "ktrace_sx");
STAILQ_INIT(&ktr_free);
for (i = 0; i < ktr_requestpool; i++) {
- req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK);
+ req = malloc(sizeof(struct ktr_request), M_KTRACE, M_WAITOK |
+ M_ZERO);
STAILQ_INSERT_HEAD(&ktr_free, req, ktr_list);
}
}
@@ -285,7 +286,7 @@ ktrace_resize_pool(u_int oldsize, u_int newsize)
STAILQ_INIT(&ktr_new);
while (bound-- > 0) {
req = malloc(sizeof(struct ktr_request), M_KTRACE,
- M_WAITOK);
+ M_WAITOK | M_ZERO);
STAILQ_INSERT_HEAD(&ktr_new, req, ktr_list);
}
mtx_lock(&ktrace_mtx);