git: 5c18bf9d5fd7 - main - ktrace: Zero request structures when populating the pool
Mark Johnston
markj at FreeBSD.org
Fri Jul 23 14:49:55 UTC 2021
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=5c18bf9d5fd7684024e0a55da1e8537d4cfaf0bf
commit 5c18bf9d5fd7684024e0a55da1e8537d4cfaf0bf
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-23 14:29:53 +0000
ktrace: Zero request structures when populating the pool
Otherwise uninitialized pad bytes may be copied into the ktrace log
file.
Reported by: KMSAN
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
---
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 87cea3f269d5..be0ccfd344fa 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