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
This commit is contained in:
Mark Johnston 2022-03-19 21:59:13 -04:00
parent 964bf2f902
commit ecd764b0ea

View file

@ -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? */