audit_arg.c (b783025921d03873f5e6715ad7d75f86b372435c) audit_arg.c (15bcf785ba268a1fb2b270233a7ae56d9e0ebc3a)
1/*-
2 * Copyright (c) 1999-2005 Apple Inc.
3 * Copyright (c) 2016-2017 Robert N. M. Watson
4 * All rights reserved.
5 *
6 * Portions of this software were developed by BAE Systems, the University of
7 * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL
8 * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent

--- 752 unchanged lines hidden (view full) ---

761 if (ar == NULL)
762 return;
763
764 audit_arg_upath(td, dirfd, upath, &ar->k_ar.ar_arg_upath2);
765 ARG_SET_VALID(ar, ARG_UPATH2);
766}
767
768/*
1/*-
2 * Copyright (c) 1999-2005 Apple Inc.
3 * Copyright (c) 2016-2017 Robert N. M. Watson
4 * All rights reserved.
5 *
6 * Portions of this software were developed by BAE Systems, the University of
7 * Cambridge Computer Laboratory, and Memorial University under DARPA/AFRL
8 * contract FA8650-15-C-7558 ("CADETS"), as part of the DARPA Transparent

--- 752 unchanged lines hidden (view full) ---

761 if (ar == NULL)
762 return;
763
764 audit_arg_upath(td, dirfd, upath, &ar->k_ar.ar_arg_upath2);
765 ARG_SET_VALID(ar, ARG_UPATH2);
766}
767
768/*
769 * Variants on path auditing that do not canonicalise the path passed in;
770 * these are for use with filesystem-like subsystems that employ string names,
771 * but do not support a hierarchical namespace -- for example, POSIX IPC
772 * objects. The subsystem should have performed any necessary
773 * canonicalisation required to make the paths useful to audit analysis.
774 */
775static void
776audit_arg_upath_canon(char *upath, char **pathp)
777{
778
779 if (*pathp == NULL)
780 *pathp = malloc(MAXPATHLEN, M_AUDITPATH, M_WAITOK);
781 (void)snprintf(*pathp, MAXPATHLEN, "%s", upath);
782}
783
784void
785audit_arg_upath1_canon(char *upath)
786{
787 struct kaudit_record *ar;
788
789 ar = currecord();
790 if (ar == NULL)
791 return;
792
793 audit_arg_upath_canon(upath, &ar->k_ar.ar_arg_upath1);
794 ARG_SET_VALID(ar, ARG_UPATH1);
795}
796
797void
798audit_arg_upath2_canon(char *upath)
799{
800 struct kaudit_record *ar;
801
802 ar = currecord();
803 if (ar == NULL)
804 return;
805
806 audit_arg_upath_canon(upath, &ar->k_ar.ar_arg_upath2);
807 ARG_SET_VALID(ar, ARG_UPATH2);
808}
809
810/*
769 * Function to save the path and vnode attr information into the audit
770 * record.
771 *
772 * It is assumed that the caller will hold any vnode locks necessary to
773 * perform a VOP_GETATTR() on the passed vnode.
774 *
775 * XXX: The attr code is very similar to vfs_vnops.c:vn_stat(), but always
776 * provides access to the generation number as we need that to construct the

--- 163 unchanged lines hidden ---
811 * Function to save the path and vnode attr information into the audit
812 * record.
813 *
814 * It is assumed that the caller will hold any vnode locks necessary to
815 * perform a VOP_GETATTR() on the passed vnode.
816 *
817 * XXX: The attr code is very similar to vfs_vnops.c:vn_stat(), but always
818 * provides access to the generation number as we need that to construct the

--- 163 unchanged lines hidden ---