4 * Copyright (c) 2011, 2012, 2013, 2015, 2016, Juniper Networks, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifndef _SECURITY_MAC_VERIEXEC_INTERNAL_H
30 #define _SECURITY_MAC_VERIEXEC_INTERNAL_H
33 #error "no user-serviceable parts inside"
36 #include <sys/queue.h>
37 #include <sys/malloc.h>
38 #include <sys/sysctl.h>
40 #define MAC_VERIEXEC_FULLNAME "MAC/veriexec"
42 #define VERIEXEC_FILES_FIRST 1
44 #if defined(VERIFIED_EXEC_DEBUG) || defined(VERIFIED_EXEC_DEBUG_VERBOSE)
45 # define VERIEXEC_DEBUG(n, x) if (mac_veriexec_debug > (n)) printf x
47 # define VERIEXEC_DEBUG(n, x)
50 struct mac_veriexec_file_info
55 struct mac_veriexec_fpops *ops;
56 unsigned char fingerprint[MAXFINGERPRINTLEN];
57 LIST_ENTRY(mac_veriexec_file_info) entries;
60 MALLOC_DECLARE(M_VERIEXEC);
62 SYSCTL_DECL(_security_mac_veriexec);
73 int mac_veriexec_metadata_fetch_fingerprint_status(struct vnode *vp,
74 struct vattr *vap, struct thread *td, int check_files);
75 int mac_veriexec_metadata_get_executable_flags(struct ucred *cred,
76 struct proc *p, int *flags, int check_files);
77 int mac_veriexec_metadata_get_file_flags(dev_t fsid, long fileid,
78 unsigned long gen, int *flags, int check_files);
79 void mac_veriexec_metadata_init(void);
80 void mac_veriexec_metadata_print_db(struct sbuf *sbp);
81 int mac_veriexec_metadata_unmounted(dev_t fsid, struct thread *td);
83 int mac_veriexec_fingerprint_add_ops(struct mac_veriexec_fpops *fpops);
85 int mac_veriexec_fingerprint_check_image(struct image_params *imgp,
86 int check_files, struct thread *td);
87 int mac_veriexec_fingerprint_check_vnode(struct vnode *vp,
88 struct mac_veriexec_file_info *ip, struct thread *td,
89 off_t file_size, unsigned char *fingerprint);
90 void mac_veriexec_fingerprint_init(void);
91 struct mac_veriexec_fpops *
92 mac_veriexec_fingerprint_lookup_ops(const char *type);
95 mac_veriexec_get_fingerprint_status(struct vnode *vp);
96 int mac_veriexec_get_state(void);
97 int mac_veriexec_in_state(int state);
98 void mac_veriexec_set_fingerprint_status(struct vnode *vp,
99 fingerprint_status_t fp_status);
100 void mac_veriexec_set_state(int state);
102 #endif /* !_SECURITY_MAC_VERIEXEC_INTERNAL_H */