git: 057275e4be56 - stable/13 - ktrace: Zero request structures when populating the pool
Mark Johnston
markj at FreeBSD.org
Fri Jul 30 00:33:24 UTC 2021
The branch stable/13 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=057275e4be560e02b5ba31918dc262beb474188d
commit 057275e4be560e02b5ba31918dc262beb474188d
Author: Mark Johnston <markj at FreeBSD.org>
AuthorDate: 2021-07-23 14:29:53 +0000
Commit: Mark Johnston <markj at FreeBSD.org>
CommitDate: 2021-07-30 00:32:59 +0000
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)
---
sys/kern/kern_ktrace.c | 5 +++--
1 file 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);
More information about the dev-commits-src-all
mailing list