git: ecd764b0ea7a - main - audit: Initialize vattr fields before calling VOP_GETATTR

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 28 Mar 2022 15:24:13 UTC
The branch main has been updated by markj:

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

commit ecd764b0ea7a1b7fb5f1e6632f8d8db9233f06ea
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-03-20 01:59:13 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-03-28 15:23:45 +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
    MFC after:      2 weeks
    Sponsored by:   The FreeBSD Foundation
---
 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? */