1 1.59 maxv /* $NetBSD: verified_exec.h,v 1.59 2018/12/24 16:04:14 maxv Exp $ */ 2 1.1 blymn 3 1.1 blymn /*- 4 1.50 elad * Copyright (c) 2005, 2006 Elad Efrat <elad (at) NetBSD.org> 5 1.50 elad * Copyright (c) 2005, 2006 Brett Lymn <blymn (at) NetBSD.org> 6 1.50 elad * All rights reserved. 7 1.1 blymn * 8 1.1 blymn * Redistribution and use in source and binary forms, with or without 9 1.1 blymn * modification, are permitted provided that the following conditions 10 1.1 blymn * are met: 11 1.1 blymn * 1. Redistributions of source code must retain the above copyright 12 1.1 blymn * notice, this list of conditions and the following disclaimer. 13 1.50 elad * 2. Redistributions in binary form must reproduce the above copyright 14 1.50 elad * notice, this list of conditions and the following disclaimer in the 15 1.50 elad * documentation and/or other materials provided with the distribution. 16 1.51 elad * 3. The name of the authors may not be used to endorse or promote products 17 1.50 elad * derived from this software without specific prior written permission. 18 1.7 blymn * 19 1.50 elad * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 20 1.50 elad * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 1.50 elad * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 22 1.50 elad * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 23 1.50 elad * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 24 1.50 elad * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 1.50 elad * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 1.50 elad * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 1.50 elad * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 28 1.50 elad * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 1.1 blymn */ 30 1.1 blymn 31 1.14 elad #ifndef _SYS_VERIFIED_EXEC_H_ 32 1.14 elad #define _SYS_VERIFIED_EXEC_H_ 33 1.14 elad 34 1.56 elad #include <sys/ioccom.h> 35 1.44 elad 36 1.46 agc #if defined(_KERNEL) && !defined(HAVE_NBTOOL_CONFIG_H) 37 1.56 elad #include <sys/types.h> 38 1.42 elad #include <prop/proplib.h> 39 1.56 elad 40 1.56 elad struct mount; 41 1.56 elad struct vnode; 42 1.56 elad 43 1.56 elad #ifdef notyet 44 1.56 elad struct vm_page; 45 1.56 elad #endif /* notyet */ 46 1.44 elad #endif /* _KERNEL */ 47 1.28 elad 48 1.24 elad /* Flags for a Veriexec entry. These can be OR'd together. */ 49 1.16 elad #define VERIEXEC_DIRECT 0x01 /* Direct execution (exec) */ 50 1.16 elad #define VERIEXEC_INDIRECT 0x02 /* Indirect execution (#!) */ 51 1.16 elad #define VERIEXEC_FILE 0x04 /* Plain file (open) */ 52 1.20 elad #define VERIEXEC_UNTRUSTED 0x10 /* Untrusted storage */ 53 1.1 blymn 54 1.56 elad /* Operations for the Veriexec pseudo-device. */ 55 1.43 elad #define VERIEXEC_LOAD _IOW('X', 0x1, struct plistref) 56 1.43 elad #define VERIEXEC_TABLESIZE _IOW('X', 0x2, struct plistref) 57 1.43 elad #define VERIEXEC_DELETE _IOW('X', 0x3, struct plistref) 58 1.43 elad #define VERIEXEC_QUERY _IOWR('X', 0x4, struct plistref) 59 1.56 elad #define VERIEXEC_DUMP _IOR('X', 0x5, struct plistref) 60 1.56 elad #define VERIEXEC_FLUSH _IO('X', 0x6) 61 1.7 blymn 62 1.44 elad /* Veriexec modes (strict levels). */ 63 1.44 elad #define VERIEXEC_LEARNING 0 /* Learning mode. */ 64 1.44 elad #define VERIEXEC_IDS 1 /* Intrusion detection mode. */ 65 1.44 elad #define VERIEXEC_IPS 2 /* Intrusion prevention mode. */ 66 1.44 elad #define VERIEXEC_LOCKDOWN 3 /* Lockdown mode. */ 67 1.8 elad 68 1.28 elad /* Valid status field values. */ 69 1.28 elad #define FINGERPRINT_NOTEVAL 0 /* fingerprint has not been evaluated */ 70 1.28 elad #define FINGERPRINT_VALID 1 /* fingerprint evaluated and matches list */ 71 1.28 elad #define FINGERPRINT_NOMATCH 2 /* fingerprint evaluated but does not match */ 72 1.28 elad 73 1.28 elad /* Per-page fingerprint status. */ 74 1.28 elad #define PAGE_FP_NONE 0 /* no per-page fingerprints. */ 75 1.28 elad #define PAGE_FP_READY 1 /* per-page fingerprints ready for use. */ 76 1.28 elad #define PAGE_FP_FAIL 2 /* mismatch in per-page fingerprints. */ 77 1.28 elad 78 1.56 elad #if defined(_KERNEL) && !defined(HAVE_NBTOOL_CONFIG_H) 79 1.57 christos 80 1.1 blymn /* 81 1.56 elad * Fingerprint operations vector for Veriexec. 82 1.24 elad * Function types: init, update, final. 83 1.1 blymn */ 84 1.44 elad typedef void (*veriexec_fpop_init_t)(void *); 85 1.44 elad typedef void (*veriexec_fpop_update_t)(void *, u_char *, u_int); 86 1.44 elad typedef void (*veriexec_fpop_final_t)(u_char *, void *); 87 1.1 blymn 88 1.40 elad void veriexec_init(void); 89 1.44 elad int veriexec_fpops_add(const char *, size_t, size_t, veriexec_fpop_init_t, 90 1.44 elad veriexec_fpop_update_t, veriexec_fpop_final_t); 91 1.44 elad int veriexec_file_add(struct lwp *, prop_dictionary_t); 92 1.44 elad int veriexec_verify(struct lwp *, struct vnode *, const u_char *, int, 93 1.54 thorpej bool *); 94 1.49 elad #ifdef notyet 95 1.49 elad int veriexec_page_verify(struct veriexec_file_entry *, struct vm_page *, 96 1.49 elad size_t, struct lwp *); 97 1.49 elad #endif /* notyet */ 98 1.54 thorpej bool veriexec_lookup(struct vnode *); 99 1.53 elad int veriexec_file_delete(struct lwp *, struct vnode *); 100 1.53 elad int veriexec_table_delete(struct lwp *, struct mount *); 101 1.45 elad int veriexec_convert(struct vnode *, prop_dictionary_t); 102 1.56 elad int veriexec_dump(struct lwp *, prop_array_t); 103 1.56 elad int veriexec_flush(struct lwp *); 104 1.44 elad void veriexec_purge(struct vnode *); 105 1.57 christos int veriexec_removechk(struct lwp *, struct vnode *, const char *); 106 1.57 christos int veriexec_renamechk(struct lwp *, struct vnode *, const char *, 107 1.57 christos struct vnode *, const char *); 108 1.44 elad int veriexec_unmountchk(struct mount *); 109 1.48 elad int veriexec_openchk(struct lwp *, struct vnode *, const char *, int); 110 1.14 elad #endif /* _KERNEL */ 111 1.7 blymn 112 1.18 elad #endif /* !_SYS_VERIFIED_EXEC_H_ */ 113