git: 97d99787446f - stable/13 - audit: Initialize vattr fields before calling VOP_GETATTR

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 11 Apr 2022 13:44:02 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=97d99787446fa48228d56973291ef3ae1f78ea66

commit 97d99787446fa48228d56973291ef3ae1f78ea66
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-03-20 01:59:13 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-04-11 13:43:27 +0000

    audit: Initialize vattr fields before calling VOP_GETATTR
    
    Some filesystems do not fill out certain optional vattr fields.  To
    ensure that they do not get copied out to userspace uninitialized, use
    VATTR_NULL to provide default values.
    
    Reported by:    KMSAN
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit ecd764b0ea7a1b7fb5f1e6632f8d8db9233f06ea)
---
 sys/security/audit/audit_arg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/security/audit/audit_arg.c b/sys/security/audit/audit_arg.c
index a917b5b6e297..7e0b0de2abff 100644
--- a/sys/security/audit/audit_arg.c
+++ b/sys/security/audit/audit_arg.c
@@ -873,6 +873,7 @@ audit_arg_vnode(struct vnode *vp, struct vnode_au_info *vnp)
 
 	ASSERT_VOP_LOCKED(vp, "audit_arg_vnode");
 
+	VATTR_NULL(&vattr);
 	error = VOP_GETATTR(vp, &vattr, curthread->td_ucred);
 	if (error) {
 		/* XXX: How to handle this case? */