git: 17cb4e662e17 - stable/13 - elf: Avoid dumping uninitialized bytes in PRSTATUS core dump notes

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Thu, 12 May 2022 22:56:35 UTC
The branch stable/13 has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=17cb4e662e17d9d5bc295bfa1f55cdae400ab5e8

commit 17cb4e662e17d9d5bc295bfa1f55cdae400ab5e8
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-03-23 16:52:44 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-12 22:12:59 +0000

    elf: Avoid dumping uninitialized bytes in PRSTATUS core dump notes
    
    elf_prstatus_t contains pad space.
    
    Reported by:    KMSAN
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D34606
    
    (cherry picked from commit 1babcad6bc4093664a10c7ab98b9ebd2d64bcaaf)
---
 sys/kern/imgact_elf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index 419449262978..c39a865dcf05 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -2180,6 +2180,7 @@ __elfN(get_prstatus)(struct regset *rs, struct thread *td, void *buf,
 		KASSERT(*sizep == sizeof(*status), ("%s: invalid size",
 		    __func__));
 		status = buf;
+		memset(status, 0, *sizep);
 		status->pr_version = PRSTATUS_VERSION;
 		status->pr_statussz = sizeof(elf_prstatus_t);
 		status->pr_gregsetsz = sizeof(elf_gregset_t);