FreeBSD/sys/security/audit/audit_arg.c
/*
 * Function to save the path and vnode attr information into the audit
 * record.
 *
 * It is assumed that the caller will hold any vnode locks necessary to
 * perform a VOP_GETATTR() on the passed vnode.
 *
 * XXX: The attr code is very similar to vfs_vnops.c:vn_stat(), but always
 * provides access to the generation number as we need that to construct the
 * BSM file ID.
 *
 * XXX: We should accept the process argument from the caller, since it's
 * very likely they already have a reference.
 *
 * XXX: Error handling in this function is poor.
 *
 * XXXAUDIT: Possibly KASSERT the path pointer is NULL?
 */
Function to save the path and vnode attr information into the audit
record.

It is assumed that the caller will hold any vnode locks necessary to
perform a VOP_GETATTR() on the passed vnode.

The attr code is very similar to vfs_vnops.c:vn_stat(), but always
provides access to the generation number as we need that to construct the
BSM file ID.

We should accept the process argument from the caller, since it's
very likely they already have a reference.

Error handling in this function is poor.


Function to save the path and vnode attr information into the audit record . It is assumed that the caller will hold any vnode locks necessary to perform a VOP_GETATTR () on the passed vnode . The attr code is very similar to vfs_vnops . c : vn_stat () but always provides access to the generation number as we need that to construct the BSM file ID . We should accept the process argument from the caller since it ' s very likely they already have a reference . Error handling in this function is poor .
static int
audit_arg_vnode(struct vnode *vp, struct vnode_au_info *vnp)
{
	struct vattr vattr;
	int error;
	ASSERT_VOP_LOCKED(vp, "audit_arg_vnode");
	error = VOP_GETATTR(vp, &vattr, curthread->td_ucred);
	if (error) {
		return (error);
	}
	vnp->vn_mode = vattr.va_mode;
	vnp->vn_uid = vattr.va_uid;
	vnp->vn_gid = vattr.va_gid;
	vnp->vn_dev = vattr.va_rdev;
	vnp->vn_fsid = vattr.va_fsid;
	vnp->vn_fileid = vattr.va_fileid;
	vnp->vn_gen = vattr.va_gen;
	return (0);
}
static int audit_arg_vnode ( struct vnode * vp , struct vnode_au_info * vnp ) { struct vattr vattr ; int error ; ASSERT_VOP_LOCKED ( vp , " " ) ; error = VOP_GETATTR ( vp , & vattr , curthread -> td_ucred ) ; if ( error ) { return ( error ) ; } vnp -> vn_mode = vattr . va_mode ; vnp -> vn_uid = vattr . va_uid ; vnp -> vn_gid = vattr . va_gid ; vnp -> vn_dev = vattr . va_rdev ; vnp -> vn_fsid = vattr . va_fsid ; vnp -> vn_fileid = vattr . va_fileid ; vnp -> vn_gen = vattr . va_gen ; return ( 0 ) ; }
Function to save the path and vnode attr information into the audit
 record.
Function to save the path and vnode attr information into the audit record .
/* XXX: How to handle this case? */