1d8a7b7a3SRobert Watson /*- 29b6dd12eSRobert Watson * Copyright (c) 1999-2002, 2007-2011 Robert N. M. Watson 364094732SRobert Watson * Copyright (c) 2001-2005 McAfee, Inc. 430d239bcSRobert Watson * Copyright (c) 2006 SPARTA, Inc. 56356dba0SRobert Watson * Copyright (c) 2008 Apple Inc. 6d8a7b7a3SRobert Watson * All rights reserved. 7d8a7b7a3SRobert Watson * 8d8a7b7a3SRobert Watson * This software was developed by Robert Watson for the TrustedBSD Project. 9d8a7b7a3SRobert Watson * 1064094732SRobert Watson * This software was developed for the FreeBSD Project in part by McAfee 1164094732SRobert Watson * Research, the Security Research Division of McAfee, Inc. under 1264094732SRobert Watson * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA 1364094732SRobert Watson * CHATS research program. 14d8a7b7a3SRobert Watson * 1530d239bcSRobert Watson * This software was enhanced by SPARTA ISSO under SPAWAR contract 1630d239bcSRobert Watson * N66001-04-C-6019 ("SEFOS"). 1730d239bcSRobert Watson * 186f6174a7SRobert Watson * This software was developed at the University of Cambridge Computer 196f6174a7SRobert Watson * Laboratory with support from a grant from Google, Inc. 206f6174a7SRobert Watson * 21d8a7b7a3SRobert Watson * Redistribution and use in source and binary forms, with or without 22d8a7b7a3SRobert Watson * modification, are permitted provided that the following conditions 23d8a7b7a3SRobert Watson * are met: 24d8a7b7a3SRobert Watson * 1. Redistributions of source code must retain the above copyright 25d8a7b7a3SRobert Watson * notice, this list of conditions and the following disclaimer. 26d8a7b7a3SRobert Watson * 2. Redistributions in binary form must reproduce the above copyright 27d8a7b7a3SRobert Watson * notice, this list of conditions and the following disclaimer in the 28d8a7b7a3SRobert Watson * documentation and/or other materials provided with the distribution. 29d8a7b7a3SRobert Watson * 30d8a7b7a3SRobert Watson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 31d8a7b7a3SRobert Watson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32d8a7b7a3SRobert Watson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33d8a7b7a3SRobert Watson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 34d8a7b7a3SRobert Watson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35d8a7b7a3SRobert Watson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36d8a7b7a3SRobert Watson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37d8a7b7a3SRobert Watson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38d8a7b7a3SRobert Watson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39d8a7b7a3SRobert Watson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40d8a7b7a3SRobert Watson * SUCH DAMAGE. 41d8a7b7a3SRobert Watson */ 42d8a7b7a3SRobert Watson 43d8a7b7a3SRobert Watson /* 44d8a7b7a3SRobert Watson * Developed by the TrustedBSD Project. 456827d029SRobert Watson * 466827d029SRobert Watson * MAC Test policy - tests MAC Framework labeling by assigning object class 476827d029SRobert Watson * magic numbers to each label and validates that each time an object label 486827d029SRobert Watson * is passed into the policy, it has a consistent object type, catching 496827d029SRobert Watson * incorrectly passed labels, labels passed after free, etc. 50d8a7b7a3SRobert Watson */ 51d8a7b7a3SRobert Watson 52d8a7b7a3SRobert Watson #include <sys/param.h> 53d8a7b7a3SRobert Watson #include <sys/acl.h> 5432240d08SMarcel Moolenaar #include <sys/kdb.h> 55d8a7b7a3SRobert Watson #include <sys/kernel.h> 566aeb05d7STom Rhodes #include <sys/ksem.h> 570712b254SRobert Watson #include <sys/malloc.h> 587405fcc3SRobert Watson #include <sys/module.h> 59d8a7b7a3SRobert Watson #include <sys/mount.h> 607405fcc3SRobert Watson #include <sys/msg.h> 61d8a7b7a3SRobert Watson #include <sys/proc.h> 62d8a7b7a3SRobert Watson #include <sys/vnode.h> 637405fcc3SRobert Watson #include <sys/sem.h> 647405fcc3SRobert Watson #include <sys/shm.h> 65d8a7b7a3SRobert Watson #include <sys/socket.h> 66d8a7b7a3SRobert Watson #include <sys/socketvar.h> 6736422989SPoul-Henning Kamp #include <sys/sx.h> 68d8a7b7a3SRobert Watson #include <sys/sysctl.h> 69d8a7b7a3SRobert Watson 702449b9e5SMitchell Horne #include <ddb/ddb.h> 712449b9e5SMitchell Horne 72d8a7b7a3SRobert Watson #include <fs/devfs/devfs.h> 73d8a7b7a3SRobert Watson 74d8a7b7a3SRobert Watson #include <net/bpfdesc.h> 75d8a7b7a3SRobert Watson #include <net/if.h> 76d8a7b7a3SRobert Watson #include <net/if_types.h> 77d8a7b7a3SRobert Watson #include <net/if_var.h> 78d8a7b7a3SRobert Watson 790efd6615SRobert Watson #include <security/mac/mac_policy.h> 80d8a7b7a3SRobert Watson 817029da5cSPawel Biernacki static SYSCTL_NODE(_security_mac, OID_AUTO, test, 827029da5cSPawel Biernacki CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 83d8a7b7a3SRobert Watson "TrustedBSD mac_test policy controls"); 84d8a7b7a3SRobert Watson 856827d029SRobert Watson #define MAGIC_BPF 0xfe1ad1b6 866827d029SRobert Watson #define MAGIC_DEVFS 0x9ee79c32 876827d029SRobert Watson #define MAGIC_IFNET 0xc218b120 886827d029SRobert Watson #define MAGIC_INPCB 0x4440f7bb 89048e1287SRobert Watson #define MAGIC_IP6Q 0x0870e1b7 906827d029SRobert Watson #define MAGIC_IPQ 0x206188ef 916827d029SRobert Watson #define MAGIC_MBUF 0xbbefa5bb 926827d029SRobert Watson #define MAGIC_MOUNT 0xc7c46e47 936827d029SRobert Watson #define MAGIC_SOCKET 0x9199c6cd 94f10b1ebcSRobert Watson #define MAGIC_SYNCACHE 0x7fb838a8 95269ad130SRobert Watson #define MAGIC_SYSV_MSG 0x8bbba61e 96269ad130SRobert Watson #define MAGIC_SYSV_MSQ 0xea672391 97269ad130SRobert Watson #define MAGIC_SYSV_SEM 0x896e8a0b 98269ad130SRobert Watson #define MAGIC_SYSV_SHM 0x76119ab0 996827d029SRobert Watson #define MAGIC_PIPE 0xdc6c9919 100269ad130SRobert Watson #define MAGIC_POSIX_SEM 0x78ae980c 1018e38aeffSJohn Baldwin #define MAGIC_POSIX_SHM 0x4e853fc9 1026827d029SRobert Watson #define MAGIC_PROC 0x3b4be98f 1036827d029SRobert Watson #define MAGIC_CRED 0x9a5a4987 1046827d029SRobert Watson #define MAGIC_VNODE 0x1a67a45c 1056827d029SRobert Watson #define MAGIC_FREE 0x849ba1fd 106d8a7b7a3SRobert Watson 1070142affcSRobert Watson #define SLOT(x) mac_label_get((x), test_slot) 1080142affcSRobert Watson #define SLOT_SET(x, v) mac_label_set((x), test_slot, (v)) 109250ee706SRobert Watson 110d8a7b7a3SRobert Watson static int test_slot; 111d8a7b7a3SRobert Watson SYSCTL_INT(_security_mac_test, OID_AUTO, slot, CTLFLAG_RD, 112d8a7b7a3SRobert Watson &test_slot, 0, "Slot allocated by framework"); 113d8a7b7a3SRobert Watson 1147029da5cSPawel Biernacki static SYSCTL_NODE(_security_mac_test, OID_AUTO, counter, 1157029da5cSPawel Biernacki CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 1166827d029SRobert Watson "TrustedBSD mac_test counters controls"); 117d8a7b7a3SRobert Watson 1186827d029SRobert Watson #define COUNTER_DECL(variable) \ 1196827d029SRobert Watson static int counter_##variable; \ 1206827d029SRobert Watson SYSCTL_INT(_security_mac_test_counter, OID_AUTO, variable, \ 1216827d029SRobert Watson CTLFLAG_RD, &counter_##variable, 0, #variable) 122d8a7b7a3SRobert Watson 1236827d029SRobert Watson #define COUNTER_INC(variable) atomic_add_int(&counter_##variable, 1) 1246827d029SRobert Watson 125b2e3811cSRobert Watson #ifdef KDB 1263de213ccSRobert Watson #define DEBUGGER(func, string) kdb_enter(KDB_WHY_MAC, (string)) 127b2e3811cSRobert Watson #else 1286827d029SRobert Watson #define DEBUGGER(func, string) printf("mac_test: %s: %s\n", (func), (string)) 129b2e3811cSRobert Watson #endif 130b2e3811cSRobert Watson 1316827d029SRobert Watson #define LABEL_CHECK(label, magic) do { \ 1326827d029SRobert Watson if (label != NULL) { \ 1336827d029SRobert Watson KASSERT(SLOT(label) == magic || SLOT(label) == 0, \ 1346827d029SRobert Watson ("%s: bad %s label", __func__, #magic)); \ 1356827d029SRobert Watson } \ 1366827d029SRobert Watson } while (0) 1376827d029SRobert Watson 138269ad130SRobert Watson #define LABEL_DESTROY(label, magic) do { \ 1396827d029SRobert Watson if (SLOT(label) == magic || SLOT(label) == 0) { \ 1406827d029SRobert Watson SLOT_SET(label, MAGIC_FREE); \ 1416827d029SRobert Watson } else if (SLOT(label) == MAGIC_FREE) { \ 1426827d029SRobert Watson DEBUGGER("%s: dup destroy", __func__); \ 1436827d029SRobert Watson } else { \ 1446827d029SRobert Watson DEBUGGER("%s: corrupted label", __func__); \ 1456827d029SRobert Watson } \ 1466827d029SRobert Watson } while (0) 1476827d029SRobert Watson 148269ad130SRobert Watson #define LABEL_INIT(label, magic) do { \ 149269ad130SRobert Watson SLOT_SET(label, magic); \ 150269ad130SRobert Watson } while (0) 151269ad130SRobert Watson 1526827d029SRobert Watson #define LABEL_NOTFREE(label) do { \ 1536827d029SRobert Watson KASSERT(SLOT(label) != MAGIC_FREE, \ 1546827d029SRobert Watson ("%s: destroyed label", __func__)); \ 1556827d029SRobert Watson } while (0) 1566827d029SRobert Watson 157d8a7b7a3SRobert Watson /* 158eb320b0eSRobert Watson * Object-specific entry point implementations are sorted alphabetically by 159eb320b0eSRobert Watson * object type name and then by operation. 160eb320b0eSRobert Watson */ 161eb320b0eSRobert Watson COUNTER_DECL(bpfdesc_check_receive); 162a557af22SRobert Watson static int 163f0336833SRobert Watson test_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, 164eb320b0eSRobert Watson struct ifnet *ifp, struct label *ifplabel) 165d8a7b7a3SRobert Watson { 166d8a7b7a3SRobert Watson 167f0336833SRobert Watson LABEL_CHECK(dlabel, MAGIC_BPF); 168eb320b0eSRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 169eb320b0eSRobert Watson COUNTER_INC(bpfdesc_check_receive); 1700712b254SRobert Watson 1715e7ce478SRobert Watson return (0); 172d8a7b7a3SRobert Watson } 173d8a7b7a3SRobert Watson 174eb320b0eSRobert Watson COUNTER_DECL(bpfdesc_create); 175d8a7b7a3SRobert Watson static void 176f0336833SRobert Watson test_bpfdesc_create(struct ucred *cred, struct bpf_d *d, 177f0336833SRobert Watson struct label *dlabel) 178d8a7b7a3SRobert Watson { 179d8a7b7a3SRobert Watson 180eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 181f0336833SRobert Watson LABEL_CHECK(dlabel, MAGIC_BPF); 182eb320b0eSRobert Watson COUNTER_INC(bpfdesc_create); 183d8a7b7a3SRobert Watson } 184d8a7b7a3SRobert Watson 185eb320b0eSRobert Watson COUNTER_DECL(bpfdesc_create_mbuf); 18696adb909SRobert Watson static void 187f0336833SRobert Watson test_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, 188f0336833SRobert Watson struct mbuf *m, struct label *mlabel) 189d8a7b7a3SRobert Watson { 190d8a7b7a3SRobert Watson 191f0336833SRobert Watson LABEL_CHECK(dlabel, MAGIC_BPF); 192f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 193eb320b0eSRobert Watson COUNTER_INC(bpfdesc_create_mbuf); 194d8a7b7a3SRobert Watson } 195d8a7b7a3SRobert Watson 19630d239bcSRobert Watson COUNTER_DECL(bpfdesc_destroy_label); 197d8a7b7a3SRobert Watson static void 1983f1a7a90SRobert Watson test_bpfdesc_destroy_label(struct label *label) 199d8a7b7a3SRobert Watson { 200d8a7b7a3SRobert Watson 201269ad130SRobert Watson LABEL_DESTROY(label, MAGIC_BPF); 20230d239bcSRobert Watson COUNTER_INC(bpfdesc_destroy_label); 203d8a7b7a3SRobert Watson } 204d8a7b7a3SRobert Watson 205eb320b0eSRobert Watson COUNTER_DECL(bpfdesc_init_label); 206d8a7b7a3SRobert Watson static void 207eb320b0eSRobert Watson test_bpfdesc_init_label(struct label *label) 208d8a7b7a3SRobert Watson { 209d8a7b7a3SRobert Watson 210eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_BPF); 211eb320b0eSRobert Watson COUNTER_INC(bpfdesc_init_label); 212d8a7b7a3SRobert Watson } 213d8a7b7a3SRobert Watson 214eb320b0eSRobert Watson COUNTER_DECL(cred_check_relabel); 215eb320b0eSRobert Watson static int 216eb320b0eSRobert Watson test_cred_check_relabel(struct ucred *cred, struct label *newlabel) 217d8a7b7a3SRobert Watson { 218d8a7b7a3SRobert Watson 219eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 220eb320b0eSRobert Watson LABEL_CHECK(newlabel, MAGIC_CRED); 221eb320b0eSRobert Watson COUNTER_INC(cred_check_relabel); 222eb320b0eSRobert Watson 223eb320b0eSRobert Watson return (0); 224d8a7b7a3SRobert Watson } 225d8a7b7a3SRobert Watson 2266f6174a7SRobert Watson COUNTER_DECL(cred_check_setaudit); 2276f6174a7SRobert Watson static int 2286f6174a7SRobert Watson test_cred_check_setaudit(struct ucred *cred, struct auditinfo *ai) 2296f6174a7SRobert Watson { 2306f6174a7SRobert Watson 2316f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2326f6174a7SRobert Watson COUNTER_INC(cred_check_setaudit); 2336f6174a7SRobert Watson 2346f6174a7SRobert Watson return (0); 2356f6174a7SRobert Watson } 2366f6174a7SRobert Watson 2376f6174a7SRobert Watson COUNTER_DECL(cred_check_setaudit_addr); 2386f6174a7SRobert Watson static int 2396f6174a7SRobert Watson test_cred_check_setaudit_addr(struct ucred *cred, 2406f6174a7SRobert Watson struct auditinfo_addr *aia) 2416f6174a7SRobert Watson { 2426f6174a7SRobert Watson 2436f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2446f6174a7SRobert Watson COUNTER_INC(cred_check_setaudit_addr); 2456f6174a7SRobert Watson 2466f6174a7SRobert Watson return (0); 2476f6174a7SRobert Watson } 2486f6174a7SRobert Watson 2496f6174a7SRobert Watson COUNTER_DECL(cred_check_setauid); 2506f6174a7SRobert Watson static int 2516f6174a7SRobert Watson test_cred_check_setauid(struct ucred *cred, uid_t auid) 2526f6174a7SRobert Watson { 2536f6174a7SRobert Watson 2546f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2556f6174a7SRobert Watson COUNTER_INC(cred_check_setauid); 2566f6174a7SRobert Watson 2576f6174a7SRobert Watson return (0); 2586f6174a7SRobert Watson } 2596f6174a7SRobert Watson 260*ddb3eb4eSOlivier Certner COUNTER_DECL(cred_setcred_enter); 261*ddb3eb4eSOlivier Certner static void 262*ddb3eb4eSOlivier Certner test_cred_setcred_enter(void) 263*ddb3eb4eSOlivier Certner { 264*ddb3eb4eSOlivier Certner COUNTER_INC(cred_setcred_enter); 265*ddb3eb4eSOlivier Certner } 266*ddb3eb4eSOlivier Certner 267*ddb3eb4eSOlivier Certner COUNTER_DECL(cred_check_setcred); 268*ddb3eb4eSOlivier Certner static int 269*ddb3eb4eSOlivier Certner test_cred_check_setcred(u_int flags, const struct ucred *old_cred, 270*ddb3eb4eSOlivier Certner struct ucred *new_cred) 271*ddb3eb4eSOlivier Certner { 272*ddb3eb4eSOlivier Certner LABEL_CHECK(old_cred->cr_label, MAGIC_CRED); 273*ddb3eb4eSOlivier Certner LABEL_CHECK(new_cred->cr_label, MAGIC_CRED); 274*ddb3eb4eSOlivier Certner COUNTER_INC(cred_check_setcred); 275*ddb3eb4eSOlivier Certner 276*ddb3eb4eSOlivier Certner return (0); 277*ddb3eb4eSOlivier Certner } 278*ddb3eb4eSOlivier Certner 279*ddb3eb4eSOlivier Certner COUNTER_DECL(cred_setcred_exit); 280*ddb3eb4eSOlivier Certner static void 281*ddb3eb4eSOlivier Certner test_cred_setcred_exit(void) 282*ddb3eb4eSOlivier Certner { 283*ddb3eb4eSOlivier Certner COUNTER_INC(cred_setcred_exit); 284*ddb3eb4eSOlivier Certner } 285*ddb3eb4eSOlivier Certner 2866f6174a7SRobert Watson COUNTER_DECL(cred_check_setegid); 2876f6174a7SRobert Watson static int 2886f6174a7SRobert Watson test_cred_check_setegid(struct ucred *cred, gid_t egid) 2896f6174a7SRobert Watson { 2906f6174a7SRobert Watson 2916f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2926f6174a7SRobert Watson COUNTER_INC(cred_check_setegid); 2936f6174a7SRobert Watson 2946f6174a7SRobert Watson return (0); 2956f6174a7SRobert Watson } 2966f6174a7SRobert Watson 2976f6174a7SRobert Watson COUNTER_DECL(proc_check_euid); 2986f6174a7SRobert Watson static int 2996f6174a7SRobert Watson test_cred_check_seteuid(struct ucred *cred, uid_t euid) 3006f6174a7SRobert Watson { 3016f6174a7SRobert Watson 3026f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3036f6174a7SRobert Watson COUNTER_INC(proc_check_euid); 3046f6174a7SRobert Watson 3056f6174a7SRobert Watson return (0); 3066f6174a7SRobert Watson } 3076f6174a7SRobert Watson 3086f6174a7SRobert Watson COUNTER_DECL(cred_check_setregid); 3096f6174a7SRobert Watson static int 3106f6174a7SRobert Watson test_cred_check_setregid(struct ucred *cred, gid_t rgid, gid_t egid) 3116f6174a7SRobert Watson { 3126f6174a7SRobert Watson 3136f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3146f6174a7SRobert Watson COUNTER_INC(cred_check_setregid); 3156f6174a7SRobert Watson 3166f6174a7SRobert Watson return (0); 3176f6174a7SRobert Watson } 3186f6174a7SRobert Watson 3196f6174a7SRobert Watson COUNTER_DECL(cred_check_setreuid); 3206f6174a7SRobert Watson static int 3216f6174a7SRobert Watson test_cred_check_setreuid(struct ucred *cred, uid_t ruid, uid_t euid) 3226f6174a7SRobert Watson { 3236f6174a7SRobert Watson 3246f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3256f6174a7SRobert Watson COUNTER_INC(cred_check_setreuid); 3266f6174a7SRobert Watson 3276f6174a7SRobert Watson return (0); 3286f6174a7SRobert Watson } 3296f6174a7SRobert Watson 3306f6174a7SRobert Watson COUNTER_DECL(cred_check_setgid); 3316f6174a7SRobert Watson static int 3326f6174a7SRobert Watson test_cred_check_setgid(struct ucred *cred, gid_t gid) 3336f6174a7SRobert Watson { 3346f6174a7SRobert Watson 3356f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3366f6174a7SRobert Watson COUNTER_INC(cred_check_setgid); 3376f6174a7SRobert Watson 3386f6174a7SRobert Watson return (0); 3396f6174a7SRobert Watson } 3406f6174a7SRobert Watson 3416f6174a7SRobert Watson COUNTER_DECL(cred_check_setgroups); 3426f6174a7SRobert Watson static int 3436f6174a7SRobert Watson test_cred_check_setgroups(struct ucred *cred, int ngroups, 3446f6174a7SRobert Watson gid_t *gidset) 3456f6174a7SRobert Watson { 3466f6174a7SRobert Watson 3476f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3486f6174a7SRobert Watson COUNTER_INC(cred_check_setgroups); 3496f6174a7SRobert Watson 3506f6174a7SRobert Watson return (0); 3516f6174a7SRobert Watson } 3526f6174a7SRobert Watson 3536f6174a7SRobert Watson COUNTER_DECL(cred_check_setresgid); 3546f6174a7SRobert Watson static int 3556f6174a7SRobert Watson test_cred_check_setresgid(struct ucred *cred, gid_t rgid, gid_t egid, 3566f6174a7SRobert Watson gid_t sgid) 3576f6174a7SRobert Watson { 3586f6174a7SRobert Watson 3596f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3606f6174a7SRobert Watson COUNTER_INC(cred_check_setresgid); 3616f6174a7SRobert Watson 3626f6174a7SRobert Watson return (0); 3636f6174a7SRobert Watson } 3646f6174a7SRobert Watson 3656f6174a7SRobert Watson COUNTER_DECL(cred_check_setresuid); 3666f6174a7SRobert Watson static int 3676f6174a7SRobert Watson test_cred_check_setresuid(struct ucred *cred, uid_t ruid, uid_t euid, 3686f6174a7SRobert Watson uid_t suid) 3696f6174a7SRobert Watson { 3706f6174a7SRobert Watson 3716f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3726f6174a7SRobert Watson COUNTER_INC(cred_check_setresuid); 3736f6174a7SRobert Watson 3746f6174a7SRobert Watson return (0); 3756f6174a7SRobert Watson } 3766f6174a7SRobert Watson 3776f6174a7SRobert Watson COUNTER_DECL(cred_check_setuid); 3786f6174a7SRobert Watson static int 3796f6174a7SRobert Watson test_cred_check_setuid(struct ucred *cred, uid_t uid) 3806f6174a7SRobert Watson { 3816f6174a7SRobert Watson 3826f6174a7SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3836f6174a7SRobert Watson COUNTER_INC(cred_check_setuid); 3846f6174a7SRobert Watson 3856f6174a7SRobert Watson return (0); 3866f6174a7SRobert Watson } 3876f6174a7SRobert Watson 388eb320b0eSRobert Watson COUNTER_DECL(cred_check_visible); 389eb320b0eSRobert Watson static int 390eb320b0eSRobert Watson test_cred_check_visible(struct ucred *u1, struct ucred *u2) 391d8a7b7a3SRobert Watson { 392d8a7b7a3SRobert Watson 393eb320b0eSRobert Watson LABEL_CHECK(u1->cr_label, MAGIC_CRED); 394eb320b0eSRobert Watson LABEL_CHECK(u2->cr_label, MAGIC_CRED); 395eb320b0eSRobert Watson COUNTER_INC(cred_check_visible); 396d8a7b7a3SRobert Watson 397eb320b0eSRobert Watson return (0); 398d8a7b7a3SRobert Watson } 399d8a7b7a3SRobert Watson 40030d239bcSRobert Watson COUNTER_DECL(cred_copy_label); 4010196273bSRobert Watson static void 4023f1a7a90SRobert Watson test_cred_copy_label(struct label *src, struct label *dest) 40356d9e932SRobert Watson { 40456d9e932SRobert Watson 4056827d029SRobert Watson LABEL_CHECK(src, MAGIC_CRED); 4066827d029SRobert Watson LABEL_CHECK(dest, MAGIC_CRED); 40730d239bcSRobert Watson COUNTER_INC(cred_copy_label); 40856d9e932SRobert Watson } 40956d9e932SRobert Watson 410212ab0cfSRobert Watson COUNTER_DECL(cred_create_init); 411212ab0cfSRobert Watson static void 412212ab0cfSRobert Watson test_cred_create_init(struct ucred *cred) 413212ab0cfSRobert Watson { 414212ab0cfSRobert Watson 415212ab0cfSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 416212ab0cfSRobert Watson COUNTER_INC(cred_create_init); 417212ab0cfSRobert Watson } 418212ab0cfSRobert Watson 419212ab0cfSRobert Watson COUNTER_DECL(cred_create_swapper); 420212ab0cfSRobert Watson static void 421212ab0cfSRobert Watson test_cred_create_swapper(struct ucred *cred) 422212ab0cfSRobert Watson { 423212ab0cfSRobert Watson 424212ab0cfSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 425212ab0cfSRobert Watson COUNTER_INC(cred_create_swapper); 426212ab0cfSRobert Watson } 427212ab0cfSRobert Watson 428eb320b0eSRobert Watson COUNTER_DECL(cred_destroy_label); 42956d9e932SRobert Watson static void 430eb320b0eSRobert Watson test_cred_destroy_label(struct label *label) 4312220907bSRobert Watson { 4322220907bSRobert Watson 433eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_CRED); 434eb320b0eSRobert Watson COUNTER_INC(cred_destroy_label); 4350196273bSRobert Watson } 4360196273bSRobert Watson 437b0f4c777SRobert Watson COUNTER_DECL(cred_externalize_label); 438d8a7b7a3SRobert Watson static int 439b0f4c777SRobert Watson test_cred_externalize_label(struct label *label, char *element_name, 440f51e5803SRobert Watson struct sbuf *sb, int *claimed) 441d8a7b7a3SRobert Watson { 442d8a7b7a3SRobert Watson 443b0f4c777SRobert Watson LABEL_CHECK(label, MAGIC_CRED); 444b0f4c777SRobert Watson COUNTER_INC(cred_externalize_label); 445b0f4c777SRobert Watson 446b0f4c777SRobert Watson return (0); 447b0f4c777SRobert Watson } 448b0f4c777SRobert Watson 449eb320b0eSRobert Watson COUNTER_DECL(cred_init_label); 450d8a7b7a3SRobert Watson static void 451eb320b0eSRobert Watson test_cred_init_label(struct label *label) 452763bbd2fSRobert Watson { 453763bbd2fSRobert Watson 454eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_CRED); 455eb320b0eSRobert Watson COUNTER_INC(cred_init_label); 456763bbd2fSRobert Watson } 457763bbd2fSRobert Watson 4581876fb21SRobert Watson COUNTER_DECL(cred_internalize_label); 4591876fb21SRobert Watson static int 4601876fb21SRobert Watson test_cred_internalize_label(struct label *label, char *element_name, 4611876fb21SRobert Watson char *element_data, int *claimed) 4621876fb21SRobert Watson { 4631876fb21SRobert Watson 4641876fb21SRobert Watson LABEL_CHECK(label, MAGIC_CRED); 4651876fb21SRobert Watson COUNTER_INC(cred_internalize_label); 4661876fb21SRobert Watson 4671876fb21SRobert Watson return (0); 4681876fb21SRobert Watson } 4691876fb21SRobert Watson 470eb320b0eSRobert Watson COUNTER_DECL(cred_relabel); 471763bbd2fSRobert Watson static void 472eb320b0eSRobert Watson test_cred_relabel(struct ucred *cred, struct label *newlabel) 473763bbd2fSRobert Watson { 474763bbd2fSRobert Watson 475eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 476eb320b0eSRobert Watson LABEL_CHECK(newlabel, MAGIC_CRED); 477eb320b0eSRobert Watson COUNTER_INC(cred_relabel); 478763bbd2fSRobert Watson } 479763bbd2fSRobert Watson 4802449b9e5SMitchell Horne COUNTER_DECL(ddb_command_exec); 4812449b9e5SMitchell Horne static int 4822449b9e5SMitchell Horne test_ddb_command_exec(struct db_command *cmd, db_expr_t addr, bool have_addr, 4832449b9e5SMitchell Horne db_expr_t count, char *modif) 4842449b9e5SMitchell Horne { 4852449b9e5SMitchell Horne 4862449b9e5SMitchell Horne COUNTER_INC(ddb_command_exec); 4872449b9e5SMitchell Horne 4882449b9e5SMitchell Horne return (0); 4892449b9e5SMitchell Horne } 4902449b9e5SMitchell Horne 4912449b9e5SMitchell Horne COUNTER_DECL(ddb_command_register); 4922449b9e5SMitchell Horne static int 4932449b9e5SMitchell Horne test_ddb_command_register(struct db_command_table *table, 4942449b9e5SMitchell Horne struct db_command *cmd) 4952449b9e5SMitchell Horne { 4962449b9e5SMitchell Horne 4972449b9e5SMitchell Horne COUNTER_INC(ddb_command_register); 4982449b9e5SMitchell Horne 4992449b9e5SMitchell Horne return (0); 5002449b9e5SMitchell Horne } 5012449b9e5SMitchell Horne 50230d239bcSRobert Watson COUNTER_DECL(devfs_create_device); 503763bbd2fSRobert Watson static void 5043f1a7a90SRobert Watson test_devfs_create_device(struct ucred *cred, struct mount *mp, 50578007886SRobert Watson struct cdev *dev, struct devfs_dirent *de, struct label *delabel) 506d8a7b7a3SRobert Watson { 507d8a7b7a3SRobert Watson 5086827d029SRobert Watson if (cred != NULL) 5096827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 51078007886SRobert Watson LABEL_CHECK(delabel, MAGIC_DEVFS); 51130d239bcSRobert Watson COUNTER_INC(devfs_create_device); 512d8a7b7a3SRobert Watson } 513d8a7b7a3SRobert Watson 51430d239bcSRobert Watson COUNTER_DECL(devfs_create_directory); 515d8a7b7a3SRobert Watson static void 5163f1a7a90SRobert Watson test_devfs_create_directory(struct mount *mp, char *dirname, 51778007886SRobert Watson int dirnamelen, struct devfs_dirent *de, struct label *delabel) 518990b4b2dSRobert Watson { 519990b4b2dSRobert Watson 52078007886SRobert Watson LABEL_CHECK(delabel, MAGIC_DEVFS); 52130d239bcSRobert Watson COUNTER_INC(devfs_create_directory); 522990b4b2dSRobert Watson } 523990b4b2dSRobert Watson 52430d239bcSRobert Watson COUNTER_DECL(devfs_create_symlink); 525990b4b2dSRobert Watson static void 5263f1a7a90SRobert Watson test_devfs_create_symlink(struct ucred *cred, struct mount *mp, 527990b4b2dSRobert Watson struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de, 528990b4b2dSRobert Watson struct label *delabel) 529eea8ea31SRobert Watson { 530eea8ea31SRobert Watson 5316827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 5326827d029SRobert Watson LABEL_CHECK(ddlabel, MAGIC_DEVFS); 5336827d029SRobert Watson LABEL_CHECK(delabel, MAGIC_DEVFS); 53430d239bcSRobert Watson COUNTER_INC(devfs_create_symlink); 535eea8ea31SRobert Watson } 536eea8ea31SRobert Watson 537eb320b0eSRobert Watson COUNTER_DECL(devfs_destroy_label); 538d8a7b7a3SRobert Watson static void 539eb320b0eSRobert Watson test_devfs_destroy_label(struct label *label) 540d8a7b7a3SRobert Watson { 541d8a7b7a3SRobert Watson 542eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_DEVFS); 543eb320b0eSRobert Watson COUNTER_INC(devfs_destroy_label); 544d8a7b7a3SRobert Watson } 545d8a7b7a3SRobert Watson 546eb320b0eSRobert Watson COUNTER_DECL(devfs_init_label); 547d8a7b7a3SRobert Watson static void 548eb320b0eSRobert Watson test_devfs_init_label(struct label *label) 549d8a7b7a3SRobert Watson { 550d8a7b7a3SRobert Watson 551eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_DEVFS); 552eb320b0eSRobert Watson COUNTER_INC(devfs_init_label); 553d8a7b7a3SRobert Watson } 554d8a7b7a3SRobert Watson 55530d239bcSRobert Watson COUNTER_DECL(devfs_update); 556d8a7b7a3SRobert Watson static void 5573f1a7a90SRobert Watson test_devfs_update(struct mount *mp, struct devfs_dirent *devfs_dirent, 55830575990SRobert Watson struct label *direntlabel, struct vnode *vp, struct label *vplabel) 559d8a7b7a3SRobert Watson { 560d8a7b7a3SRobert Watson 5616827d029SRobert Watson LABEL_CHECK(direntlabel, MAGIC_DEVFS); 56278007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 56330d239bcSRobert Watson COUNTER_INC(devfs_update); 564d8a7b7a3SRobert Watson } 565d8a7b7a3SRobert Watson 566eb320b0eSRobert Watson COUNTER_DECL(devfs_vnode_associate); 567d8a7b7a3SRobert Watson static void 568eb320b0eSRobert Watson test_devfs_vnode_associate(struct mount *mp, struct label *mplabel, 569eb320b0eSRobert Watson struct devfs_dirent *de, struct label *delabel, struct vnode *vp, 570eb320b0eSRobert Watson struct label *vplabel) 571d8a7b7a3SRobert Watson { 572d8a7b7a3SRobert Watson 573eb320b0eSRobert Watson LABEL_CHECK(mplabel, MAGIC_MOUNT); 574eb320b0eSRobert Watson LABEL_CHECK(delabel, MAGIC_DEVFS); 575eb320b0eSRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 576eb320b0eSRobert Watson COUNTER_INC(devfs_vnode_associate); 577d8a7b7a3SRobert Watson } 578d8a7b7a3SRobert Watson 57930d239bcSRobert Watson COUNTER_DECL(ifnet_check_relabel); 580d8a7b7a3SRobert Watson static int 5813f1a7a90SRobert Watson test_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, 582a7f3aac7SRobert Watson struct label *ifplabel, struct label *newlabel) 583d8a7b7a3SRobert Watson { 584d8a7b7a3SRobert Watson 5856827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 586a7f3aac7SRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 5876827d029SRobert Watson LABEL_CHECK(newlabel, MAGIC_IFNET); 58830d239bcSRobert Watson COUNTER_INC(ifnet_check_relabel); 589269ad130SRobert Watson 590d8a7b7a3SRobert Watson return (0); 591d8a7b7a3SRobert Watson } 592d8a7b7a3SRobert Watson 59330d239bcSRobert Watson COUNTER_DECL(ifnet_check_transmit); 594d8a7b7a3SRobert Watson static int 5953f1a7a90SRobert Watson test_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, 596f0336833SRobert Watson struct mbuf *m, struct label *mlabel) 597d8a7b7a3SRobert Watson { 598d8a7b7a3SRobert Watson 599a7f3aac7SRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 600f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 60130d239bcSRobert Watson COUNTER_INC(ifnet_check_transmit); 602250ee706SRobert Watson 603d8a7b7a3SRobert Watson return (0); 604d8a7b7a3SRobert Watson } 605d8a7b7a3SRobert Watson 606eb320b0eSRobert Watson COUNTER_DECL(ifnet_copy_label); 607eb320b0eSRobert Watson static void 608eb320b0eSRobert Watson test_ifnet_copy_label(struct label *src, struct label *dest) 609eb320b0eSRobert Watson { 610eb320b0eSRobert Watson 611eb320b0eSRobert Watson LABEL_CHECK(src, MAGIC_IFNET); 612eb320b0eSRobert Watson LABEL_CHECK(dest, MAGIC_IFNET); 613eb320b0eSRobert Watson COUNTER_INC(ifnet_copy_label); 614eb320b0eSRobert Watson } 615eb320b0eSRobert Watson 616eb320b0eSRobert Watson COUNTER_DECL(ifnet_create); 617eb320b0eSRobert Watson static void 618eb320b0eSRobert Watson test_ifnet_create(struct ifnet *ifp, struct label *ifplabel) 619eb320b0eSRobert Watson { 620eb320b0eSRobert Watson 621eb320b0eSRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 622eb320b0eSRobert Watson COUNTER_INC(ifnet_create); 623eb320b0eSRobert Watson } 624eb320b0eSRobert Watson 625eb320b0eSRobert Watson COUNTER_DECL(ifnet_create_mbuf); 626eb320b0eSRobert Watson static void 627eb320b0eSRobert Watson test_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, 628f0336833SRobert Watson struct mbuf *m, struct label *mlabel) 629eb320b0eSRobert Watson { 630eb320b0eSRobert Watson 631eb320b0eSRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 632f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 633eb320b0eSRobert Watson COUNTER_INC(ifnet_create_mbuf); 634eb320b0eSRobert Watson } 635eb320b0eSRobert Watson 636eb320b0eSRobert Watson COUNTER_DECL(ifnet_destroy_label); 637eb320b0eSRobert Watson static void 638eb320b0eSRobert Watson test_ifnet_destroy_label(struct label *label) 639eb320b0eSRobert Watson { 640eb320b0eSRobert Watson 641eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_IFNET); 642eb320b0eSRobert Watson COUNTER_INC(ifnet_destroy_label); 643eb320b0eSRobert Watson } 644eb320b0eSRobert Watson 645eb320b0eSRobert Watson COUNTER_DECL(ifnet_externalize_label); 646eb320b0eSRobert Watson static int 647eb320b0eSRobert Watson test_ifnet_externalize_label(struct label *label, char *element_name, 648eb320b0eSRobert Watson struct sbuf *sb, int *claimed) 649eb320b0eSRobert Watson { 650eb320b0eSRobert Watson 651eb320b0eSRobert Watson LABEL_CHECK(label, MAGIC_IFNET); 652eb320b0eSRobert Watson COUNTER_INC(ifnet_externalize_label); 653eb320b0eSRobert Watson 654eb320b0eSRobert Watson return (0); 655eb320b0eSRobert Watson } 656eb320b0eSRobert Watson 657eb320b0eSRobert Watson COUNTER_DECL(ifnet_init_label); 658eb320b0eSRobert Watson static void 659eb320b0eSRobert Watson test_ifnet_init_label(struct label *label) 660eb320b0eSRobert Watson { 661eb320b0eSRobert Watson 662eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_IFNET); 663eb320b0eSRobert Watson COUNTER_INC(ifnet_init_label); 664eb320b0eSRobert Watson } 665eb320b0eSRobert Watson 6661876fb21SRobert Watson COUNTER_DECL(ifnet_internalize_label); 6671876fb21SRobert Watson static int 6681876fb21SRobert Watson test_ifnet_internalize_label(struct label *label, char *element_name, 6691876fb21SRobert Watson char *element_data, int *claimed) 6701876fb21SRobert Watson { 6711876fb21SRobert Watson 6721876fb21SRobert Watson LABEL_CHECK(label, MAGIC_IFNET); 6731876fb21SRobert Watson COUNTER_INC(ifnet_internalize_label); 6741876fb21SRobert Watson 6751876fb21SRobert Watson return (0); 6761876fb21SRobert Watson } 6771876fb21SRobert Watson 678eb320b0eSRobert Watson COUNTER_DECL(ifnet_relabel); 679eb320b0eSRobert Watson static void 680eb320b0eSRobert Watson test_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, 681eb320b0eSRobert Watson struct label *ifplabel, struct label *newlabel) 682eb320b0eSRobert Watson { 683eb320b0eSRobert Watson 684eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 685eb320b0eSRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 686eb320b0eSRobert Watson LABEL_CHECK(newlabel, MAGIC_IFNET); 687eb320b0eSRobert Watson COUNTER_INC(ifnet_relabel); 688eb320b0eSRobert Watson } 689eb320b0eSRobert Watson 69030d239bcSRobert Watson COUNTER_DECL(inpcb_check_deliver); 691d8a7b7a3SRobert Watson static int 6923f1a7a90SRobert Watson test_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, 693a557af22SRobert Watson struct mbuf *m, struct label *mlabel) 694a557af22SRobert Watson { 695a557af22SRobert Watson 6966827d029SRobert Watson LABEL_CHECK(inplabel, MAGIC_INPCB); 6976827d029SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 69830d239bcSRobert Watson COUNTER_INC(inpcb_check_deliver); 699a557af22SRobert Watson 700a557af22SRobert Watson return (0); 701a557af22SRobert Watson } 702a557af22SRobert Watson 7037fb179baSBjoern A. Zeeb COUNTER_DECL(inpcb_check_visible); 7047fb179baSBjoern A. Zeeb static int 7057fb179baSBjoern A. Zeeb test_inpcb_check_visible(struct ucred *cred, struct inpcb *inp, 7067fb179baSBjoern A. Zeeb struct label *inplabel) 7077fb179baSBjoern A. Zeeb { 7087fb179baSBjoern A. Zeeb 7097fb179baSBjoern A. Zeeb LABEL_CHECK(cred->cr_label, MAGIC_CRED); 7107fb179baSBjoern A. Zeeb LABEL_CHECK(inplabel, MAGIC_INPCB); 7117fb179baSBjoern A. Zeeb COUNTER_INC(inpcb_check_visible); 7127fb179baSBjoern A. Zeeb 7137fb179baSBjoern A. Zeeb return (0); 7147fb179baSBjoern A. Zeeb } 7157fb179baSBjoern A. Zeeb 716eb320b0eSRobert Watson COUNTER_DECL(inpcb_create); 717eb320b0eSRobert Watson static void 718eb320b0eSRobert Watson test_inpcb_create(struct socket *so, struct label *solabel, 719eb320b0eSRobert Watson struct inpcb *inp, struct label *inplabel) 7207e400ed1SRobert Watson { 7217e400ed1SRobert Watson 7223de40469SRobert Watson SOCK_LOCK(so); 723eb320b0eSRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 7243de40469SRobert Watson SOCK_UNLOCK(so); 725eb320b0eSRobert Watson LABEL_CHECK(inplabel, MAGIC_INPCB); 726eb320b0eSRobert Watson COUNTER_INC(inpcb_create); 727eb320b0eSRobert Watson } 7287e400ed1SRobert Watson 729eb320b0eSRobert Watson COUNTER_DECL(inpcb_create_mbuf); 730eb320b0eSRobert Watson static void 731eb320b0eSRobert Watson test_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, 732eb320b0eSRobert Watson struct mbuf *m, struct label *mlabel) 733eb320b0eSRobert Watson { 734eb320b0eSRobert Watson 735eb320b0eSRobert Watson LABEL_CHECK(inplabel, MAGIC_INPCB); 736eb320b0eSRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 737eb320b0eSRobert Watson COUNTER_INC(inpcb_create_mbuf); 738eb320b0eSRobert Watson } 739eb320b0eSRobert Watson 740eb320b0eSRobert Watson COUNTER_DECL(inpcb_destroy_label); 741eb320b0eSRobert Watson static void 742eb320b0eSRobert Watson test_inpcb_destroy_label(struct label *label) 743eb320b0eSRobert Watson { 744eb320b0eSRobert Watson 745eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_INPCB); 746eb320b0eSRobert Watson COUNTER_INC(inpcb_destroy_label); 747eb320b0eSRobert Watson } 748eb320b0eSRobert Watson 749eb320b0eSRobert Watson COUNTER_DECL(inpcb_init_label); 750eb320b0eSRobert Watson static int 751eb320b0eSRobert Watson test_inpcb_init_label(struct label *label, int flag) 752eb320b0eSRobert Watson { 753eb320b0eSRobert Watson 754eb320b0eSRobert Watson if (flag & M_WAITOK) 755eb320b0eSRobert Watson WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 756eb320b0eSRobert Watson "test_inpcb_init_label() at %s:%d", __FILE__, 757eb320b0eSRobert Watson __LINE__); 758eb320b0eSRobert Watson 759eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_INPCB); 760eb320b0eSRobert Watson COUNTER_INC(inpcb_init_label); 7617e400ed1SRobert Watson return (0); 7627e400ed1SRobert Watson } 7637e400ed1SRobert Watson 764eb320b0eSRobert Watson COUNTER_DECL(inpcb_sosetlabel); 765eb320b0eSRobert Watson static void 766eb320b0eSRobert Watson test_inpcb_sosetlabel(struct socket *so, struct label *solabel, 767eb320b0eSRobert Watson struct inpcb *inp, struct label *inplabel) 7687e400ed1SRobert Watson { 7697e400ed1SRobert Watson 7703de40469SRobert Watson SOCK_LOCK_ASSERT(so); 7713de40469SRobert Watson 772eb320b0eSRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 773eb320b0eSRobert Watson LABEL_CHECK(inplabel, MAGIC_INPCB); 774eb320b0eSRobert Watson COUNTER_INC(inpcb_sosetlabel); 775eb320b0eSRobert Watson } 7767e400ed1SRobert Watson 777048e1287SRobert Watson COUNTER_DECL(ip6q_create); 778048e1287SRobert Watson static void 779048e1287SRobert Watson test_ip6q_create(struct mbuf *fragment, struct label *fragmentlabel, 780048e1287SRobert Watson struct ip6q *q6, struct label *q6label) 781048e1287SRobert Watson { 782048e1287SRobert Watson 783048e1287SRobert Watson LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 784048e1287SRobert Watson LABEL_CHECK(q6label, MAGIC_IP6Q); 785048e1287SRobert Watson COUNTER_INC(ip6q_create); 786048e1287SRobert Watson } 787048e1287SRobert Watson 788048e1287SRobert Watson COUNTER_DECL(ip6q_destroy_label); 789048e1287SRobert Watson static void 790048e1287SRobert Watson test_ip6q_destroy_label(struct label *label) 791048e1287SRobert Watson { 792048e1287SRobert Watson 793048e1287SRobert Watson LABEL_DESTROY(label, MAGIC_IP6Q); 794048e1287SRobert Watson COUNTER_INC(ip6q_destroy_label); 795048e1287SRobert Watson } 796048e1287SRobert Watson 797048e1287SRobert Watson COUNTER_DECL(ip6q_init_label); 798048e1287SRobert Watson static int 799048e1287SRobert Watson test_ip6q_init_label(struct label *label, int flag) 800048e1287SRobert Watson { 801048e1287SRobert Watson 802048e1287SRobert Watson if (flag & M_WAITOK) 803048e1287SRobert Watson WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 804048e1287SRobert Watson "test_ip6q_init_label() at %s:%d", __FILE__, 805048e1287SRobert Watson __LINE__); 806048e1287SRobert Watson 807048e1287SRobert Watson LABEL_INIT(label, MAGIC_IP6Q); 808048e1287SRobert Watson COUNTER_INC(ip6q_init_label); 809048e1287SRobert Watson return (0); 810048e1287SRobert Watson } 811048e1287SRobert Watson 812048e1287SRobert Watson COUNTER_DECL(ip6q_match); 813048e1287SRobert Watson static int 814048e1287SRobert Watson test_ip6q_match(struct mbuf *fragment, struct label *fragmentlabel, 815048e1287SRobert Watson struct ip6q *q6, struct label *q6label) 816048e1287SRobert Watson { 817048e1287SRobert Watson 818048e1287SRobert Watson LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 819048e1287SRobert Watson LABEL_CHECK(q6label, MAGIC_IP6Q); 820048e1287SRobert Watson COUNTER_INC(ip6q_match); 821048e1287SRobert Watson 822048e1287SRobert Watson return (1); 823048e1287SRobert Watson } 824048e1287SRobert Watson 825048e1287SRobert Watson COUNTER_DECL(ip6q_reassemble); 826048e1287SRobert Watson static void 827048e1287SRobert Watson test_ip6q_reassemble(struct ip6q *q6, struct label *q6label, struct mbuf *m, 828048e1287SRobert Watson struct label *mlabel) 829048e1287SRobert Watson { 830048e1287SRobert Watson 831048e1287SRobert Watson LABEL_CHECK(q6label, MAGIC_IP6Q); 832048e1287SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 833048e1287SRobert Watson COUNTER_INC(ip6q_reassemble); 834048e1287SRobert Watson } 835048e1287SRobert Watson 836048e1287SRobert Watson COUNTER_DECL(ip6q_update); 837048e1287SRobert Watson static void 838048e1287SRobert Watson test_ip6q_update(struct mbuf *m, struct label *mlabel, struct ip6q *q6, 839048e1287SRobert Watson struct label *q6label) 840048e1287SRobert Watson { 841048e1287SRobert Watson 842048e1287SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 843048e1287SRobert Watson LABEL_CHECK(q6label, MAGIC_IP6Q); 844048e1287SRobert Watson COUNTER_INC(ip6q_update); 845048e1287SRobert Watson } 846048e1287SRobert Watson 847eb320b0eSRobert Watson COUNTER_DECL(ipq_create); 848eb320b0eSRobert Watson static void 849eb320b0eSRobert Watson test_ipq_create(struct mbuf *fragment, struct label *fragmentlabel, 85037f44cb4SRobert Watson struct ipq *q, struct label *qlabel) 851eb320b0eSRobert Watson { 852eb320b0eSRobert Watson 853eb320b0eSRobert Watson LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 85437f44cb4SRobert Watson LABEL_CHECK(qlabel, MAGIC_IPQ); 855eb320b0eSRobert Watson COUNTER_INC(ipq_create); 856eb320b0eSRobert Watson } 857eb320b0eSRobert Watson 858eb320b0eSRobert Watson COUNTER_DECL(ipq_destroy_label); 859eb320b0eSRobert Watson static void 860eb320b0eSRobert Watson test_ipq_destroy_label(struct label *label) 861eb320b0eSRobert Watson { 862eb320b0eSRobert Watson 863eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_IPQ); 864eb320b0eSRobert Watson COUNTER_INC(ipq_destroy_label); 865eb320b0eSRobert Watson } 866eb320b0eSRobert Watson 867eb320b0eSRobert Watson COUNTER_DECL(ipq_init_label); 868eb320b0eSRobert Watson static int 869eb320b0eSRobert Watson test_ipq_init_label(struct label *label, int flag) 870eb320b0eSRobert Watson { 871eb320b0eSRobert Watson 872eb320b0eSRobert Watson if (flag & M_WAITOK) 873eb320b0eSRobert Watson WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 874eb320b0eSRobert Watson "test_ipq_init_label() at %s:%d", __FILE__, 875eb320b0eSRobert Watson __LINE__); 876eb320b0eSRobert Watson 877eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_IPQ); 878eb320b0eSRobert Watson COUNTER_INC(ipq_init_label); 8797e400ed1SRobert Watson return (0); 8807e400ed1SRobert Watson } 8817e400ed1SRobert Watson 882eb320b0eSRobert Watson COUNTER_DECL(ipq_match); 8837e400ed1SRobert Watson static int 884eb320b0eSRobert Watson test_ipq_match(struct mbuf *fragment, struct label *fragmentlabel, 88537f44cb4SRobert Watson struct ipq *q, struct label *qlabel) 8867e400ed1SRobert Watson { 8877e400ed1SRobert Watson 888eb320b0eSRobert Watson LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 88937f44cb4SRobert Watson LABEL_CHECK(qlabel, MAGIC_IPQ); 890eb320b0eSRobert Watson COUNTER_INC(ipq_match); 8917e400ed1SRobert Watson 892eb320b0eSRobert Watson return (1); 8937e400ed1SRobert Watson } 8947e400ed1SRobert Watson 895eb320b0eSRobert Watson COUNTER_DECL(ipq_reassemble); 896eb320b0eSRobert Watson static void 89737f44cb4SRobert Watson test_ipq_reassemble(struct ipq *q, struct label *qlabel, struct mbuf *m, 898f0336833SRobert Watson struct label *mlabel) 8997e400ed1SRobert Watson { 9007e400ed1SRobert Watson 90137f44cb4SRobert Watson LABEL_CHECK(qlabel, MAGIC_IPQ); 902f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 903eb320b0eSRobert Watson COUNTER_INC(ipq_reassemble); 9047e400ed1SRobert Watson } 9057e400ed1SRobert Watson 906eb320b0eSRobert Watson COUNTER_DECL(ipq_update); 907eb320b0eSRobert Watson static void 90837f44cb4SRobert Watson test_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *q, 90937f44cb4SRobert Watson struct label *qlabel) 9107e400ed1SRobert Watson { 9117e400ed1SRobert Watson 912f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 91337f44cb4SRobert Watson LABEL_CHECK(qlabel, MAGIC_IPQ); 914eb320b0eSRobert Watson COUNTER_INC(ipq_update); 9157e400ed1SRobert Watson } 9167e400ed1SRobert Watson 9172449b9e5SMitchell Horne COUNTER_DECL(kdb_backend_check); 9182449b9e5SMitchell Horne static int 9192449b9e5SMitchell Horne test_kdb_check_backend(struct kdb_dbbe *be) 9202449b9e5SMitchell Horne { 9212449b9e5SMitchell Horne 9222449b9e5SMitchell Horne COUNTER_INC(kdb_backend_check); 9232449b9e5SMitchell Horne 9242449b9e5SMitchell Horne return (0); 9252449b9e5SMitchell Horne } 9262449b9e5SMitchell Horne 92730d239bcSRobert Watson COUNTER_DECL(kenv_check_dump); 9287e400ed1SRobert Watson static int 9293f1a7a90SRobert Watson test_kenv_check_dump(struct ucred *cred) 930ca26e8baSRobert Watson { 931ca26e8baSRobert Watson 9326827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 93330d239bcSRobert Watson COUNTER_INC(kenv_check_dump); 934250ee706SRobert Watson 935ca26e8baSRobert Watson return (0); 936ca26e8baSRobert Watson } 937ca26e8baSRobert Watson 93830d239bcSRobert Watson COUNTER_DECL(kenv_check_get); 939ca26e8baSRobert Watson static int 9403f1a7a90SRobert Watson test_kenv_check_get(struct ucred *cred, char *name) 941ca26e8baSRobert Watson { 942ca26e8baSRobert Watson 9436827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 94430d239bcSRobert Watson COUNTER_INC(kenv_check_get); 945250ee706SRobert Watson 946ca26e8baSRobert Watson return (0); 947ca26e8baSRobert Watson } 948ca26e8baSRobert Watson 94930d239bcSRobert Watson COUNTER_DECL(kenv_check_set); 950ca26e8baSRobert Watson static int 9513f1a7a90SRobert Watson test_kenv_check_set(struct ucred *cred, char *name, char *value) 952ca26e8baSRobert Watson { 953ca26e8baSRobert Watson 9546827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 95530d239bcSRobert Watson COUNTER_INC(kenv_check_set); 956250ee706SRobert Watson 957ca26e8baSRobert Watson return (0); 958ca26e8baSRobert Watson } 959ca26e8baSRobert Watson 96030d239bcSRobert Watson COUNTER_DECL(kenv_check_unset); 961ca26e8baSRobert Watson static int 9623f1a7a90SRobert Watson test_kenv_check_unset(struct ucred *cred, char *name) 963ca26e8baSRobert Watson { 964ca26e8baSRobert Watson 9656827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 96630d239bcSRobert Watson COUNTER_INC(kenv_check_unset); 967250ee706SRobert Watson 968ca26e8baSRobert Watson return (0); 969ca26e8baSRobert Watson } 970ca26e8baSRobert Watson 97130d239bcSRobert Watson COUNTER_DECL(kld_check_load); 972ca26e8baSRobert Watson static int 9733f1a7a90SRobert Watson test_kld_check_load(struct ucred *cred, struct vnode *vp, 974ca26e8baSRobert Watson struct label *label) 975ca26e8baSRobert Watson { 976ca26e8baSRobert Watson 9776827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 9786827d029SRobert Watson LABEL_CHECK(label, MAGIC_VNODE); 97930d239bcSRobert Watson COUNTER_INC(kld_check_load); 980250ee706SRobert Watson 981ca26e8baSRobert Watson return (0); 982ca26e8baSRobert Watson } 983ca26e8baSRobert Watson 98430d239bcSRobert Watson COUNTER_DECL(kld_check_stat); 985ca26e8baSRobert Watson static int 9863f1a7a90SRobert Watson test_kld_check_stat(struct ucred *cred) 987ca26e8baSRobert Watson { 988ca26e8baSRobert Watson 9896827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 99030d239bcSRobert Watson COUNTER_INC(kld_check_stat); 991250ee706SRobert Watson 992ca26e8baSRobert Watson return (0); 993ca26e8baSRobert Watson } 994ca26e8baSRobert Watson 995eb320b0eSRobert Watson COUNTER_DECL(mbuf_copy_label); 996eb320b0eSRobert Watson static void 997eb320b0eSRobert Watson test_mbuf_copy_label(struct label *src, struct label *dest) 998eb320b0eSRobert Watson { 999eb320b0eSRobert Watson 1000eb320b0eSRobert Watson LABEL_CHECK(src, MAGIC_MBUF); 1001eb320b0eSRobert Watson LABEL_CHECK(dest, MAGIC_MBUF); 1002eb320b0eSRobert Watson COUNTER_INC(mbuf_copy_label); 1003eb320b0eSRobert Watson } 1004eb320b0eSRobert Watson 1005eb320b0eSRobert Watson COUNTER_DECL(mbuf_destroy_label); 1006eb320b0eSRobert Watson static void 1007eb320b0eSRobert Watson test_mbuf_destroy_label(struct label *label) 1008eb320b0eSRobert Watson { 1009eb320b0eSRobert Watson 1010eb320b0eSRobert Watson /* 1011eb320b0eSRobert Watson * If we're loaded dynamically, there may be mbufs in flight that 1012eb320b0eSRobert Watson * didn't have label storage allocated for them. Handle this 1013eb320b0eSRobert Watson * gracefully. 1014eb320b0eSRobert Watson */ 1015eb320b0eSRobert Watson if (label == NULL) 1016eb320b0eSRobert Watson return; 1017eb320b0eSRobert Watson 1018eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_MBUF); 1019eb320b0eSRobert Watson COUNTER_INC(mbuf_destroy_label); 1020eb320b0eSRobert Watson } 1021eb320b0eSRobert Watson 1022eb320b0eSRobert Watson COUNTER_DECL(mbuf_init_label); 1023eb320b0eSRobert Watson static int 1024eb320b0eSRobert Watson test_mbuf_init_label(struct label *label, int flag) 1025eb320b0eSRobert Watson { 1026eb320b0eSRobert Watson 1027eb320b0eSRobert Watson if (flag & M_WAITOK) 1028eb320b0eSRobert Watson WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 1029eb320b0eSRobert Watson "test_mbuf_init_label() at %s:%d", __FILE__, 1030eb320b0eSRobert Watson __LINE__); 1031eb320b0eSRobert Watson 1032eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_MBUF); 1033eb320b0eSRobert Watson COUNTER_INC(mbuf_init_label); 1034eb320b0eSRobert Watson return (0); 1035eb320b0eSRobert Watson } 1036eb320b0eSRobert Watson 103730d239bcSRobert Watson COUNTER_DECL(mount_check_stat); 1038ca26e8baSRobert Watson static int 10393f1a7a90SRobert Watson test_mount_check_stat(struct ucred *cred, struct mount *mp, 104078007886SRobert Watson struct label *mplabel) 1041d8a7b7a3SRobert Watson { 1042d8a7b7a3SRobert Watson 10436827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 104478007886SRobert Watson LABEL_CHECK(mplabel, MAGIC_MOUNT); 104530d239bcSRobert Watson COUNTER_INC(mount_check_stat); 1046250ee706SRobert Watson 1047d8a7b7a3SRobert Watson return (0); 1048d8a7b7a3SRobert Watson } 1049d8a7b7a3SRobert Watson 1050eb320b0eSRobert Watson COUNTER_DECL(mount_create); 1051eb320b0eSRobert Watson static void 1052eb320b0eSRobert Watson test_mount_create(struct ucred *cred, struct mount *mp, 1053eb320b0eSRobert Watson struct label *mplabel) 1054eb320b0eSRobert Watson { 1055eb320b0eSRobert Watson 1056eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1057eb320b0eSRobert Watson LABEL_CHECK(mplabel, MAGIC_MOUNT); 1058eb320b0eSRobert Watson COUNTER_INC(mount_create); 1059eb320b0eSRobert Watson } 1060eb320b0eSRobert Watson 1061eb320b0eSRobert Watson COUNTER_DECL(mount_destroy_label); 1062eb320b0eSRobert Watson static void 1063eb320b0eSRobert Watson test_mount_destroy_label(struct label *label) 1064eb320b0eSRobert Watson { 1065eb320b0eSRobert Watson 1066eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_MOUNT); 1067eb320b0eSRobert Watson COUNTER_INC(mount_destroy_label); 1068eb320b0eSRobert Watson } 1069eb320b0eSRobert Watson 1070eb320b0eSRobert Watson COUNTER_DECL(mount_init_label); 1071eb320b0eSRobert Watson static void 1072eb320b0eSRobert Watson test_mount_init_label(struct label *label) 1073eb320b0eSRobert Watson { 1074eb320b0eSRobert Watson 1075eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_MOUNT); 1076eb320b0eSRobert Watson COUNTER_INC(mount_init_label); 1077eb320b0eSRobert Watson } 1078eb320b0eSRobert Watson 1079eb320b0eSRobert Watson COUNTER_DECL(netinet_arp_send); 1080eb320b0eSRobert Watson static void 1081eb320b0eSRobert Watson test_netinet_arp_send(struct ifnet *ifp, struct label *ifplabel, 1082f0336833SRobert Watson struct mbuf *m, struct label *mlabel) 1083eb320b0eSRobert Watson { 1084eb320b0eSRobert Watson 1085eb320b0eSRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 1086f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 1087eb320b0eSRobert Watson COUNTER_INC(netinet_arp_send); 1088eb320b0eSRobert Watson } 1089eb320b0eSRobert Watson 1090eb320b0eSRobert Watson COUNTER_DECL(netinet_fragment); 1091eb320b0eSRobert Watson static void 1092f0336833SRobert Watson test_netinet_fragment(struct mbuf *m, struct label *mlabel, 1093f0336833SRobert Watson struct mbuf *frag, struct label *fraglabel) 1094eb320b0eSRobert Watson { 1095eb320b0eSRobert Watson 1096f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 1097f0336833SRobert Watson LABEL_CHECK(fraglabel, MAGIC_MBUF); 1098eb320b0eSRobert Watson COUNTER_INC(netinet_fragment); 1099eb320b0eSRobert Watson } 1100eb320b0eSRobert Watson 1101eb320b0eSRobert Watson COUNTER_DECL(netinet_icmp_reply); 1102eb320b0eSRobert Watson static void 1103eb320b0eSRobert Watson test_netinet_icmp_reply(struct mbuf *mrecv, struct label *mrecvlabel, 1104eb320b0eSRobert Watson struct mbuf *msend, struct label *msendlabel) 1105eb320b0eSRobert Watson { 1106eb320b0eSRobert Watson 1107eb320b0eSRobert Watson LABEL_CHECK(mrecvlabel, MAGIC_MBUF); 1108eb320b0eSRobert Watson LABEL_CHECK(msendlabel, MAGIC_MBUF); 1109eb320b0eSRobert Watson COUNTER_INC(netinet_icmp_reply); 1110eb320b0eSRobert Watson } 1111eb320b0eSRobert Watson 1112eb320b0eSRobert Watson COUNTER_DECL(netinet_icmp_replyinplace); 1113eb320b0eSRobert Watson static void 1114eb320b0eSRobert Watson test_netinet_icmp_replyinplace(struct mbuf *m, struct label *mlabel) 1115eb320b0eSRobert Watson { 1116eb320b0eSRobert Watson 1117eb320b0eSRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 1118eb320b0eSRobert Watson COUNTER_INC(netinet_icmp_replyinplace); 1119eb320b0eSRobert Watson } 1120eb320b0eSRobert Watson 1121eb320b0eSRobert Watson COUNTER_DECL(netinet_igmp_send); 1122eb320b0eSRobert Watson static void 1123eb320b0eSRobert Watson test_netinet_igmp_send(struct ifnet *ifp, struct label *ifplabel, 1124f0336833SRobert Watson struct mbuf *m, struct label *mlabel) 1125eb320b0eSRobert Watson { 1126eb320b0eSRobert Watson 1127eb320b0eSRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 1128f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 1129eb320b0eSRobert Watson COUNTER_INC(netinet_igmp_send); 1130eb320b0eSRobert Watson } 1131eb320b0eSRobert Watson 1132eb320b0eSRobert Watson COUNTER_DECL(netinet_tcp_reply); 1133eb320b0eSRobert Watson static void 1134eb320b0eSRobert Watson test_netinet_tcp_reply(struct mbuf *m, struct label *mlabel) 1135eb320b0eSRobert Watson { 1136eb320b0eSRobert Watson 1137eb320b0eSRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 1138eb320b0eSRobert Watson COUNTER_INC(netinet_tcp_reply); 1139eb320b0eSRobert Watson } 1140eb320b0eSRobert Watson 1141eb320b0eSRobert Watson COUNTER_DECL(netinet6_nd6_send); 1142eb320b0eSRobert Watson static void 1143eb320b0eSRobert Watson test_netinet6_nd6_send(struct ifnet *ifp, struct label *ifplabel, 1144f0336833SRobert Watson struct mbuf *m, struct label *mlabel) 1145eb320b0eSRobert Watson { 1146eb320b0eSRobert Watson 1147eb320b0eSRobert Watson LABEL_CHECK(ifplabel, MAGIC_IFNET); 1148f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 1149eb320b0eSRobert Watson COUNTER_INC(netinet6_nd6_send); 1150eb320b0eSRobert Watson } 1151eb320b0eSRobert Watson 115230d239bcSRobert Watson COUNTER_DECL(pipe_check_ioctl); 1153d8a7b7a3SRobert Watson static int 11543f1a7a90SRobert Watson test_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, 1155f0336833SRobert Watson struct label *pplabel, unsigned long cmd, void /* caddr_t */ *data) 1156d8a7b7a3SRobert Watson { 1157d8a7b7a3SRobert Watson 11586827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1159f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 116030d239bcSRobert Watson COUNTER_INC(pipe_check_ioctl); 1161250ee706SRobert Watson 1162d8a7b7a3SRobert Watson return (0); 1163d8a7b7a3SRobert Watson } 1164d8a7b7a3SRobert Watson 116530d239bcSRobert Watson COUNTER_DECL(pipe_check_poll); 1166d8a7b7a3SRobert Watson static int 11673f1a7a90SRobert Watson test_pipe_check_poll(struct ucred *cred, struct pipepair *pp, 1168f0336833SRobert Watson struct label *pplabel) 1169c024c3eeSRobert Watson { 1170c024c3eeSRobert Watson 11716827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1172f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 117330d239bcSRobert Watson COUNTER_INC(pipe_check_poll); 1174250ee706SRobert Watson 1175c024c3eeSRobert Watson return (0); 1176c024c3eeSRobert Watson } 1177c024c3eeSRobert Watson 117830d239bcSRobert Watson COUNTER_DECL(pipe_check_read); 1179c024c3eeSRobert Watson static int 11803f1a7a90SRobert Watson test_pipe_check_read(struct ucred *cred, struct pipepair *pp, 1181f0336833SRobert Watson struct label *pplabel) 1182d8a7b7a3SRobert Watson { 1183d8a7b7a3SRobert Watson 11846827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1185f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 118630d239bcSRobert Watson COUNTER_INC(pipe_check_read); 1187250ee706SRobert Watson 1188d8a7b7a3SRobert Watson return (0); 1189d8a7b7a3SRobert Watson } 1190d8a7b7a3SRobert Watson 119130d239bcSRobert Watson COUNTER_DECL(pipe_check_relabel); 1192d8a7b7a3SRobert Watson static int 11933f1a7a90SRobert Watson test_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, 1194f0336833SRobert Watson struct label *pplabel, struct label *newlabel) 1195d8a7b7a3SRobert Watson { 1196d8a7b7a3SRobert Watson 11976827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1198f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 11996827d029SRobert Watson LABEL_CHECK(newlabel, MAGIC_PIPE); 120030d239bcSRobert Watson COUNTER_INC(pipe_check_relabel); 1201250ee706SRobert Watson 1202d8a7b7a3SRobert Watson return (0); 1203d8a7b7a3SRobert Watson } 1204d8a7b7a3SRobert Watson 120530d239bcSRobert Watson COUNTER_DECL(pipe_check_stat); 1206d8a7b7a3SRobert Watson static int 12073f1a7a90SRobert Watson test_pipe_check_stat(struct ucred *cred, struct pipepair *pp, 1208f0336833SRobert Watson struct label *pplabel) 1209c024c3eeSRobert Watson { 1210c024c3eeSRobert Watson 12116827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1212f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 121330d239bcSRobert Watson COUNTER_INC(pipe_check_stat); 1214250ee706SRobert Watson 1215c024c3eeSRobert Watson return (0); 1216c024c3eeSRobert Watson } 1217c024c3eeSRobert Watson 121830d239bcSRobert Watson COUNTER_DECL(pipe_check_write); 1219c024c3eeSRobert Watson static int 12203f1a7a90SRobert Watson test_pipe_check_write(struct ucred *cred, struct pipepair *pp, 1221f0336833SRobert Watson struct label *pplabel) 1222c024c3eeSRobert Watson { 1223c024c3eeSRobert Watson 12246827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1225f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 122630d239bcSRobert Watson COUNTER_INC(pipe_check_write); 1227250ee706SRobert Watson 1228c024c3eeSRobert Watson return (0); 1229c024c3eeSRobert Watson } 1230c024c3eeSRobert Watson 1231eb320b0eSRobert Watson COUNTER_DECL(pipe_copy_label); 1232eb320b0eSRobert Watson static void 1233eb320b0eSRobert Watson test_pipe_copy_label(struct label *src, struct label *dest) 1234eb320b0eSRobert Watson { 1235eb320b0eSRobert Watson 1236eb320b0eSRobert Watson LABEL_CHECK(src, MAGIC_PIPE); 1237eb320b0eSRobert Watson LABEL_CHECK(dest, MAGIC_PIPE); 1238eb320b0eSRobert Watson COUNTER_INC(pipe_copy_label); 1239eb320b0eSRobert Watson } 1240eb320b0eSRobert Watson 1241eb320b0eSRobert Watson COUNTER_DECL(pipe_create); 1242eb320b0eSRobert Watson static void 1243eb320b0eSRobert Watson test_pipe_create(struct ucred *cred, struct pipepair *pp, 1244f0336833SRobert Watson struct label *pplabel) 1245eb320b0eSRobert Watson { 1246eb320b0eSRobert Watson 1247eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1248f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 1249eb320b0eSRobert Watson COUNTER_INC(pipe_create); 1250eb320b0eSRobert Watson } 1251eb320b0eSRobert Watson 1252eb320b0eSRobert Watson COUNTER_DECL(pipe_destroy_label); 1253eb320b0eSRobert Watson static void 1254eb320b0eSRobert Watson test_pipe_destroy_label(struct label *label) 1255eb320b0eSRobert Watson { 1256eb320b0eSRobert Watson 1257eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_PIPE); 1258eb320b0eSRobert Watson COUNTER_INC(pipe_destroy_label); 1259eb320b0eSRobert Watson } 1260eb320b0eSRobert Watson 1261eb320b0eSRobert Watson COUNTER_DECL(pipe_externalize_label); 1262eb320b0eSRobert Watson static int 1263eb320b0eSRobert Watson test_pipe_externalize_label(struct label *label, char *element_name, 1264eb320b0eSRobert Watson struct sbuf *sb, int *claimed) 1265eb320b0eSRobert Watson { 1266eb320b0eSRobert Watson 1267eb320b0eSRobert Watson LABEL_CHECK(label, MAGIC_PIPE); 1268eb320b0eSRobert Watson COUNTER_INC(pipe_externalize_label); 1269eb320b0eSRobert Watson 1270eb320b0eSRobert Watson return (0); 1271eb320b0eSRobert Watson } 1272eb320b0eSRobert Watson 1273eb320b0eSRobert Watson COUNTER_DECL(pipe_init_label); 1274eb320b0eSRobert Watson static void 1275eb320b0eSRobert Watson test_pipe_init_label(struct label *label) 1276eb320b0eSRobert Watson { 1277eb320b0eSRobert Watson 1278eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_PIPE); 1279eb320b0eSRobert Watson COUNTER_INC(pipe_init_label); 1280eb320b0eSRobert Watson } 1281eb320b0eSRobert Watson 12821876fb21SRobert Watson COUNTER_DECL(pipe_internalize_label); 12831876fb21SRobert Watson static int 12841876fb21SRobert Watson test_pipe_internalize_label(struct label *label, char *element_name, 12851876fb21SRobert Watson char *element_data, int *claimed) 12861876fb21SRobert Watson { 12871876fb21SRobert Watson 12881876fb21SRobert Watson LABEL_CHECK(label, MAGIC_PIPE); 12891876fb21SRobert Watson COUNTER_INC(pipe_internalize_label); 12901876fb21SRobert Watson 12911876fb21SRobert Watson return (0); 12921876fb21SRobert Watson } 12931876fb21SRobert Watson 1294eb320b0eSRobert Watson COUNTER_DECL(pipe_relabel); 1295eb320b0eSRobert Watson static void 1296eb320b0eSRobert Watson test_pipe_relabel(struct ucred *cred, struct pipepair *pp, 1297f0336833SRobert Watson struct label *pplabel, struct label *newlabel) 1298eb320b0eSRobert Watson { 1299eb320b0eSRobert Watson 1300eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1301f0336833SRobert Watson LABEL_CHECK(pplabel, MAGIC_PIPE); 1302eb320b0eSRobert Watson LABEL_CHECK(newlabel, MAGIC_PIPE); 1303eb320b0eSRobert Watson COUNTER_INC(pipe_relabel); 1304eb320b0eSRobert Watson } 1305eb320b0eSRobert Watson 1306438aeadfSRobert Watson COUNTER_DECL(posixsem_check_getvalue); 1307438aeadfSRobert Watson static int 13086bc1e9cdSJohn Baldwin test_posixsem_check_getvalue(struct ucred *active_cred, struct ucred *file_cred, 13096bc1e9cdSJohn Baldwin struct ksem *ks, struct label *kslabel) 1310438aeadfSRobert Watson { 1311438aeadfSRobert Watson 13126bc1e9cdSJohn Baldwin LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 13136bc1e9cdSJohn Baldwin LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1314438aeadfSRobert Watson LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1315438aeadfSRobert Watson COUNTER_INC(posixsem_check_getvalue); 1316438aeadfSRobert Watson 1317438aeadfSRobert Watson return (0); 1318438aeadfSRobert Watson } 1319438aeadfSRobert Watson 1320438aeadfSRobert Watson COUNTER_DECL(posixsem_check_open); 1321438aeadfSRobert Watson static int 1322438aeadfSRobert Watson test_posixsem_check_open(struct ucred *cred, struct ksem *ks, 1323438aeadfSRobert Watson struct label *kslabel) 1324438aeadfSRobert Watson { 1325438aeadfSRobert Watson 1326438aeadfSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1327438aeadfSRobert Watson LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1328438aeadfSRobert Watson COUNTER_INC(posixsem_check_open); 1329438aeadfSRobert Watson 1330438aeadfSRobert Watson return (0); 1331438aeadfSRobert Watson } 1332438aeadfSRobert Watson 1333438aeadfSRobert Watson COUNTER_DECL(posixsem_check_post); 1334438aeadfSRobert Watson static int 13356bc1e9cdSJohn Baldwin test_posixsem_check_post(struct ucred *active_cred, struct ucred *file_cred, 13366bc1e9cdSJohn Baldwin struct ksem *ks, struct label *kslabel) 1337438aeadfSRobert Watson { 1338438aeadfSRobert Watson 13396bc1e9cdSJohn Baldwin LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 13406bc1e9cdSJohn Baldwin LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1341438aeadfSRobert Watson LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1342438aeadfSRobert Watson COUNTER_INC(posixsem_check_post); 1343438aeadfSRobert Watson 1344438aeadfSRobert Watson return (0); 1345438aeadfSRobert Watson } 1346438aeadfSRobert Watson 13479c00bb91SKonstantin Belousov COUNTER_DECL(posixsem_check_setmode); 13489c00bb91SKonstantin Belousov static int 13499c00bb91SKonstantin Belousov test_posixsem_check_setmode(struct ucred *cred, struct ksem *ks, 13509c00bb91SKonstantin Belousov struct label *kslabel, mode_t mode) 13519c00bb91SKonstantin Belousov { 13529c00bb91SKonstantin Belousov 13539c00bb91SKonstantin Belousov LABEL_CHECK(cred->cr_label, MAGIC_CRED); 13549c00bb91SKonstantin Belousov LABEL_CHECK(kslabel, MAGIC_POSIX_SHM); 13559c00bb91SKonstantin Belousov COUNTER_INC(posixsem_check_setmode); 13569c00bb91SKonstantin Belousov return (0); 13579c00bb91SKonstantin Belousov } 13589c00bb91SKonstantin Belousov 13599c00bb91SKonstantin Belousov COUNTER_DECL(posixsem_check_setowner); 13609c00bb91SKonstantin Belousov static int 13619c00bb91SKonstantin Belousov test_posixsem_check_setowner(struct ucred *cred, struct ksem *ks, 13629c00bb91SKonstantin Belousov struct label *kslabel, uid_t uid, gid_t gid) 13639c00bb91SKonstantin Belousov { 13649c00bb91SKonstantin Belousov 13659c00bb91SKonstantin Belousov LABEL_CHECK(cred->cr_label, MAGIC_CRED); 13669c00bb91SKonstantin Belousov LABEL_CHECK(kslabel, MAGIC_POSIX_SHM); 13679c00bb91SKonstantin Belousov COUNTER_INC(posixsem_check_setowner); 13689c00bb91SKonstantin Belousov return (0); 13699c00bb91SKonstantin Belousov } 13709c00bb91SKonstantin Belousov 13716bc1e9cdSJohn Baldwin COUNTER_DECL(posixsem_check_stat); 13726bc1e9cdSJohn Baldwin static int 13736bc1e9cdSJohn Baldwin test_posixsem_check_stat(struct ucred *active_cred, 13746bc1e9cdSJohn Baldwin struct ucred *file_cred, struct ksem *ks, struct label *kslabel) 13756bc1e9cdSJohn Baldwin { 13766bc1e9cdSJohn Baldwin 13776bc1e9cdSJohn Baldwin LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 13786bc1e9cdSJohn Baldwin LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 13796bc1e9cdSJohn Baldwin LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 13806bc1e9cdSJohn Baldwin COUNTER_INC(posixsem_check_stat); 13816bc1e9cdSJohn Baldwin return (0); 13826bc1e9cdSJohn Baldwin } 13836bc1e9cdSJohn Baldwin 1384438aeadfSRobert Watson COUNTER_DECL(posixsem_check_unlink); 1385438aeadfSRobert Watson static int 1386438aeadfSRobert Watson test_posixsem_check_unlink(struct ucred *cred, struct ksem *ks, 1387438aeadfSRobert Watson struct label *kslabel) 1388438aeadfSRobert Watson { 1389438aeadfSRobert Watson 1390438aeadfSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1391438aeadfSRobert Watson LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1392438aeadfSRobert Watson COUNTER_INC(posixsem_check_unlink); 1393438aeadfSRobert Watson 1394438aeadfSRobert Watson return (0); 1395438aeadfSRobert Watson } 1396438aeadfSRobert Watson 1397438aeadfSRobert Watson COUNTER_DECL(posixsem_check_wait); 1398438aeadfSRobert Watson static int 13996bc1e9cdSJohn Baldwin test_posixsem_check_wait(struct ucred *active_cred, struct ucred *file_cred, 14006bc1e9cdSJohn Baldwin struct ksem *ks, struct label *kslabel) 1401438aeadfSRobert Watson { 1402438aeadfSRobert Watson 14036bc1e9cdSJohn Baldwin LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 14046bc1e9cdSJohn Baldwin LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1405438aeadfSRobert Watson LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1406438aeadfSRobert Watson COUNTER_INC(posixsem_check_wait); 140752648411SRobert Watson 140852648411SRobert Watson return (0); 140952648411SRobert Watson } 141052648411SRobert Watson 1411eb320b0eSRobert Watson COUNTER_DECL(posixsem_create); 1412eb320b0eSRobert Watson static void 1413eb320b0eSRobert Watson test_posixsem_create(struct ucred *cred, struct ksem *ks, 1414eb320b0eSRobert Watson struct label *kslabel) 1415eb320b0eSRobert Watson { 1416eb320b0eSRobert Watson 1417eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1418eb320b0eSRobert Watson LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1419eb320b0eSRobert Watson COUNTER_INC(posixsem_create); 1420eb320b0eSRobert Watson } 1421eb320b0eSRobert Watson 1422eb320b0eSRobert Watson COUNTER_DECL(posixsem_destroy_label); 1423eb320b0eSRobert Watson static void 1424eb320b0eSRobert Watson test_posixsem_destroy_label(struct label *label) 1425eb320b0eSRobert Watson { 1426eb320b0eSRobert Watson 1427eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_POSIX_SEM); 1428eb320b0eSRobert Watson COUNTER_INC(posixsem_destroy_label); 1429eb320b0eSRobert Watson } 1430eb320b0eSRobert Watson 1431eb320b0eSRobert Watson COUNTER_DECL(posixsem_init_label); 1432eb320b0eSRobert Watson static void 1433eb320b0eSRobert Watson test_posixsem_init_label(struct label *label) 1434eb320b0eSRobert Watson { 1435eb320b0eSRobert Watson 1436eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_POSIX_SEM); 1437eb320b0eSRobert Watson COUNTER_INC(posixsem_init_label); 1438eb320b0eSRobert Watson } 1439eb320b0eSRobert Watson 14409b6dd12eSRobert Watson COUNTER_DECL(posixshm_check_create); 14419b6dd12eSRobert Watson static int 14429b6dd12eSRobert Watson test_posixshm_check_create(struct ucred *cred, const char *path) 14439b6dd12eSRobert Watson { 14449b6dd12eSRobert Watson 14459b6dd12eSRobert Watson COUNTER_INC(posixshm_check_create); 14469b6dd12eSRobert Watson return (0); 14479b6dd12eSRobert Watson } 14489b6dd12eSRobert Watson 14498e38aeffSJohn Baldwin COUNTER_DECL(posixshm_check_mmap); 14508e38aeffSJohn Baldwin static int 14518e38aeffSJohn Baldwin test_posixshm_check_mmap(struct ucred *cred, struct shmfd *shmfd, 14528e38aeffSJohn Baldwin struct label *shmfdlabel, int prot, int flags) 14538e38aeffSJohn Baldwin { 14548e38aeffSJohn Baldwin 14558e38aeffSJohn Baldwin LABEL_CHECK(cred->cr_label, MAGIC_CRED); 14568e38aeffSJohn Baldwin LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1457127cc767SJohn Baldwin COUNTER_INC(posixshm_check_mmap); 14588e38aeffSJohn Baldwin return (0); 14598e38aeffSJohn Baldwin } 14608e38aeffSJohn Baldwin 14618e38aeffSJohn Baldwin COUNTER_DECL(posixshm_check_open); 14628e38aeffSJohn Baldwin static int 14638e38aeffSJohn Baldwin test_posixshm_check_open(struct ucred *cred, struct shmfd *shmfd, 14649b6dd12eSRobert Watson struct label *shmfdlabel, accmode_t accmode) 14658e38aeffSJohn Baldwin { 14668e38aeffSJohn Baldwin 14678e38aeffSJohn Baldwin LABEL_CHECK(cred->cr_label, MAGIC_CRED); 14688e38aeffSJohn Baldwin LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1469127cc767SJohn Baldwin COUNTER_INC(posixshm_check_open); 14708e38aeffSJohn Baldwin return (0); 14718e38aeffSJohn Baldwin } 14728e38aeffSJohn Baldwin 1473940cb0e2SKonstantin Belousov COUNTER_DECL(posixshm_check_read); 1474940cb0e2SKonstantin Belousov static int 1475940cb0e2SKonstantin Belousov test_posixshm_check_read(struct ucred *active_cred, 1476940cb0e2SKonstantin Belousov struct ucred *file_cred, struct shmfd *shm, struct label *shmlabel) 1477940cb0e2SKonstantin Belousov { 1478940cb0e2SKonstantin Belousov 1479940cb0e2SKonstantin Belousov LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1480940cb0e2SKonstantin Belousov if (file_cred != NULL) 1481940cb0e2SKonstantin Belousov LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1482940cb0e2SKonstantin Belousov LABEL_CHECK(shmlabel, MAGIC_POSIX_SHM); 1483940cb0e2SKonstantin Belousov COUNTER_INC(posixshm_check_read); 1484940cb0e2SKonstantin Belousov 1485940cb0e2SKonstantin Belousov return (0); 1486940cb0e2SKonstantin Belousov } 1487940cb0e2SKonstantin Belousov 14889c00bb91SKonstantin Belousov COUNTER_DECL(posixshm_check_setmode); 14899c00bb91SKonstantin Belousov static int 14909c00bb91SKonstantin Belousov test_posixshm_check_setmode(struct ucred *cred, struct shmfd *shmfd, 14919c00bb91SKonstantin Belousov struct label *shmfdlabel, mode_t mode) 14929c00bb91SKonstantin Belousov { 14939c00bb91SKonstantin Belousov 14949c00bb91SKonstantin Belousov LABEL_CHECK(cred->cr_label, MAGIC_CRED); 14959c00bb91SKonstantin Belousov LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 14969c00bb91SKonstantin Belousov COUNTER_INC(posixshm_check_setmode); 14979c00bb91SKonstantin Belousov return (0); 14989c00bb91SKonstantin Belousov } 14999c00bb91SKonstantin Belousov 15009c00bb91SKonstantin Belousov COUNTER_DECL(posixshm_check_setowner); 15019c00bb91SKonstantin Belousov static int 15029c00bb91SKonstantin Belousov test_posixshm_check_setowner(struct ucred *cred, struct shmfd *shmfd, 15039c00bb91SKonstantin Belousov struct label *shmfdlabel, uid_t uid, gid_t gid) 15049c00bb91SKonstantin Belousov { 15059c00bb91SKonstantin Belousov 15069c00bb91SKonstantin Belousov LABEL_CHECK(cred->cr_label, MAGIC_CRED); 15079c00bb91SKonstantin Belousov LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 15089c00bb91SKonstantin Belousov COUNTER_INC(posixshm_check_setowner); 15099c00bb91SKonstantin Belousov return (0); 15109c00bb91SKonstantin Belousov } 15119c00bb91SKonstantin Belousov 15128e38aeffSJohn Baldwin COUNTER_DECL(posixshm_check_stat); 15138e38aeffSJohn Baldwin static int 15148e38aeffSJohn Baldwin test_posixshm_check_stat(struct ucred *active_cred, 15158e38aeffSJohn Baldwin struct ucred *file_cred, struct shmfd *shmfd, struct label *shmfdlabel) 15168e38aeffSJohn Baldwin { 15178e38aeffSJohn Baldwin 15188e38aeffSJohn Baldwin LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 15198e38aeffSJohn Baldwin LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 15208e38aeffSJohn Baldwin LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1521127cc767SJohn Baldwin COUNTER_INC(posixshm_check_stat); 15228e38aeffSJohn Baldwin return (0); 15238e38aeffSJohn Baldwin } 15248e38aeffSJohn Baldwin 15258e38aeffSJohn Baldwin COUNTER_DECL(posixshm_check_truncate); 15268e38aeffSJohn Baldwin static int 15278e38aeffSJohn Baldwin test_posixshm_check_truncate(struct ucred *active_cred, 15288e38aeffSJohn Baldwin struct ucred *file_cred, struct shmfd *shmfd, struct label *shmfdlabel) 15298e38aeffSJohn Baldwin { 15308e38aeffSJohn Baldwin 15318e38aeffSJohn Baldwin LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 15328e38aeffSJohn Baldwin LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 15338e38aeffSJohn Baldwin LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1534127cc767SJohn Baldwin COUNTER_INC(posixshm_check_truncate); 15358e38aeffSJohn Baldwin return (0); 15368e38aeffSJohn Baldwin } 15378e38aeffSJohn Baldwin 15388e38aeffSJohn Baldwin COUNTER_DECL(posixshm_check_unlink); 15398e38aeffSJohn Baldwin static int 15408e38aeffSJohn Baldwin test_posixshm_check_unlink(struct ucred *cred, struct shmfd *shmfd, 15418e38aeffSJohn Baldwin struct label *shmfdlabel) 15428e38aeffSJohn Baldwin { 15438e38aeffSJohn Baldwin 15448e38aeffSJohn Baldwin LABEL_CHECK(cred->cr_label, MAGIC_CRED); 15458e38aeffSJohn Baldwin LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1546127cc767SJohn Baldwin COUNTER_INC(posixshm_check_unlink); 15478e38aeffSJohn Baldwin return (0); 15488e38aeffSJohn Baldwin } 15498e38aeffSJohn Baldwin 1550940cb0e2SKonstantin Belousov COUNTER_DECL(posixshm_check_write); 1551940cb0e2SKonstantin Belousov static int 1552940cb0e2SKonstantin Belousov test_posixshm_check_write(struct ucred *active_cred, 1553940cb0e2SKonstantin Belousov struct ucred *file_cred, struct shmfd *shm, struct label *shmlabel) 1554940cb0e2SKonstantin Belousov { 1555940cb0e2SKonstantin Belousov 1556940cb0e2SKonstantin Belousov LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1557940cb0e2SKonstantin Belousov if (file_cred != NULL) 1558940cb0e2SKonstantin Belousov LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1559940cb0e2SKonstantin Belousov LABEL_CHECK(shmlabel, MAGIC_POSIX_SHM); 1560940cb0e2SKonstantin Belousov COUNTER_INC(posixshm_check_write); 1561940cb0e2SKonstantin Belousov 1562940cb0e2SKonstantin Belousov return (0); 1563940cb0e2SKonstantin Belousov } 1564940cb0e2SKonstantin Belousov 15658e38aeffSJohn Baldwin COUNTER_DECL(posixshm_create); 15668e38aeffSJohn Baldwin static void 15678e38aeffSJohn Baldwin test_posixshm_create(struct ucred *cred, struct shmfd *shmfd, 15688e38aeffSJohn Baldwin struct label *shmfdlabel) 15698e38aeffSJohn Baldwin { 15708e38aeffSJohn Baldwin 15718e38aeffSJohn Baldwin LABEL_CHECK(cred->cr_label, MAGIC_CRED); 15728e38aeffSJohn Baldwin LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 15738e38aeffSJohn Baldwin COUNTER_INC(posixshm_create); 15748e38aeffSJohn Baldwin } 15758e38aeffSJohn Baldwin 15768e38aeffSJohn Baldwin COUNTER_DECL(posixshm_destroy_label); 15778e38aeffSJohn Baldwin static void 15788e38aeffSJohn Baldwin test_posixshm_destroy_label(struct label *label) 15798e38aeffSJohn Baldwin { 15808e38aeffSJohn Baldwin 15818e38aeffSJohn Baldwin LABEL_DESTROY(label, MAGIC_POSIX_SHM); 15828e38aeffSJohn Baldwin COUNTER_INC(posixshm_destroy_label); 15838e38aeffSJohn Baldwin } 15848e38aeffSJohn Baldwin 15858e38aeffSJohn Baldwin COUNTER_DECL(posixshm_init_label); 15868e38aeffSJohn Baldwin static void 15878e38aeffSJohn Baldwin test_posixshm_init_label(struct label *label) 15888e38aeffSJohn Baldwin { 15898e38aeffSJohn Baldwin 15908e38aeffSJohn Baldwin LABEL_INIT(label, MAGIC_POSIX_SHM); 15918e38aeffSJohn Baldwin COUNTER_INC(posixshm_init_label); 15928e38aeffSJohn Baldwin } 15938e38aeffSJohn Baldwin 159430d239bcSRobert Watson COUNTER_DECL(proc_check_debug); 159552648411SRobert Watson static int 15963f1a7a90SRobert Watson test_proc_check_debug(struct ucred *cred, struct proc *p) 1597d8a7b7a3SRobert Watson { 1598d8a7b7a3SRobert Watson 15996827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 160078007886SRobert Watson LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 160130d239bcSRobert Watson COUNTER_INC(proc_check_debug); 1602250ee706SRobert Watson 1603d8a7b7a3SRobert Watson return (0); 1604d8a7b7a3SRobert Watson } 1605d8a7b7a3SRobert Watson 160630d239bcSRobert Watson COUNTER_DECL(proc_check_sched); 1607d8a7b7a3SRobert Watson static int 16083f1a7a90SRobert Watson test_proc_check_sched(struct ucred *cred, struct proc *p) 1609d8a7b7a3SRobert Watson { 1610d8a7b7a3SRobert Watson 16116827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 161278007886SRobert Watson LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 161330d239bcSRobert Watson COUNTER_INC(proc_check_sched); 1614250ee706SRobert Watson 1615d8a7b7a3SRobert Watson return (0); 1616d8a7b7a3SRobert Watson } 1617d8a7b7a3SRobert Watson 161830d239bcSRobert Watson COUNTER_DECL(proc_check_signal); 1619d8a7b7a3SRobert Watson static int 16203f1a7a90SRobert Watson test_proc_check_signal(struct ucred *cred, struct proc *p, int signum) 1621d8a7b7a3SRobert Watson { 1622d8a7b7a3SRobert Watson 16236827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 162478007886SRobert Watson LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 162530d239bcSRobert Watson COUNTER_INC(proc_check_signal); 1626250ee706SRobert Watson 1627d8a7b7a3SRobert Watson return (0); 1628d8a7b7a3SRobert Watson } 1629d8a7b7a3SRobert Watson 163030d239bcSRobert Watson COUNTER_DECL(proc_check_wait); 1631030a28b3SRobert Watson static int 16323f1a7a90SRobert Watson test_proc_check_wait(struct ucred *cred, struct proc *p) 1633babe9a2bSRobert Watson { 1634babe9a2bSRobert Watson 16356827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 163678007886SRobert Watson LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 163730d239bcSRobert Watson COUNTER_INC(proc_check_wait); 1638babe9a2bSRobert Watson 1639babe9a2bSRobert Watson return (0); 1640babe9a2bSRobert Watson } 1641babe9a2bSRobert Watson 1642eb320b0eSRobert Watson COUNTER_DECL(proc_destroy_label); 1643eb320b0eSRobert Watson static void 1644eb320b0eSRobert Watson test_proc_destroy_label(struct label *label) 1645eb320b0eSRobert Watson { 1646eb320b0eSRobert Watson 1647eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_PROC); 1648eb320b0eSRobert Watson COUNTER_INC(proc_destroy_label); 1649eb320b0eSRobert Watson } 1650eb320b0eSRobert Watson 1651eb320b0eSRobert Watson COUNTER_DECL(proc_init_label); 1652eb320b0eSRobert Watson static void 1653eb320b0eSRobert Watson test_proc_init_label(struct label *label) 1654eb320b0eSRobert Watson { 1655eb320b0eSRobert Watson 1656eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_PROC); 1657eb320b0eSRobert Watson COUNTER_INC(proc_init_label); 1658eb320b0eSRobert Watson } 1659eb320b0eSRobert Watson 166030d239bcSRobert Watson COUNTER_DECL(socket_check_accept); 1661babe9a2bSRobert Watson static int 16623f1a7a90SRobert Watson test_socket_check_accept(struct ucred *cred, struct socket *so, 166378007886SRobert Watson struct label *solabel) 16647f53207bSRobert Watson { 16657f53207bSRobert Watson 16666827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 16673de40469SRobert Watson SOCK_LOCK(so); 166878007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 16693de40469SRobert Watson SOCK_UNLOCK(so); 167030d239bcSRobert Watson COUNTER_INC(socket_check_accept); 16717f53207bSRobert Watson 16727f53207bSRobert Watson return (0); 16737f53207bSRobert Watson } 16747f53207bSRobert Watson 167530d239bcSRobert Watson COUNTER_DECL(socket_check_bind); 16767f53207bSRobert Watson static int 16773f1a7a90SRobert Watson test_socket_check_bind(struct ucred *cred, struct socket *so, 167878007886SRobert Watson struct label *solabel, struct sockaddr *sa) 1679d8a7b7a3SRobert Watson { 1680d8a7b7a3SRobert Watson 16816827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 16823de40469SRobert Watson SOCK_LOCK(so); 168378007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 16843de40469SRobert Watson SOCK_UNLOCK(so); 168530d239bcSRobert Watson COUNTER_INC(socket_check_bind); 1686250ee706SRobert Watson 1687d8a7b7a3SRobert Watson return (0); 1688d8a7b7a3SRobert Watson } 1689d8a7b7a3SRobert Watson 169030d239bcSRobert Watson COUNTER_DECL(socket_check_connect); 1691d8a7b7a3SRobert Watson static int 16923f1a7a90SRobert Watson test_socket_check_connect(struct ucred *cred, struct socket *so, 169378007886SRobert Watson struct label *solabel, struct sockaddr *sa) 1694d8a7b7a3SRobert Watson { 1695d8a7b7a3SRobert Watson 16966827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 16973de40469SRobert Watson SOCK_LOCK(so); 169878007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 16993de40469SRobert Watson SOCK_UNLOCK(so); 170030d239bcSRobert Watson COUNTER_INC(socket_check_connect); 1701250ee706SRobert Watson 1702d8a7b7a3SRobert Watson return (0); 1703d8a7b7a3SRobert Watson } 1704d8a7b7a3SRobert Watson 170530d239bcSRobert Watson COUNTER_DECL(socket_check_deliver); 1706d8a7b7a3SRobert Watson static int 17073f1a7a90SRobert Watson test_socket_check_deliver(struct socket *so, struct label *solabel, 170878007886SRobert Watson struct mbuf *m, struct label *mlabel) 1709d8a7b7a3SRobert Watson { 1710d8a7b7a3SRobert Watson 17113de40469SRobert Watson SOCK_LOCK(so); 171278007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 17133de40469SRobert Watson SOCK_UNLOCK(so); 171478007886SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 171530d239bcSRobert Watson COUNTER_INC(socket_check_deliver); 1716250ee706SRobert Watson 1717d8a7b7a3SRobert Watson return (0); 1718d8a7b7a3SRobert Watson } 1719d8a7b7a3SRobert Watson 172030d239bcSRobert Watson COUNTER_DECL(socket_check_listen); 1721d8a7b7a3SRobert Watson static int 17223f1a7a90SRobert Watson test_socket_check_listen(struct ucred *cred, struct socket *so, 172378007886SRobert Watson struct label *solabel) 1724d8a7b7a3SRobert Watson { 1725d8a7b7a3SRobert Watson 17266827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 17273de40469SRobert Watson SOCK_LOCK(so); 172878007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 17293de40469SRobert Watson SOCK_UNLOCK(so); 173030d239bcSRobert Watson COUNTER_INC(socket_check_listen); 1731250ee706SRobert Watson 1732d8a7b7a3SRobert Watson return (0); 1733d8a7b7a3SRobert Watson } 1734d8a7b7a3SRobert Watson 173530d239bcSRobert Watson COUNTER_DECL(socket_check_poll); 1736d8a7b7a3SRobert Watson static int 17373f1a7a90SRobert Watson test_socket_check_poll(struct ucred *cred, struct socket *so, 173878007886SRobert Watson struct label *solabel) 17397f53207bSRobert Watson { 17407f53207bSRobert Watson 17416827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 17423de40469SRobert Watson SOCK_LOCK(so); 174378007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 17443de40469SRobert Watson SOCK_UNLOCK(so); 174530d239bcSRobert Watson COUNTER_INC(socket_check_poll); 17467f53207bSRobert Watson 17477f53207bSRobert Watson return (0); 17487f53207bSRobert Watson } 17497f53207bSRobert Watson 175030d239bcSRobert Watson COUNTER_DECL(socket_check_receive); 17517f53207bSRobert Watson static int 17523f1a7a90SRobert Watson test_socket_check_receive(struct ucred *cred, struct socket *so, 175378007886SRobert Watson struct label *solabel) 1754d8a7b7a3SRobert Watson { 1755d8a7b7a3SRobert Watson 17566827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 17573de40469SRobert Watson SOCK_LOCK(so); 175878007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 17593de40469SRobert Watson SOCK_UNLOCK(so); 176030d239bcSRobert Watson COUNTER_INC(socket_check_receive); 1761250ee706SRobert Watson 1762d8a7b7a3SRobert Watson return (0); 1763d8a7b7a3SRobert Watson } 1764d8a7b7a3SRobert Watson 176530d239bcSRobert Watson COUNTER_DECL(socket_check_relabel); 1766d8a7b7a3SRobert Watson static int 17673f1a7a90SRobert Watson test_socket_check_relabel(struct ucred *cred, struct socket *so, 176878007886SRobert Watson struct label *solabel, struct label *newlabel) 1769d8a7b7a3SRobert Watson { 1770d8a7b7a3SRobert Watson 17713de40469SRobert Watson SOCK_LOCK_ASSERT(so); 17723de40469SRobert Watson 17736827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 177478007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 17756827d029SRobert Watson LABEL_CHECK(newlabel, MAGIC_SOCKET); 177630d239bcSRobert Watson COUNTER_INC(socket_check_relabel); 1777250ee706SRobert Watson 1778d8a7b7a3SRobert Watson return (0); 1779d8a7b7a3SRobert Watson } 1780d8a7b7a3SRobert Watson 178130d239bcSRobert Watson COUNTER_DECL(socket_check_send); 1782d8a7b7a3SRobert Watson static int 17833f1a7a90SRobert Watson test_socket_check_send(struct ucred *cred, struct socket *so, 178478007886SRobert Watson struct label *solabel) 17857f53207bSRobert Watson { 17867f53207bSRobert Watson 17876827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 17883de40469SRobert Watson SOCK_LOCK(so); 178978007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 17903de40469SRobert Watson SOCK_UNLOCK(so); 179130d239bcSRobert Watson COUNTER_INC(socket_check_send); 17927f53207bSRobert Watson 17937f53207bSRobert Watson return (0); 17947f53207bSRobert Watson } 17957f53207bSRobert Watson 179630d239bcSRobert Watson COUNTER_DECL(socket_check_stat); 17977f53207bSRobert Watson static int 17983f1a7a90SRobert Watson test_socket_check_stat(struct ucred *cred, struct socket *so, 179978007886SRobert Watson struct label *solabel) 18007f53207bSRobert Watson { 18017f53207bSRobert Watson 18026827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 18033de40469SRobert Watson SOCK_LOCK(so); 180478007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 18053de40469SRobert Watson SOCK_UNLOCK(so); 180630d239bcSRobert Watson COUNTER_INC(socket_check_stat); 18077f53207bSRobert Watson 18087f53207bSRobert Watson return (0); 18097f53207bSRobert Watson } 18107f53207bSRobert Watson 181130d239bcSRobert Watson COUNTER_DECL(socket_check_visible); 18127f53207bSRobert Watson static int 18133f1a7a90SRobert Watson test_socket_check_visible(struct ucred *cred, struct socket *so, 181478007886SRobert Watson struct label *solabel) 18157f53207bSRobert Watson { 18167f53207bSRobert Watson 18176827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 18183de40469SRobert Watson SOCK_LOCK(so); 181978007886SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 18203de40469SRobert Watson SOCK_UNLOCK(so); 182130d239bcSRobert Watson COUNTER_INC(socket_check_visible); 18227f53207bSRobert Watson 18237f53207bSRobert Watson return (0); 18247f53207bSRobert Watson } 18257f53207bSRobert Watson 1826eb320b0eSRobert Watson COUNTER_DECL(socket_copy_label); 1827eb320b0eSRobert Watson static void 1828eb320b0eSRobert Watson test_socket_copy_label(struct label *src, struct label *dest) 1829eb320b0eSRobert Watson { 1830eb320b0eSRobert Watson 1831eb320b0eSRobert Watson LABEL_CHECK(src, MAGIC_SOCKET); 1832eb320b0eSRobert Watson LABEL_CHECK(dest, MAGIC_SOCKET); 1833eb320b0eSRobert Watson COUNTER_INC(socket_copy_label); 1834eb320b0eSRobert Watson } 1835eb320b0eSRobert Watson 1836eb320b0eSRobert Watson COUNTER_DECL(socket_create); 1837eb320b0eSRobert Watson static void 1838f0336833SRobert Watson test_socket_create(struct ucred *cred, struct socket *so, 1839f0336833SRobert Watson struct label *solabel) 1840eb320b0eSRobert Watson { 1841eb320b0eSRobert Watson 1842eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1843f0336833SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 1844eb320b0eSRobert Watson COUNTER_INC(socket_create); 1845eb320b0eSRobert Watson } 1846eb320b0eSRobert Watson 1847eb320b0eSRobert Watson COUNTER_DECL(socket_create_mbuf); 1848eb320b0eSRobert Watson static void 18493de40469SRobert Watson test_socket_create_mbuf(struct socket *so, struct label *solabel, 1850f0336833SRobert Watson struct mbuf *m, struct label *mlabel) 1851eb320b0eSRobert Watson { 1852eb320b0eSRobert Watson 18533de40469SRobert Watson SOCK_LOCK(so); 18543de40469SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 18553de40469SRobert Watson SOCK_UNLOCK(so); 1856f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 1857eb320b0eSRobert Watson COUNTER_INC(socket_create_mbuf); 1858eb320b0eSRobert Watson } 1859eb320b0eSRobert Watson 1860eb320b0eSRobert Watson COUNTER_DECL(socket_destroy_label); 1861eb320b0eSRobert Watson static void 1862eb320b0eSRobert Watson test_socket_destroy_label(struct label *label) 1863eb320b0eSRobert Watson { 1864eb320b0eSRobert Watson 1865eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_SOCKET); 1866eb320b0eSRobert Watson COUNTER_INC(socket_destroy_label); 1867eb320b0eSRobert Watson } 1868eb320b0eSRobert Watson 1869eb320b0eSRobert Watson COUNTER_DECL(socket_externalize_label); 1870eb320b0eSRobert Watson static int 1871eb320b0eSRobert Watson test_socket_externalize_label(struct label *label, char *element_name, 1872eb320b0eSRobert Watson struct sbuf *sb, int *claimed) 1873eb320b0eSRobert Watson { 1874eb320b0eSRobert Watson 1875eb320b0eSRobert Watson LABEL_CHECK(label, MAGIC_SOCKET); 1876eb320b0eSRobert Watson COUNTER_INC(socket_externalize_label); 1877eb320b0eSRobert Watson 1878eb320b0eSRobert Watson return (0); 1879eb320b0eSRobert Watson } 1880eb320b0eSRobert Watson 1881eb320b0eSRobert Watson COUNTER_DECL(socket_init_label); 1882eb320b0eSRobert Watson static int 1883eb320b0eSRobert Watson test_socket_init_label(struct label *label, int flag) 1884eb320b0eSRobert Watson { 1885eb320b0eSRobert Watson 1886eb320b0eSRobert Watson if (flag & M_WAITOK) 1887eb320b0eSRobert Watson WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 1888eb320b0eSRobert Watson "test_socket_init_label() at %s:%d", __FILE__, 1889eb320b0eSRobert Watson __LINE__); 1890eb320b0eSRobert Watson 1891eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_SOCKET); 1892eb320b0eSRobert Watson COUNTER_INC(socket_init_label); 1893eb320b0eSRobert Watson return (0); 1894eb320b0eSRobert Watson } 1895eb320b0eSRobert Watson 18961876fb21SRobert Watson COUNTER_DECL(socket_internalize_label); 18971876fb21SRobert Watson static int 18981876fb21SRobert Watson test_socket_internalize_label(struct label *label, char *element_name, 18991876fb21SRobert Watson char *element_data, int *claimed) 19001876fb21SRobert Watson { 19011876fb21SRobert Watson 19021876fb21SRobert Watson LABEL_CHECK(label, MAGIC_SOCKET); 19031876fb21SRobert Watson COUNTER_INC(socket_internalize_label); 19041876fb21SRobert Watson 19051876fb21SRobert Watson return (0); 19061876fb21SRobert Watson } 19071876fb21SRobert Watson 1908eb320b0eSRobert Watson COUNTER_DECL(socket_newconn); 1909eb320b0eSRobert Watson static void 1910f0336833SRobert Watson test_socket_newconn(struct socket *oldso, struct label *oldsolabel, 1911f0336833SRobert Watson struct socket *newso, struct label *newsolabel) 1912eb320b0eSRobert Watson { 1913eb320b0eSRobert Watson 19143de40469SRobert Watson SOCK_LOCK(oldso); 1915f0336833SRobert Watson LABEL_CHECK(oldsolabel, MAGIC_SOCKET); 19163de40469SRobert Watson SOCK_UNLOCK(oldso); 19173de40469SRobert Watson SOCK_LOCK(newso); 1918f0336833SRobert Watson LABEL_CHECK(newsolabel, MAGIC_SOCKET); 19193de40469SRobert Watson SOCK_UNLOCK(newso); 1920eb320b0eSRobert Watson COUNTER_INC(socket_newconn); 1921eb320b0eSRobert Watson } 1922eb320b0eSRobert Watson 1923eb320b0eSRobert Watson COUNTER_DECL(socket_relabel); 1924eb320b0eSRobert Watson static void 1925f0336833SRobert Watson test_socket_relabel(struct ucred *cred, struct socket *so, 1926f0336833SRobert Watson struct label *solabel, struct label *newlabel) 1927eb320b0eSRobert Watson { 1928eb320b0eSRobert Watson 19293de40469SRobert Watson SOCK_LOCK_ASSERT(so); 19303de40469SRobert Watson 1931eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1932f0336833SRobert Watson LABEL_CHECK(solabel, MAGIC_SOCKET); 1933eb320b0eSRobert Watson LABEL_CHECK(newlabel, MAGIC_SOCKET); 1934eb320b0eSRobert Watson COUNTER_INC(socket_relabel); 1935eb320b0eSRobert Watson } 1936eb320b0eSRobert Watson 1937eb320b0eSRobert Watson COUNTER_DECL(socketpeer_destroy_label); 1938eb320b0eSRobert Watson static void 1939eb320b0eSRobert Watson test_socketpeer_destroy_label(struct label *label) 1940eb320b0eSRobert Watson { 1941eb320b0eSRobert Watson 1942eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_SOCKET); 1943eb320b0eSRobert Watson COUNTER_INC(socketpeer_destroy_label); 1944eb320b0eSRobert Watson } 1945eb320b0eSRobert Watson 1946eb320b0eSRobert Watson COUNTER_DECL(socketpeer_externalize_label); 1947eb320b0eSRobert Watson static int 1948eb320b0eSRobert Watson test_socketpeer_externalize_label(struct label *label, char *element_name, 1949eb320b0eSRobert Watson struct sbuf *sb, int *claimed) 1950eb320b0eSRobert Watson { 1951eb320b0eSRobert Watson 1952eb320b0eSRobert Watson LABEL_CHECK(label, MAGIC_SOCKET); 1953eb320b0eSRobert Watson COUNTER_INC(socketpeer_externalize_label); 1954eb320b0eSRobert Watson 1955eb320b0eSRobert Watson return (0); 1956eb320b0eSRobert Watson } 1957eb320b0eSRobert Watson 1958eb320b0eSRobert Watson COUNTER_DECL(socketpeer_init_label); 1959eb320b0eSRobert Watson static int 1960eb320b0eSRobert Watson test_socketpeer_init_label(struct label *label, int flag) 1961eb320b0eSRobert Watson { 1962eb320b0eSRobert Watson 1963eb320b0eSRobert Watson if (flag & M_WAITOK) 1964eb320b0eSRobert Watson WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 1965eb320b0eSRobert Watson "test_socketpeer_init_label() at %s:%d", __FILE__, 1966eb320b0eSRobert Watson __LINE__); 1967eb320b0eSRobert Watson 1968eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_SOCKET); 1969eb320b0eSRobert Watson COUNTER_INC(socketpeer_init_label); 1970eb320b0eSRobert Watson return (0); 1971eb320b0eSRobert Watson } 1972eb320b0eSRobert Watson 1973eb320b0eSRobert Watson COUNTER_DECL(socketpeer_set_from_mbuf); 1974eb320b0eSRobert Watson static void 1975f0336833SRobert Watson test_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, 19763de40469SRobert Watson struct socket *so, struct label *sopeerlabel) 1977eb320b0eSRobert Watson { 1978eb320b0eSRobert Watson 1979f0336833SRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 19803de40469SRobert Watson SOCK_LOCK(so); 19813de40469SRobert Watson LABEL_CHECK(sopeerlabel, MAGIC_SOCKET); 19823de40469SRobert Watson SOCK_UNLOCK(so); 1983eb320b0eSRobert Watson COUNTER_INC(socketpeer_set_from_mbuf); 1984eb320b0eSRobert Watson } 1985eb320b0eSRobert Watson 1986eb320b0eSRobert Watson COUNTER_DECL(socketpeer_set_from_socket); 1987eb320b0eSRobert Watson static void 1988f0336833SRobert Watson test_socketpeer_set_from_socket(struct socket *oldso, 1989f0336833SRobert Watson struct label *oldsolabel, struct socket *newso, 1990f0336833SRobert Watson struct label *newsopeerlabel) 1991eb320b0eSRobert Watson { 1992eb320b0eSRobert Watson 19933de40469SRobert Watson SOCK_LOCK(oldso); 1994f0336833SRobert Watson LABEL_CHECK(oldsolabel, MAGIC_SOCKET); 19953de40469SRobert Watson SOCK_UNLOCK(oldso); 19963de40469SRobert Watson SOCK_LOCK(newso); 1997f0336833SRobert Watson LABEL_CHECK(newsopeerlabel, MAGIC_SOCKET); 19983de40469SRobert Watson SOCK_UNLOCK(newso); 1999eb320b0eSRobert Watson COUNTER_INC(socketpeer_set_from_socket); 2000eb320b0eSRobert Watson } 2001eb320b0eSRobert Watson 2002eb320b0eSRobert Watson COUNTER_DECL(syncache_create); 2003eb320b0eSRobert Watson static void 2004eb320b0eSRobert Watson test_syncache_create(struct label *label, struct inpcb *inp) 2005eb320b0eSRobert Watson { 2006eb320b0eSRobert Watson 2007eb320b0eSRobert Watson LABEL_CHECK(label, MAGIC_SYNCACHE); 2008eb320b0eSRobert Watson COUNTER_INC(syncache_create); 2009eb320b0eSRobert Watson } 2010eb320b0eSRobert Watson 2011eb320b0eSRobert Watson COUNTER_DECL(syncache_create_mbuf); 2012eb320b0eSRobert Watson static void 2013eb320b0eSRobert Watson test_syncache_create_mbuf(struct label *sc_label, struct mbuf *m, 2014eb320b0eSRobert Watson struct label *mlabel) 2015eb320b0eSRobert Watson { 2016eb320b0eSRobert Watson 2017eb320b0eSRobert Watson LABEL_CHECK(sc_label, MAGIC_SYNCACHE); 2018eb320b0eSRobert Watson LABEL_CHECK(mlabel, MAGIC_MBUF); 2019eb320b0eSRobert Watson COUNTER_INC(syncache_create_mbuf); 2020eb320b0eSRobert Watson } 2021eb320b0eSRobert Watson 2022eb320b0eSRobert Watson COUNTER_DECL(syncache_destroy_label); 2023eb320b0eSRobert Watson static void 2024eb320b0eSRobert Watson test_syncache_destroy_label(struct label *label) 2025eb320b0eSRobert Watson { 2026eb320b0eSRobert Watson 2027eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_SYNCACHE); 2028eb320b0eSRobert Watson COUNTER_INC(syncache_destroy_label); 2029eb320b0eSRobert Watson } 2030eb320b0eSRobert Watson 2031eb320b0eSRobert Watson COUNTER_DECL(syncache_init_label); 2032eb320b0eSRobert Watson static int 2033eb320b0eSRobert Watson test_syncache_init_label(struct label *label, int flag) 2034eb320b0eSRobert Watson { 2035eb320b0eSRobert Watson 2036eb320b0eSRobert Watson if (flag & M_WAITOK) 2037eb320b0eSRobert Watson WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 2038eb320b0eSRobert Watson "test_syncache_init_label() at %s:%d", __FILE__, 2039eb320b0eSRobert Watson __LINE__); 2040eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_SYNCACHE); 2041eb320b0eSRobert Watson COUNTER_INC(syncache_init_label); 2042eb320b0eSRobert Watson return (0); 2043eb320b0eSRobert Watson } 2044eb320b0eSRobert Watson 204530d239bcSRobert Watson COUNTER_DECL(system_check_acct); 2046ca26e8baSRobert Watson static int 20473f1a7a90SRobert Watson test_system_check_acct(struct ucred *cred, struct vnode *vp, 204878007886SRobert Watson struct label *vplabel) 2049ca26e8baSRobert Watson { 2050ca26e8baSRobert Watson 20516827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 205278007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 205330d239bcSRobert Watson COUNTER_INC(system_check_acct); 205418717f69SRobert Watson 205518717f69SRobert Watson return (0); 205618717f69SRobert Watson } 205718717f69SRobert Watson 205830d239bcSRobert Watson COUNTER_DECL(system_check_audit); 205918717f69SRobert Watson static int 20603f1a7a90SRobert Watson test_system_check_audit(struct ucred *cred, void *record, int length) 206118717f69SRobert Watson { 206218717f69SRobert Watson 20636827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 206430d239bcSRobert Watson COUNTER_INC(system_check_audit); 206518717f69SRobert Watson 206618717f69SRobert Watson return (0); 206718717f69SRobert Watson } 206818717f69SRobert Watson 206930d239bcSRobert Watson COUNTER_DECL(system_check_auditctl); 207018717f69SRobert Watson static int 20713f1a7a90SRobert Watson test_system_check_auditctl(struct ucred *cred, struct vnode *vp, 207278007886SRobert Watson struct label *vplabel) 207318717f69SRobert Watson { 207418717f69SRobert Watson 20756827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 207678007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 207730d239bcSRobert Watson COUNTER_INC(system_check_auditctl); 207818717f69SRobert Watson 207918717f69SRobert Watson return (0); 208018717f69SRobert Watson } 208118717f69SRobert Watson 208230d239bcSRobert Watson COUNTER_DECL(system_check_auditon); 208318717f69SRobert Watson static int 20843f1a7a90SRobert Watson test_system_check_auditon(struct ucred *cred, int cmd) 208518717f69SRobert Watson { 208618717f69SRobert Watson 20876827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 208830d239bcSRobert Watson COUNTER_INC(system_check_auditon); 2089250ee706SRobert Watson 2090ca26e8baSRobert Watson return (0); 2091ca26e8baSRobert Watson } 2092ca26e8baSRobert Watson 209330d239bcSRobert Watson COUNTER_DECL(system_check_reboot); 2094ca26e8baSRobert Watson static int 20953f1a7a90SRobert Watson test_system_check_reboot(struct ucred *cred, int how) 2096ca26e8baSRobert Watson { 2097ca26e8baSRobert Watson 20986827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 209930d239bcSRobert Watson COUNTER_INC(system_check_reboot); 2100250ee706SRobert Watson 2101ca26e8baSRobert Watson return (0); 2102ca26e8baSRobert Watson } 2103ca26e8baSRobert Watson 210430d239bcSRobert Watson COUNTER_DECL(system_check_swapoff); 2105ca26e8baSRobert Watson static int 21063f1a7a90SRobert Watson test_system_check_swapoff(struct ucred *cred, struct vnode *vp, 210778007886SRobert Watson struct label *vplabel) 2108ca26e8baSRobert Watson { 2109ca26e8baSRobert Watson 21106827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 211178007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 211230d239bcSRobert Watson COUNTER_INC(system_check_swapoff); 2113250ee706SRobert Watson 2114ca26e8baSRobert Watson return (0); 2115ca26e8baSRobert Watson } 2116ca26e8baSRobert Watson 211730d239bcSRobert Watson COUNTER_DECL(system_check_swapon); 2118ca26e8baSRobert Watson static int 21193f1a7a90SRobert Watson test_system_check_swapon(struct ucred *cred, struct vnode *vp, 212078007886SRobert Watson struct label *vplabel) 2121ca26e8baSRobert Watson { 2122ca26e8baSRobert Watson 21236827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 212478007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 212530d239bcSRobert Watson COUNTER_INC(system_check_swapon); 2126250ee706SRobert Watson 2127ca26e8baSRobert Watson return (0); 2128ca26e8baSRobert Watson } 2129ca26e8baSRobert Watson 213030d239bcSRobert Watson COUNTER_DECL(system_check_sysctl); 2131ca26e8baSRobert Watson static int 21323f1a7a90SRobert Watson test_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, 213363dba32bSPawel Jakub Dawidek void *arg1, int arg2, struct sysctl_req *req) 2134ca26e8baSRobert Watson { 2135ca26e8baSRobert Watson 21366827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 213730d239bcSRobert Watson COUNTER_INC(system_check_sysctl); 2138250ee706SRobert Watson 2139ca26e8baSRobert Watson return (0); 2140ca26e8baSRobert Watson } 2141ca26e8baSRobert Watson 2142eb320b0eSRobert Watson COUNTER_DECL(sysvmsg_cleanup); 2143eb320b0eSRobert Watson static void 2144eb320b0eSRobert Watson test_sysvmsg_cleanup(struct label *msglabel) 2145eb320b0eSRobert Watson { 2146eb320b0eSRobert Watson 2147eb320b0eSRobert Watson LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2148eb320b0eSRobert Watson COUNTER_INC(sysvmsg_cleanup); 2149eb320b0eSRobert Watson } 2150eb320b0eSRobert Watson 2151eb320b0eSRobert Watson COUNTER_DECL(sysvmsg_create); 2152eb320b0eSRobert Watson static void 2153eb320b0eSRobert Watson test_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, 2154eb320b0eSRobert Watson struct label *msqlabel, struct msg *msgptr, struct label *msglabel) 2155eb320b0eSRobert Watson { 2156eb320b0eSRobert Watson 2157eb320b0eSRobert Watson LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2158eb320b0eSRobert Watson LABEL_CHECK(msqlabel, MAGIC_SYSV_MSQ); 2159eb320b0eSRobert Watson COUNTER_INC(sysvmsg_create); 2160eb320b0eSRobert Watson } 2161eb320b0eSRobert Watson 2162eb320b0eSRobert Watson COUNTER_DECL(sysvmsg_destroy_label); 2163eb320b0eSRobert Watson static void 2164eb320b0eSRobert Watson test_sysvmsg_destroy_label(struct label *label) 2165eb320b0eSRobert Watson { 2166eb320b0eSRobert Watson 2167eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_SYSV_MSG); 2168eb320b0eSRobert Watson COUNTER_INC(sysvmsg_destroy_label); 2169eb320b0eSRobert Watson } 2170eb320b0eSRobert Watson 2171eb320b0eSRobert Watson COUNTER_DECL(sysvmsg_init_label); 2172eb320b0eSRobert Watson static void 2173eb320b0eSRobert Watson test_sysvmsg_init_label(struct label *label) 2174eb320b0eSRobert Watson { 2175eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_SYSV_MSG); 2176eb320b0eSRobert Watson COUNTER_INC(sysvmsg_init_label); 2177eb320b0eSRobert Watson } 2178eb320b0eSRobert Watson 2179eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_check_msgmsq); 2180eb320b0eSRobert Watson static int 2181eb320b0eSRobert Watson test_sysvmsq_check_msgmsq(struct ucred *cred, struct msg *msgptr, 2182eb320b0eSRobert Watson struct label *msglabel, struct msqid_kernel *msqkptr, 2183eb320b0eSRobert Watson struct label *msqklabel) 2184eb320b0eSRobert Watson { 2185eb320b0eSRobert Watson 2186eb320b0eSRobert Watson LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2187eb320b0eSRobert Watson LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2188eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2189eb320b0eSRobert Watson COUNTER_INC(sysvmsq_check_msgmsq); 2190eb320b0eSRobert Watson 2191eb320b0eSRobert Watson return (0); 2192eb320b0eSRobert Watson } 2193eb320b0eSRobert Watson 2194eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_check_msgrcv); 2195eb320b0eSRobert Watson static int 2196eb320b0eSRobert Watson test_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, 2197eb320b0eSRobert Watson struct label *msglabel) 2198eb320b0eSRobert Watson { 2199eb320b0eSRobert Watson 2200eb320b0eSRobert Watson LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2201eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2202eb320b0eSRobert Watson COUNTER_INC(sysvmsq_check_msgrcv); 2203eb320b0eSRobert Watson 2204eb320b0eSRobert Watson return (0); 2205eb320b0eSRobert Watson } 2206eb320b0eSRobert Watson 2207eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_check_msgrmid); 2208eb320b0eSRobert Watson static int 2209eb320b0eSRobert Watson test_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, 2210eb320b0eSRobert Watson struct label *msglabel) 2211eb320b0eSRobert Watson { 2212eb320b0eSRobert Watson 2213eb320b0eSRobert Watson LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2214eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2215eb320b0eSRobert Watson COUNTER_INC(sysvmsq_check_msgrmid); 2216eb320b0eSRobert Watson 2217eb320b0eSRobert Watson return (0); 2218eb320b0eSRobert Watson } 2219eb320b0eSRobert Watson 2220eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_check_msqget); 2221eb320b0eSRobert Watson static int 2222eb320b0eSRobert Watson test_sysvmsq_check_msqget(struct ucred *cred, 2223eb320b0eSRobert Watson struct msqid_kernel *msqkptr, struct label *msqklabel) 2224eb320b0eSRobert Watson { 2225eb320b0eSRobert Watson 2226eb320b0eSRobert Watson LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2227eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2228eb320b0eSRobert Watson COUNTER_INC(sysvmsq_check_msqget); 2229eb320b0eSRobert Watson 2230eb320b0eSRobert Watson return (0); 2231eb320b0eSRobert Watson } 2232eb320b0eSRobert Watson 2233eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_check_msqsnd); 2234eb320b0eSRobert Watson static int 2235eb320b0eSRobert Watson test_sysvmsq_check_msqsnd(struct ucred *cred, 2236eb320b0eSRobert Watson struct msqid_kernel *msqkptr, struct label *msqklabel) 2237eb320b0eSRobert Watson { 2238eb320b0eSRobert Watson 2239eb320b0eSRobert Watson LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2240eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2241eb320b0eSRobert Watson COUNTER_INC(sysvmsq_check_msqsnd); 2242eb320b0eSRobert Watson 2243eb320b0eSRobert Watson return (0); 2244eb320b0eSRobert Watson } 2245eb320b0eSRobert Watson 2246eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_check_msqrcv); 2247eb320b0eSRobert Watson static int 2248eb320b0eSRobert Watson test_sysvmsq_check_msqrcv(struct ucred *cred, 2249eb320b0eSRobert Watson struct msqid_kernel *msqkptr, struct label *msqklabel) 2250eb320b0eSRobert Watson { 2251eb320b0eSRobert Watson 2252eb320b0eSRobert Watson LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2253eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2254eb320b0eSRobert Watson COUNTER_INC(sysvmsq_check_msqrcv); 2255eb320b0eSRobert Watson 2256eb320b0eSRobert Watson return (0); 2257eb320b0eSRobert Watson } 2258eb320b0eSRobert Watson 2259eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_check_msqctl); 2260eb320b0eSRobert Watson static int 2261eb320b0eSRobert Watson test_sysvmsq_check_msqctl(struct ucred *cred, 2262eb320b0eSRobert Watson struct msqid_kernel *msqkptr, struct label *msqklabel, int cmd) 2263eb320b0eSRobert Watson { 2264eb320b0eSRobert Watson 2265eb320b0eSRobert Watson LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2266eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2267eb320b0eSRobert Watson COUNTER_INC(sysvmsq_check_msqctl); 2268eb320b0eSRobert Watson 2269eb320b0eSRobert Watson return (0); 2270eb320b0eSRobert Watson } 2271eb320b0eSRobert Watson 2272eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_cleanup); 2273eb320b0eSRobert Watson static void 2274eb320b0eSRobert Watson test_sysvmsq_cleanup(struct label *msqlabel) 2275eb320b0eSRobert Watson { 2276eb320b0eSRobert Watson 2277eb320b0eSRobert Watson LABEL_CHECK(msqlabel, MAGIC_SYSV_MSQ); 2278eb320b0eSRobert Watson COUNTER_INC(sysvmsq_cleanup); 2279eb320b0eSRobert Watson } 2280eb320b0eSRobert Watson 2281eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_create); 2282eb320b0eSRobert Watson static void 2283eb320b0eSRobert Watson test_sysvmsq_create(struct ucred *cred, 2284eb320b0eSRobert Watson struct msqid_kernel *msqkptr, struct label *msqlabel) 2285eb320b0eSRobert Watson { 2286eb320b0eSRobert Watson 2287eb320b0eSRobert Watson LABEL_CHECK(msqlabel, MAGIC_SYSV_MSQ); 2288eb320b0eSRobert Watson COUNTER_INC(sysvmsq_create); 2289eb320b0eSRobert Watson } 2290eb320b0eSRobert Watson 2291eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_destroy_label); 2292eb320b0eSRobert Watson static void 2293eb320b0eSRobert Watson test_sysvmsq_destroy_label(struct label *label) 2294eb320b0eSRobert Watson { 2295eb320b0eSRobert Watson 2296eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_SYSV_MSQ); 2297eb320b0eSRobert Watson COUNTER_INC(sysvmsq_destroy_label); 2298eb320b0eSRobert Watson } 2299eb320b0eSRobert Watson 2300eb320b0eSRobert Watson COUNTER_DECL(sysvmsq_init_label); 2301eb320b0eSRobert Watson static void 2302eb320b0eSRobert Watson test_sysvmsq_init_label(struct label *label) 2303eb320b0eSRobert Watson { 2304eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_SYSV_MSQ); 2305eb320b0eSRobert Watson COUNTER_INC(sysvmsq_init_label); 2306eb320b0eSRobert Watson } 2307eb320b0eSRobert Watson 2308eb320b0eSRobert Watson COUNTER_DECL(sysvsem_check_semctl); 2309eb320b0eSRobert Watson static int 2310eb320b0eSRobert Watson test_sysvsem_check_semctl(struct ucred *cred, 2311eb320b0eSRobert Watson struct semid_kernel *semakptr, struct label *semaklabel, int cmd) 2312eb320b0eSRobert Watson { 2313eb320b0eSRobert Watson 2314eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2315eb320b0eSRobert Watson LABEL_CHECK(semaklabel, MAGIC_SYSV_SEM); 2316eb320b0eSRobert Watson COUNTER_INC(sysvsem_check_semctl); 2317eb320b0eSRobert Watson 2318eb320b0eSRobert Watson return (0); 2319eb320b0eSRobert Watson } 2320eb320b0eSRobert Watson 2321eb320b0eSRobert Watson COUNTER_DECL(sysvsem_check_semget); 2322eb320b0eSRobert Watson static int 2323eb320b0eSRobert Watson test_sysvsem_check_semget(struct ucred *cred, 2324eb320b0eSRobert Watson struct semid_kernel *semakptr, struct label *semaklabel) 2325eb320b0eSRobert Watson { 2326eb320b0eSRobert Watson 2327eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2328eb320b0eSRobert Watson LABEL_CHECK(semaklabel, MAGIC_SYSV_SEM); 2329eb320b0eSRobert Watson COUNTER_INC(sysvsem_check_semget); 2330eb320b0eSRobert Watson 2331eb320b0eSRobert Watson return (0); 2332eb320b0eSRobert Watson } 2333eb320b0eSRobert Watson 2334eb320b0eSRobert Watson COUNTER_DECL(sysvsem_check_semop); 2335eb320b0eSRobert Watson static int 2336eb320b0eSRobert Watson test_sysvsem_check_semop(struct ucred *cred, 2337eb320b0eSRobert Watson struct semid_kernel *semakptr, struct label *semaklabel, size_t accesstype) 2338eb320b0eSRobert Watson { 2339eb320b0eSRobert Watson 2340eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2341eb320b0eSRobert Watson LABEL_CHECK(semaklabel, MAGIC_SYSV_SEM); 2342eb320b0eSRobert Watson COUNTER_INC(sysvsem_check_semop); 2343eb320b0eSRobert Watson 2344eb320b0eSRobert Watson return (0); 2345eb320b0eSRobert Watson } 2346eb320b0eSRobert Watson 2347eb320b0eSRobert Watson COUNTER_DECL(sysvsem_cleanup); 2348eb320b0eSRobert Watson static void 2349eb320b0eSRobert Watson test_sysvsem_cleanup(struct label *semalabel) 2350eb320b0eSRobert Watson { 2351eb320b0eSRobert Watson 2352eb320b0eSRobert Watson LABEL_CHECK(semalabel, MAGIC_SYSV_SEM); 2353eb320b0eSRobert Watson COUNTER_INC(sysvsem_cleanup); 2354eb320b0eSRobert Watson } 2355eb320b0eSRobert Watson 2356eb320b0eSRobert Watson COUNTER_DECL(sysvsem_create); 2357eb320b0eSRobert Watson static void 2358eb320b0eSRobert Watson test_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, 2359eb320b0eSRobert Watson struct label *semalabel) 2360eb320b0eSRobert Watson { 2361eb320b0eSRobert Watson 2362eb320b0eSRobert Watson LABEL_CHECK(semalabel, MAGIC_SYSV_SEM); 2363eb320b0eSRobert Watson COUNTER_INC(sysvsem_create); 2364eb320b0eSRobert Watson } 2365eb320b0eSRobert Watson 2366eb320b0eSRobert Watson COUNTER_DECL(sysvsem_destroy_label); 2367eb320b0eSRobert Watson static void 2368eb320b0eSRobert Watson test_sysvsem_destroy_label(struct label *label) 2369eb320b0eSRobert Watson { 2370eb320b0eSRobert Watson 2371eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_SYSV_SEM); 2372eb320b0eSRobert Watson COUNTER_INC(sysvsem_destroy_label); 2373eb320b0eSRobert Watson } 2374eb320b0eSRobert Watson 2375eb320b0eSRobert Watson COUNTER_DECL(sysvsem_init_label); 2376eb320b0eSRobert Watson static void 2377eb320b0eSRobert Watson test_sysvsem_init_label(struct label *label) 2378eb320b0eSRobert Watson { 2379eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_SYSV_SEM); 2380eb320b0eSRobert Watson COUNTER_INC(sysvsem_init_label); 2381eb320b0eSRobert Watson } 2382eb320b0eSRobert Watson 2383eb320b0eSRobert Watson COUNTER_DECL(sysvshm_check_shmat); 2384eb320b0eSRobert Watson static int 2385eb320b0eSRobert Watson test_sysvshm_check_shmat(struct ucred *cred, 2386eb320b0eSRobert Watson struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) 2387eb320b0eSRobert Watson { 2388eb320b0eSRobert Watson 2389eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2390eb320b0eSRobert Watson LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2391eb320b0eSRobert Watson COUNTER_INC(sysvshm_check_shmat); 2392eb320b0eSRobert Watson 2393eb320b0eSRobert Watson return (0); 2394eb320b0eSRobert Watson } 2395eb320b0eSRobert Watson 2396eb320b0eSRobert Watson COUNTER_DECL(sysvshm_check_shmctl); 2397eb320b0eSRobert Watson static int 2398eb320b0eSRobert Watson test_sysvshm_check_shmctl(struct ucred *cred, 2399eb320b0eSRobert Watson struct shmid_kernel *shmsegptr, struct label *shmseglabel, int cmd) 2400eb320b0eSRobert Watson { 2401eb320b0eSRobert Watson 2402eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2403eb320b0eSRobert Watson LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2404eb320b0eSRobert Watson COUNTER_INC(sysvshm_check_shmctl); 2405eb320b0eSRobert Watson 2406eb320b0eSRobert Watson return (0); 2407eb320b0eSRobert Watson } 2408eb320b0eSRobert Watson 2409eb320b0eSRobert Watson COUNTER_DECL(sysvshm_check_shmdt); 2410eb320b0eSRobert Watson static int 2411eb320b0eSRobert Watson test_sysvshm_check_shmdt(struct ucred *cred, 2412eb320b0eSRobert Watson struct shmid_kernel *shmsegptr, struct label *shmseglabel) 2413eb320b0eSRobert Watson { 2414eb320b0eSRobert Watson 2415eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2416eb320b0eSRobert Watson LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2417eb320b0eSRobert Watson COUNTER_INC(sysvshm_check_shmdt); 2418eb320b0eSRobert Watson 2419eb320b0eSRobert Watson return (0); 2420eb320b0eSRobert Watson } 2421eb320b0eSRobert Watson 2422eb320b0eSRobert Watson COUNTER_DECL(sysvshm_check_shmget); 2423eb320b0eSRobert Watson static int 2424eb320b0eSRobert Watson test_sysvshm_check_shmget(struct ucred *cred, 2425eb320b0eSRobert Watson struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) 2426eb320b0eSRobert Watson { 2427eb320b0eSRobert Watson 2428eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2429eb320b0eSRobert Watson LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2430eb320b0eSRobert Watson COUNTER_INC(sysvshm_check_shmget); 2431eb320b0eSRobert Watson 2432eb320b0eSRobert Watson return (0); 2433eb320b0eSRobert Watson } 2434eb320b0eSRobert Watson 2435eb320b0eSRobert Watson COUNTER_DECL(sysvshm_cleanup); 2436eb320b0eSRobert Watson static void 2437eb320b0eSRobert Watson test_sysvshm_cleanup(struct label *shmlabel) 2438eb320b0eSRobert Watson { 2439eb320b0eSRobert Watson 2440eb320b0eSRobert Watson LABEL_CHECK(shmlabel, MAGIC_SYSV_SHM); 2441eb320b0eSRobert Watson COUNTER_INC(sysvshm_cleanup); 2442eb320b0eSRobert Watson } 2443eb320b0eSRobert Watson 2444eb320b0eSRobert Watson COUNTER_DECL(sysvshm_create); 2445eb320b0eSRobert Watson static void 2446eb320b0eSRobert Watson test_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, 2447eb320b0eSRobert Watson struct label *shmlabel) 2448eb320b0eSRobert Watson { 2449eb320b0eSRobert Watson 2450eb320b0eSRobert Watson LABEL_CHECK(shmlabel, MAGIC_SYSV_SHM); 2451eb320b0eSRobert Watson COUNTER_INC(sysvshm_create); 2452eb320b0eSRobert Watson } 2453eb320b0eSRobert Watson 2454eb320b0eSRobert Watson COUNTER_DECL(sysvshm_destroy_label); 2455eb320b0eSRobert Watson static void 2456eb320b0eSRobert Watson test_sysvshm_destroy_label(struct label *label) 2457eb320b0eSRobert Watson { 2458eb320b0eSRobert Watson 2459eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_SYSV_SHM); 2460eb320b0eSRobert Watson COUNTER_INC(sysvshm_destroy_label); 2461eb320b0eSRobert Watson } 2462eb320b0eSRobert Watson 2463eb320b0eSRobert Watson COUNTER_DECL(sysvshm_init_label); 2464eb320b0eSRobert Watson static void 2465eb320b0eSRobert Watson test_sysvshm_init_label(struct label *label) 2466eb320b0eSRobert Watson { 2467eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_SYSV_SHM); 2468eb320b0eSRobert Watson COUNTER_INC(sysvshm_init_label); 2469eb320b0eSRobert Watson } 2470eb320b0eSRobert Watson 2471eb320b0eSRobert Watson COUNTER_DECL(thread_userret); 2472eb320b0eSRobert Watson static void 2473eb320b0eSRobert Watson test_thread_userret(struct thread *td) 2474eb320b0eSRobert Watson { 2475eb320b0eSRobert Watson 2476eb320b0eSRobert Watson COUNTER_INC(thread_userret); 2477eb320b0eSRobert Watson } 2478eb320b0eSRobert Watson 2479eb320b0eSRobert Watson COUNTER_DECL(vnode_associate_extattr); 2480eb320b0eSRobert Watson static int 2481eb320b0eSRobert Watson test_vnode_associate_extattr(struct mount *mp, struct label *mplabel, 2482eb320b0eSRobert Watson struct vnode *vp, struct label *vplabel) 2483eb320b0eSRobert Watson { 2484eb320b0eSRobert Watson 2485eb320b0eSRobert Watson LABEL_CHECK(mplabel, MAGIC_MOUNT); 2486eb320b0eSRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 2487eb320b0eSRobert Watson COUNTER_INC(vnode_associate_extattr); 2488eb320b0eSRobert Watson 2489eb320b0eSRobert Watson return (0); 2490eb320b0eSRobert Watson } 2491eb320b0eSRobert Watson 2492eb320b0eSRobert Watson COUNTER_DECL(vnode_associate_singlelabel); 2493eb320b0eSRobert Watson static void 2494eb320b0eSRobert Watson test_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, 2495eb320b0eSRobert Watson struct vnode *vp, struct label *vplabel) 2496eb320b0eSRobert Watson { 2497eb320b0eSRobert Watson 2498eb320b0eSRobert Watson LABEL_CHECK(mplabel, MAGIC_MOUNT); 2499eb320b0eSRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 2500eb320b0eSRobert Watson COUNTER_INC(vnode_associate_singlelabel); 2501eb320b0eSRobert Watson } 2502eb320b0eSRobert Watson 250330d239bcSRobert Watson COUNTER_DECL(vnode_check_access); 2504ca26e8baSRobert Watson static int 25053f1a7a90SRobert Watson test_vnode_check_access(struct ucred *cred, struct vnode *vp, 250615bc6b2bSEdward Tomasz Napierala struct label *vplabel, accmode_t accmode) 2507d8a7b7a3SRobert Watson { 2508d8a7b7a3SRobert Watson 25096827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 251078007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 251130d239bcSRobert Watson COUNTER_INC(vnode_check_access); 2512250ee706SRobert Watson 2513d8a7b7a3SRobert Watson return (0); 2514d8a7b7a3SRobert Watson } 2515d8a7b7a3SRobert Watson 251630d239bcSRobert Watson COUNTER_DECL(vnode_check_chdir); 2517d8a7b7a3SRobert Watson static int 25183f1a7a90SRobert Watson test_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, 251978007886SRobert Watson struct label *dvplabel) 2520d8a7b7a3SRobert Watson { 2521d8a7b7a3SRobert Watson 25226827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 252378007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 252430d239bcSRobert Watson COUNTER_INC(vnode_check_chdir); 2525250ee706SRobert Watson 2526d8a7b7a3SRobert Watson return (0); 2527d8a7b7a3SRobert Watson } 2528d8a7b7a3SRobert Watson 252930d239bcSRobert Watson COUNTER_DECL(vnode_check_chroot); 2530d8a7b7a3SRobert Watson static int 25313f1a7a90SRobert Watson test_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, 253278007886SRobert Watson struct label *dvplabel) 2533d8a7b7a3SRobert Watson { 2534d8a7b7a3SRobert Watson 25356827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 253678007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 253730d239bcSRobert Watson COUNTER_INC(vnode_check_chroot); 2538250ee706SRobert Watson 2539d8a7b7a3SRobert Watson return (0); 2540d8a7b7a3SRobert Watson } 2541d8a7b7a3SRobert Watson 254230d239bcSRobert Watson COUNTER_DECL(vnode_check_create); 2543d8a7b7a3SRobert Watson static int 25443f1a7a90SRobert Watson test_vnode_check_create(struct ucred *cred, struct vnode *dvp, 254578007886SRobert Watson struct label *dvplabel, struct componentname *cnp, struct vattr *vap) 2546d8a7b7a3SRobert Watson { 2547d8a7b7a3SRobert Watson 25486827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 254978007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 255030d239bcSRobert Watson COUNTER_INC(vnode_check_create); 2551250ee706SRobert Watson 2552d8a7b7a3SRobert Watson return (0); 2553d8a7b7a3SRobert Watson } 2554d8a7b7a3SRobert Watson 255530d239bcSRobert Watson COUNTER_DECL(vnode_check_deleteacl); 2556d8a7b7a3SRobert Watson static int 25573f1a7a90SRobert Watson test_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, 255878007886SRobert Watson struct label *vplabel, acl_type_t type) 2559d8a7b7a3SRobert Watson { 2560d8a7b7a3SRobert Watson 25616827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 256278007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 256330d239bcSRobert Watson COUNTER_INC(vnode_check_deleteacl); 2564250ee706SRobert Watson 2565250ee706SRobert Watson return (0); 2566250ee706SRobert Watson } 2567250ee706SRobert Watson 256830d239bcSRobert Watson COUNTER_DECL(vnode_check_deleteextattr); 2569250ee706SRobert Watson static int 25703f1a7a90SRobert Watson test_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, 257178007886SRobert Watson struct label *vplabel, int attrnamespace, const char *name) 2572250ee706SRobert Watson { 2573250ee706SRobert Watson 25746827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 257578007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 257630d239bcSRobert Watson COUNTER_INC(vnode_check_deleteextattr); 2577250ee706SRobert Watson 2578d8a7b7a3SRobert Watson return (0); 2579d8a7b7a3SRobert Watson } 2580d8a7b7a3SRobert Watson 258130d239bcSRobert Watson COUNTER_DECL(vnode_check_exec); 2582d8a7b7a3SRobert Watson static int 25833f1a7a90SRobert Watson test_vnode_check_exec(struct ucred *cred, struct vnode *vp, 258478007886SRobert Watson struct label *vplabel, struct image_params *imgp, 2585ef5def59SRobert Watson struct label *execlabel) 2586d8a7b7a3SRobert Watson { 2587d8a7b7a3SRobert Watson 25886827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 258978007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 25906827d029SRobert Watson LABEL_CHECK(execlabel, MAGIC_CRED); 259130d239bcSRobert Watson COUNTER_INC(vnode_check_exec); 2592250ee706SRobert Watson 2593d8a7b7a3SRobert Watson return (0); 2594d8a7b7a3SRobert Watson } 2595d8a7b7a3SRobert Watson 259630d239bcSRobert Watson COUNTER_DECL(vnode_check_getacl); 2597d8a7b7a3SRobert Watson static int 25983f1a7a90SRobert Watson test_vnode_check_getacl(struct ucred *cred, struct vnode *vp, 259978007886SRobert Watson struct label *vplabel, acl_type_t type) 2600d8a7b7a3SRobert Watson { 2601d8a7b7a3SRobert Watson 26026827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 260378007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 260430d239bcSRobert Watson COUNTER_INC(vnode_check_getacl); 2605250ee706SRobert Watson 2606d8a7b7a3SRobert Watson return (0); 2607d8a7b7a3SRobert Watson } 2608d8a7b7a3SRobert Watson 260930d239bcSRobert Watson COUNTER_DECL(vnode_check_getextattr); 2610d8a7b7a3SRobert Watson static int 26113f1a7a90SRobert Watson test_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, 2612fefd0ac8SRobert Watson struct label *vplabel, int attrnamespace, const char *name) 2613d8a7b7a3SRobert Watson { 2614d8a7b7a3SRobert Watson 26156827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 261678007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 261730d239bcSRobert Watson COUNTER_INC(vnode_check_getextattr); 2618250ee706SRobert Watson 2619d8a7b7a3SRobert Watson return (0); 2620d8a7b7a3SRobert Watson } 2621d8a7b7a3SRobert Watson 262230d239bcSRobert Watson COUNTER_DECL(vnode_check_link); 2623d8a7b7a3SRobert Watson static int 26243f1a7a90SRobert Watson test_vnode_check_link(struct ucred *cred, struct vnode *dvp, 262578007886SRobert Watson struct label *dvplabel, struct vnode *vp, struct label *vplabel, 2626c27b50f5SRobert Watson struct componentname *cnp) 2627c27b50f5SRobert Watson { 2628c27b50f5SRobert Watson 26296827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 263078007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 263178007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 263230d239bcSRobert Watson COUNTER_INC(vnode_check_link); 2633250ee706SRobert Watson 2634250ee706SRobert Watson return (0); 2635250ee706SRobert Watson } 2636250ee706SRobert Watson 263730d239bcSRobert Watson COUNTER_DECL(vnode_check_listextattr); 2638250ee706SRobert Watson static int 26393f1a7a90SRobert Watson test_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, 264078007886SRobert Watson struct label *vplabel, int attrnamespace) 2641250ee706SRobert Watson { 2642250ee706SRobert Watson 26436827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 264478007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 264530d239bcSRobert Watson COUNTER_INC(vnode_check_listextattr); 2646250ee706SRobert Watson 2647c27b50f5SRobert Watson return (0); 2648c27b50f5SRobert Watson } 2649c27b50f5SRobert Watson 265030d239bcSRobert Watson COUNTER_DECL(vnode_check_lookup); 2651c27b50f5SRobert Watson static int 26523f1a7a90SRobert Watson test_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, 265378007886SRobert Watson struct label *dvplabel, struct componentname *cnp) 2654d8a7b7a3SRobert Watson { 2655d8a7b7a3SRobert Watson 26566827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 265778007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 265830d239bcSRobert Watson COUNTER_INC(vnode_check_lookup); 2659250ee706SRobert Watson 2660d8a7b7a3SRobert Watson return (0); 2661d8a7b7a3SRobert Watson } 2662d8a7b7a3SRobert Watson 266330d239bcSRobert Watson COUNTER_DECL(vnode_check_mmap); 2664d8a7b7a3SRobert Watson static int 26653f1a7a90SRobert Watson test_vnode_check_mmap(struct ucred *cred, struct vnode *vp, 266678007886SRobert Watson struct label *vplabel, int prot, int flags) 2667e183f80eSRobert Watson { 2668e183f80eSRobert Watson 26696827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 267078007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 267130d239bcSRobert Watson COUNTER_INC(vnode_check_mmap); 2672250ee706SRobert Watson 2673e183f80eSRobert Watson return (0); 2674e183f80eSRobert Watson } 2675e183f80eSRobert Watson 267630d239bcSRobert Watson COUNTER_DECL(vnode_check_open); 2677e183f80eSRobert Watson static int 26783f1a7a90SRobert Watson test_vnode_check_open(struct ucred *cred, struct vnode *vp, 267915bc6b2bSEdward Tomasz Napierala struct label *vplabel, accmode_t accmode) 2680d8a7b7a3SRobert Watson { 2681d8a7b7a3SRobert Watson 26826827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 268378007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 268430d239bcSRobert Watson COUNTER_INC(vnode_check_open); 2685250ee706SRobert Watson 2686d8a7b7a3SRobert Watson return (0); 2687d8a7b7a3SRobert Watson } 2688d8a7b7a3SRobert Watson 268930d239bcSRobert Watson COUNTER_DECL(vnode_check_poll); 2690d8a7b7a3SRobert Watson static int 26913f1a7a90SRobert Watson test_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, 269278007886SRobert Watson struct vnode *vp, struct label *vplabel) 26937f724f8bSRobert Watson { 26947f724f8bSRobert Watson 26956827d029SRobert Watson LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 26966827d029SRobert Watson if (file_cred != NULL) 26976827d029SRobert Watson LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 269878007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 269930d239bcSRobert Watson COUNTER_INC(vnode_check_poll); 2700250ee706SRobert Watson 27017f724f8bSRobert Watson return (0); 27027f724f8bSRobert Watson } 27037f724f8bSRobert Watson 270430d239bcSRobert Watson COUNTER_DECL(vnode_check_read); 27057f724f8bSRobert Watson static int 27063f1a7a90SRobert Watson test_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, 270778007886SRobert Watson struct vnode *vp, struct label *vplabel) 27087f724f8bSRobert Watson { 27097f724f8bSRobert Watson 27106827d029SRobert Watson LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 27116827d029SRobert Watson if (file_cred != NULL) 27126827d029SRobert Watson LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 271378007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 271430d239bcSRobert Watson COUNTER_INC(vnode_check_read); 2715250ee706SRobert Watson 27167f724f8bSRobert Watson return (0); 27177f724f8bSRobert Watson } 27187f724f8bSRobert Watson 271930d239bcSRobert Watson COUNTER_DECL(vnode_check_readdir); 27207f724f8bSRobert Watson static int 27213f1a7a90SRobert Watson test_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, 272278007886SRobert Watson struct label *dvplabel) 2723d8a7b7a3SRobert Watson { 2724d8a7b7a3SRobert Watson 27256827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 272678007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 272730d239bcSRobert Watson COUNTER_INC(vnode_check_readdir); 2728250ee706SRobert Watson 2729d8a7b7a3SRobert Watson return (0); 2730d8a7b7a3SRobert Watson } 2731d8a7b7a3SRobert Watson 273230d239bcSRobert Watson COUNTER_DECL(vnode_check_readlink); 2733d8a7b7a3SRobert Watson static int 27343f1a7a90SRobert Watson test_vnode_check_readlink(struct ucred *cred, struct vnode *vp, 273578007886SRobert Watson struct label *vplabel) 2736d8a7b7a3SRobert Watson { 2737d8a7b7a3SRobert Watson 27386827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 273978007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 274030d239bcSRobert Watson COUNTER_INC(vnode_check_readlink); 2741250ee706SRobert Watson 2742d8a7b7a3SRobert Watson return (0); 2743d8a7b7a3SRobert Watson } 2744d8a7b7a3SRobert Watson 274530d239bcSRobert Watson COUNTER_DECL(vnode_check_relabel); 2746d8a7b7a3SRobert Watson static int 27473f1a7a90SRobert Watson test_vnode_check_relabel(struct ucred *cred, struct vnode *vp, 274878007886SRobert Watson struct label *vplabel, struct label *newlabel) 2749d8a7b7a3SRobert Watson { 2750d8a7b7a3SRobert Watson 27516827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 275278007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 27536827d029SRobert Watson LABEL_CHECK(newlabel, MAGIC_VNODE); 275430d239bcSRobert Watson COUNTER_INC(vnode_check_relabel); 2755250ee706SRobert Watson 2756d8a7b7a3SRobert Watson return (0); 2757d8a7b7a3SRobert Watson } 2758d8a7b7a3SRobert Watson 275930d239bcSRobert Watson COUNTER_DECL(vnode_check_rename_from); 2760d8a7b7a3SRobert Watson static int 27613f1a7a90SRobert Watson test_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, 276278007886SRobert Watson struct label *dvplabel, struct vnode *vp, struct label *vplabel, 2763d8a7b7a3SRobert Watson struct componentname *cnp) 2764d8a7b7a3SRobert Watson { 2765d8a7b7a3SRobert Watson 27666827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 276778007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 276878007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 276930d239bcSRobert Watson COUNTER_INC(vnode_check_rename_from); 2770250ee706SRobert Watson 2771d8a7b7a3SRobert Watson return (0); 2772d8a7b7a3SRobert Watson } 2773d8a7b7a3SRobert Watson 277430d239bcSRobert Watson COUNTER_DECL(vnode_check_rename_to); 2775d8a7b7a3SRobert Watson static int 27763f1a7a90SRobert Watson test_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, 277778007886SRobert Watson struct label *dvplabel, struct vnode *vp, struct label *vplabel, 277878007886SRobert Watson int samedir, struct componentname *cnp) 2779d8a7b7a3SRobert Watson { 2780d8a7b7a3SRobert Watson 27816827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 278278007886SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 278378007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 278430d239bcSRobert Watson COUNTER_INC(vnode_check_rename_to); 2785250ee706SRobert Watson 2786d8a7b7a3SRobert Watson return (0); 2787d8a7b7a3SRobert Watson } 2788d8a7b7a3SRobert Watson 278930d239bcSRobert Watson COUNTER_DECL(vnode_check_revoke); 2790d8a7b7a3SRobert Watson static int 27913f1a7a90SRobert Watson test_vnode_check_revoke(struct ucred *cred, struct vnode *vp, 279278007886SRobert Watson struct label *vplabel) 2793d8a7b7a3SRobert Watson { 2794d8a7b7a3SRobert Watson 27956827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 279678007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 279730d239bcSRobert Watson COUNTER_INC(vnode_check_revoke); 2798250ee706SRobert Watson 2799d8a7b7a3SRobert Watson return (0); 2800d8a7b7a3SRobert Watson } 2801d8a7b7a3SRobert Watson 280230d239bcSRobert Watson COUNTER_DECL(vnode_check_setacl); 2803d8a7b7a3SRobert Watson static int 28043f1a7a90SRobert Watson test_vnode_check_setacl(struct ucred *cred, struct vnode *vp, 280578007886SRobert Watson struct label *vplabel, acl_type_t type, struct acl *acl) 2806d8a7b7a3SRobert Watson { 2807d8a7b7a3SRobert Watson 28086827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 280978007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 281030d239bcSRobert Watson COUNTER_INC(vnode_check_setacl); 2811250ee706SRobert Watson 2812d8a7b7a3SRobert Watson return (0); 2813d8a7b7a3SRobert Watson } 2814d8a7b7a3SRobert Watson 281530d239bcSRobert Watson COUNTER_DECL(vnode_check_setextattr); 2816d8a7b7a3SRobert Watson static int 28173f1a7a90SRobert Watson test_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, 2818fefd0ac8SRobert Watson struct label *vplabel, int attrnamespace, const char *name) 2819d8a7b7a3SRobert Watson { 2820d8a7b7a3SRobert Watson 28216827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 282278007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 282330d239bcSRobert Watson COUNTER_INC(vnode_check_setextattr); 2824250ee706SRobert Watson 2825d8a7b7a3SRobert Watson return (0); 2826d8a7b7a3SRobert Watson } 2827d8a7b7a3SRobert Watson 282830d239bcSRobert Watson COUNTER_DECL(vnode_check_setflags); 2829d8a7b7a3SRobert Watson static int 28303f1a7a90SRobert Watson test_vnode_check_setflags(struct ucred *cred, struct vnode *vp, 283178007886SRobert Watson struct label *vplabel, u_long flags) 2832d8a7b7a3SRobert Watson { 2833d8a7b7a3SRobert Watson 28346827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 283578007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 283630d239bcSRobert Watson COUNTER_INC(vnode_check_setflags); 2837250ee706SRobert Watson 2838d8a7b7a3SRobert Watson return (0); 2839d8a7b7a3SRobert Watson } 2840d8a7b7a3SRobert Watson 284130d239bcSRobert Watson COUNTER_DECL(vnode_check_setmode); 2842d8a7b7a3SRobert Watson static int 28433f1a7a90SRobert Watson test_vnode_check_setmode(struct ucred *cred, struct vnode *vp, 284478007886SRobert Watson struct label *vplabel, mode_t mode) 2845d8a7b7a3SRobert Watson { 2846d8a7b7a3SRobert Watson 28476827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 284878007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 284930d239bcSRobert Watson COUNTER_INC(vnode_check_setmode); 2850250ee706SRobert Watson 2851d8a7b7a3SRobert Watson return (0); 2852d8a7b7a3SRobert Watson } 2853d8a7b7a3SRobert Watson 285430d239bcSRobert Watson COUNTER_DECL(vnode_check_setowner); 2855d8a7b7a3SRobert Watson static int 28563f1a7a90SRobert Watson test_vnode_check_setowner(struct ucred *cred, struct vnode *vp, 285778007886SRobert Watson struct label *vplabel, uid_t uid, gid_t gid) 2858d8a7b7a3SRobert Watson { 2859d8a7b7a3SRobert Watson 28606827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 286178007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 286230d239bcSRobert Watson COUNTER_INC(vnode_check_setowner); 2863250ee706SRobert Watson 2864d8a7b7a3SRobert Watson return (0); 2865d8a7b7a3SRobert Watson } 2866d8a7b7a3SRobert Watson 286730d239bcSRobert Watson COUNTER_DECL(vnode_check_setutimes); 2868d8a7b7a3SRobert Watson static int 28693f1a7a90SRobert Watson test_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, 287078007886SRobert Watson struct label *vplabel, struct timespec atime, struct timespec mtime) 2871d8a7b7a3SRobert Watson { 2872d8a7b7a3SRobert Watson 28736827d029SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 287478007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 287530d239bcSRobert Watson COUNTER_INC(vnode_check_setutimes); 2876250ee706SRobert Watson 2877d8a7b7a3SRobert Watson return (0); 2878d8a7b7a3SRobert Watson } 2879d8a7b7a3SRobert Watson 288030d239bcSRobert Watson COUNTER_DECL(vnode_check_stat); 2881d8a7b7a3SRobert Watson static int 28823f1a7a90SRobert Watson test_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, 288378007886SRobert Watson struct vnode *vp, struct label *vplabel) 2884d8a7b7a3SRobert Watson { 2885d8a7b7a3SRobert Watson 28866827d029SRobert Watson LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 28876827d029SRobert Watson if (file_cred != NULL) 28886827d029SRobert Watson LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 288978007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 289030d239bcSRobert Watson COUNTER_INC(vnode_check_stat); 2891250ee706SRobert Watson 2892d8a7b7a3SRobert Watson return (0); 2893d8a7b7a3SRobert Watson } 2894d8a7b7a3SRobert Watson 289530d239bcSRobert Watson COUNTER_DECL(vnode_check_unlink); 289645e0f3d6SRobert Watson static int 28973f1a7a90SRobert Watson test_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, 289845e0f3d6SRobert Watson struct label *dvplabel, struct vnode *vp, struct label *vplabel, 289945e0f3d6SRobert Watson struct componentname *cnp) 290045e0f3d6SRobert Watson { 290145e0f3d6SRobert Watson 290245e0f3d6SRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 290345e0f3d6SRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 290445e0f3d6SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 290530d239bcSRobert Watson COUNTER_INC(vnode_check_unlink); 290645e0f3d6SRobert Watson 290745e0f3d6SRobert Watson return (0); 290845e0f3d6SRobert Watson } 290945e0f3d6SRobert Watson 291030d239bcSRobert Watson COUNTER_DECL(vnode_check_write); 29117f724f8bSRobert Watson static int 29123f1a7a90SRobert Watson test_vnode_check_write(struct ucred *active_cred, 291378007886SRobert Watson struct ucred *file_cred, struct vnode *vp, struct label *vplabel) 29147f724f8bSRobert Watson { 29157f724f8bSRobert Watson 29166827d029SRobert Watson LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 29176827d029SRobert Watson if (file_cred != NULL) 29186827d029SRobert Watson LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 291978007886SRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 292030d239bcSRobert Watson COUNTER_INC(vnode_check_write); 2921250ee706SRobert Watson 29227f724f8bSRobert Watson return (0); 29237f724f8bSRobert Watson } 29247f724f8bSRobert Watson 2925eb320b0eSRobert Watson COUNTER_DECL(vnode_copy_label); 2926eb320b0eSRobert Watson static void 2927eb320b0eSRobert Watson test_vnode_copy_label(struct label *src, struct label *dest) 2928eb320b0eSRobert Watson { 2929eb320b0eSRobert Watson 2930eb320b0eSRobert Watson LABEL_CHECK(src, MAGIC_VNODE); 2931eb320b0eSRobert Watson LABEL_CHECK(dest, MAGIC_VNODE); 2932eb320b0eSRobert Watson COUNTER_INC(vnode_copy_label); 2933eb320b0eSRobert Watson } 2934eb320b0eSRobert Watson 2935eb320b0eSRobert Watson COUNTER_DECL(vnode_create_extattr); 2936eb320b0eSRobert Watson static int 2937eb320b0eSRobert Watson test_vnode_create_extattr(struct ucred *cred, struct mount *mp, 2938eb320b0eSRobert Watson struct label *mplabel, struct vnode *dvp, struct label *dvplabel, 2939eb320b0eSRobert Watson struct vnode *vp, struct label *vplabel, struct componentname *cnp) 2940eb320b0eSRobert Watson { 2941eb320b0eSRobert Watson 2942eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2943eb320b0eSRobert Watson LABEL_CHECK(mplabel, MAGIC_MOUNT); 2944eb320b0eSRobert Watson LABEL_CHECK(dvplabel, MAGIC_VNODE); 2945eb320b0eSRobert Watson COUNTER_INC(vnode_create_extattr); 2946eb320b0eSRobert Watson 2947eb320b0eSRobert Watson return (0); 2948eb320b0eSRobert Watson } 2949eb320b0eSRobert Watson 2950eb320b0eSRobert Watson COUNTER_DECL(vnode_destroy_label); 2951eb320b0eSRobert Watson static void 2952eb320b0eSRobert Watson test_vnode_destroy_label(struct label *label) 2953eb320b0eSRobert Watson { 2954eb320b0eSRobert Watson 2955eb320b0eSRobert Watson LABEL_DESTROY(label, MAGIC_VNODE); 2956eb320b0eSRobert Watson COUNTER_INC(vnode_destroy_label); 2957eb320b0eSRobert Watson } 2958eb320b0eSRobert Watson 2959eb320b0eSRobert Watson COUNTER_DECL(vnode_execve_transition); 2960eb320b0eSRobert Watson static void 2961eb320b0eSRobert Watson test_vnode_execve_transition(struct ucred *old, struct ucred *new, 2962eb320b0eSRobert Watson struct vnode *vp, struct label *filelabel, 2963eb320b0eSRobert Watson struct label *interpvplabel, struct image_params *imgp, 2964eb320b0eSRobert Watson struct label *execlabel) 2965eb320b0eSRobert Watson { 2966eb320b0eSRobert Watson 2967eb320b0eSRobert Watson LABEL_CHECK(old->cr_label, MAGIC_CRED); 2968eb320b0eSRobert Watson LABEL_CHECK(new->cr_label, MAGIC_CRED); 2969eb320b0eSRobert Watson LABEL_CHECK(filelabel, MAGIC_VNODE); 2970eb320b0eSRobert Watson LABEL_CHECK(interpvplabel, MAGIC_VNODE); 2971eb320b0eSRobert Watson LABEL_CHECK(execlabel, MAGIC_CRED); 2972eb320b0eSRobert Watson COUNTER_INC(vnode_execve_transition); 2973eb320b0eSRobert Watson } 2974eb320b0eSRobert Watson 2975eb320b0eSRobert Watson COUNTER_DECL(vnode_execve_will_transition); 2976eb320b0eSRobert Watson static int 2977eb320b0eSRobert Watson test_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, 2978eb320b0eSRobert Watson struct label *filelabel, struct label *interpvplabel, 2979eb320b0eSRobert Watson struct image_params *imgp, struct label *execlabel) 2980eb320b0eSRobert Watson { 2981eb320b0eSRobert Watson 2982eb320b0eSRobert Watson LABEL_CHECK(old->cr_label, MAGIC_CRED); 2983eb320b0eSRobert Watson LABEL_CHECK(filelabel, MAGIC_VNODE); 2984eb320b0eSRobert Watson LABEL_CHECK(interpvplabel, MAGIC_VNODE); 2985eb320b0eSRobert Watson LABEL_CHECK(execlabel, MAGIC_CRED); 2986eb320b0eSRobert Watson COUNTER_INC(vnode_execve_will_transition); 2987eb320b0eSRobert Watson 2988eb320b0eSRobert Watson return (0); 2989eb320b0eSRobert Watson } 2990eb320b0eSRobert Watson 2991eb320b0eSRobert Watson COUNTER_DECL(vnode_externalize_label); 2992eb320b0eSRobert Watson static int 2993eb320b0eSRobert Watson test_vnode_externalize_label(struct label *label, char *element_name, 2994eb320b0eSRobert Watson struct sbuf *sb, int *claimed) 2995eb320b0eSRobert Watson { 2996eb320b0eSRobert Watson 2997eb320b0eSRobert Watson LABEL_CHECK(label, MAGIC_VNODE); 2998eb320b0eSRobert Watson COUNTER_INC(vnode_externalize_label); 2999eb320b0eSRobert Watson 3000eb320b0eSRobert Watson return (0); 3001eb320b0eSRobert Watson } 3002eb320b0eSRobert Watson 3003eb320b0eSRobert Watson COUNTER_DECL(vnode_init_label); 3004eb320b0eSRobert Watson static void 3005eb320b0eSRobert Watson test_vnode_init_label(struct label *label) 3006eb320b0eSRobert Watson { 3007eb320b0eSRobert Watson 3008eb320b0eSRobert Watson LABEL_INIT(label, MAGIC_VNODE); 3009eb320b0eSRobert Watson COUNTER_INC(vnode_init_label); 3010eb320b0eSRobert Watson } 3011eb320b0eSRobert Watson 30121876fb21SRobert Watson COUNTER_DECL(vnode_internalize_label); 30131876fb21SRobert Watson static int 30141876fb21SRobert Watson test_vnode_internalize_label(struct label *label, char *element_name, 30151876fb21SRobert Watson char *element_data, int *claimed) 30161876fb21SRobert Watson { 30171876fb21SRobert Watson 30181876fb21SRobert Watson LABEL_CHECK(label, MAGIC_VNODE); 30191876fb21SRobert Watson COUNTER_INC(vnode_internalize_label); 30201876fb21SRobert Watson 30211876fb21SRobert Watson return (0); 30221876fb21SRobert Watson } 30231876fb21SRobert Watson 3024eb320b0eSRobert Watson COUNTER_DECL(vnode_relabel); 3025eb320b0eSRobert Watson static void 3026eb320b0eSRobert Watson test_vnode_relabel(struct ucred *cred, struct vnode *vp, 3027eb320b0eSRobert Watson struct label *vplabel, struct label *label) 3028eb320b0eSRobert Watson { 3029eb320b0eSRobert Watson 3030eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3031eb320b0eSRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 3032eb320b0eSRobert Watson LABEL_CHECK(label, MAGIC_VNODE); 3033eb320b0eSRobert Watson COUNTER_INC(vnode_relabel); 3034eb320b0eSRobert Watson } 3035eb320b0eSRobert Watson 3036eb320b0eSRobert Watson COUNTER_DECL(vnode_setlabel_extattr); 3037eb320b0eSRobert Watson static int 3038eb320b0eSRobert Watson test_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, 3039eb320b0eSRobert Watson struct label *vplabel, struct label *intlabel) 3040eb320b0eSRobert Watson { 3041eb320b0eSRobert Watson 3042eb320b0eSRobert Watson LABEL_CHECK(cred->cr_label, MAGIC_CRED); 3043eb320b0eSRobert Watson LABEL_CHECK(vplabel, MAGIC_VNODE); 3044eb320b0eSRobert Watson LABEL_CHECK(intlabel, MAGIC_VNODE); 3045eb320b0eSRobert Watson COUNTER_INC(vnode_setlabel_extattr); 3046eb320b0eSRobert Watson 3047eb320b0eSRobert Watson return (0); 3048eb320b0eSRobert Watson } 3049eb320b0eSRobert Watson 30503f1a7a90SRobert Watson static struct mac_policy_ops test_ops = 3051d8a7b7a3SRobert Watson { 3052eb320b0eSRobert Watson .mpo_bpfdesc_check_receive = test_bpfdesc_check_receive, 3053eb320b0eSRobert Watson .mpo_bpfdesc_create = test_bpfdesc_create, 3054eb320b0eSRobert Watson .mpo_bpfdesc_create_mbuf = test_bpfdesc_create_mbuf, 30553f1a7a90SRobert Watson .mpo_bpfdesc_destroy_label = test_bpfdesc_destroy_label, 3056eb320b0eSRobert Watson .mpo_bpfdesc_init_label = test_bpfdesc_init_label, 3057eb320b0eSRobert Watson 3058eb320b0eSRobert Watson .mpo_cred_check_relabel = test_cred_check_relabel, 30596f6174a7SRobert Watson .mpo_cred_check_setaudit = test_cred_check_setaudit, 30606f6174a7SRobert Watson .mpo_cred_check_setaudit_addr = test_cred_check_setaudit_addr, 30616f6174a7SRobert Watson .mpo_cred_check_setauid = test_cred_check_setauid, 3062*ddb3eb4eSOlivier Certner .mpo_cred_setcred_enter = test_cred_setcred_enter, 3063*ddb3eb4eSOlivier Certner .mpo_cred_check_setcred = test_cred_check_setcred, 3064*ddb3eb4eSOlivier Certner .mpo_cred_setcred_exit = test_cred_setcred_exit, 30656f6174a7SRobert Watson .mpo_cred_check_seteuid = test_cred_check_seteuid, 30666f6174a7SRobert Watson .mpo_cred_check_setegid = test_cred_check_setegid, 30676f6174a7SRobert Watson .mpo_cred_check_setgid = test_cred_check_setgid, 30686f6174a7SRobert Watson .mpo_cred_check_setgroups = test_cred_check_setgroups, 30696f6174a7SRobert Watson .mpo_cred_check_setregid = test_cred_check_setregid, 30706f6174a7SRobert Watson .mpo_cred_check_setresgid = test_cred_check_setresgid, 30716f6174a7SRobert Watson .mpo_cred_check_setresuid = test_cred_check_setresuid, 30726f6174a7SRobert Watson .mpo_cred_check_setreuid = test_cred_check_setreuid, 30736f6174a7SRobert Watson .mpo_cred_check_setuid = test_cred_check_setuid, 3074eb320b0eSRobert Watson .mpo_cred_check_visible = test_cred_check_visible, 30753f1a7a90SRobert Watson .mpo_cred_copy_label = test_cred_copy_label, 3076212ab0cfSRobert Watson .mpo_cred_create_init = test_cred_create_init, 3077212ab0cfSRobert Watson .mpo_cred_create_swapper = test_cred_create_swapper, 3078eb320b0eSRobert Watson .mpo_cred_destroy_label = test_cred_destroy_label, 3079b0f4c777SRobert Watson .mpo_cred_externalize_label = test_cred_externalize_label, 3080eb320b0eSRobert Watson .mpo_cred_init_label = test_cred_init_label, 30811876fb21SRobert Watson .mpo_cred_internalize_label = test_cred_internalize_label, 3082eb320b0eSRobert Watson .mpo_cred_relabel = test_cred_relabel, 3083eb320b0eSRobert Watson 30842449b9e5SMitchell Horne .mpo_ddb_command_exec = test_ddb_command_exec, 30852449b9e5SMitchell Horne .mpo_ddb_command_register = test_ddb_command_register, 30862449b9e5SMitchell Horne 30873f1a7a90SRobert Watson .mpo_devfs_create_device = test_devfs_create_device, 30883f1a7a90SRobert Watson .mpo_devfs_create_directory = test_devfs_create_directory, 30893f1a7a90SRobert Watson .mpo_devfs_create_symlink = test_devfs_create_symlink, 3090eb320b0eSRobert Watson .mpo_devfs_destroy_label = test_devfs_destroy_label, 3091eb320b0eSRobert Watson .mpo_devfs_init_label = test_devfs_init_label, 30923f1a7a90SRobert Watson .mpo_devfs_update = test_devfs_update, 3093eb320b0eSRobert Watson .mpo_devfs_vnode_associate = test_devfs_vnode_associate, 3094eb320b0eSRobert Watson 30953f1a7a90SRobert Watson .mpo_ifnet_check_relabel = test_ifnet_check_relabel, 30963f1a7a90SRobert Watson .mpo_ifnet_check_transmit = test_ifnet_check_transmit, 3097eb320b0eSRobert Watson .mpo_ifnet_copy_label = test_ifnet_copy_label, 3098eb320b0eSRobert Watson .mpo_ifnet_create = test_ifnet_create, 3099eb320b0eSRobert Watson .mpo_ifnet_create_mbuf = test_ifnet_create_mbuf, 3100eb320b0eSRobert Watson .mpo_ifnet_destroy_label = test_ifnet_destroy_label, 3101eb320b0eSRobert Watson .mpo_ifnet_externalize_label = test_ifnet_externalize_label, 3102eb320b0eSRobert Watson .mpo_ifnet_init_label = test_ifnet_init_label, 31031876fb21SRobert Watson .mpo_ifnet_internalize_label = test_ifnet_internalize_label, 3104eb320b0eSRobert Watson .mpo_ifnet_relabel = test_ifnet_relabel, 3105eb320b0eSRobert Watson 3106eb320b0eSRobert Watson .mpo_syncache_destroy_label = test_syncache_destroy_label, 3107eb320b0eSRobert Watson .mpo_syncache_init_label = test_syncache_init_label, 3108eb320b0eSRobert Watson 3109eb320b0eSRobert Watson .mpo_sysvmsg_destroy_label = test_sysvmsg_destroy_label, 3110eb320b0eSRobert Watson .mpo_sysvmsg_init_label = test_sysvmsg_init_label, 3111eb320b0eSRobert Watson 3112eb320b0eSRobert Watson .mpo_sysvmsq_destroy_label = test_sysvmsq_destroy_label, 3113eb320b0eSRobert Watson .mpo_sysvmsq_init_label = test_sysvmsq_init_label, 3114eb320b0eSRobert Watson 3115eb320b0eSRobert Watson .mpo_sysvsem_destroy_label = test_sysvsem_destroy_label, 3116eb320b0eSRobert Watson .mpo_sysvsem_init_label = test_sysvsem_init_label, 3117eb320b0eSRobert Watson 3118eb320b0eSRobert Watson .mpo_sysvshm_destroy_label = test_sysvshm_destroy_label, 3119eb320b0eSRobert Watson .mpo_sysvshm_init_label = test_sysvshm_init_label, 3120eb320b0eSRobert Watson 31213f1a7a90SRobert Watson .mpo_inpcb_check_deliver = test_inpcb_check_deliver, 31227fb179baSBjoern A. Zeeb .mpo_inpcb_check_visible = test_inpcb_check_visible, 3123eb320b0eSRobert Watson .mpo_inpcb_create = test_inpcb_create, 3124eb320b0eSRobert Watson .mpo_inpcb_create_mbuf = test_inpcb_create_mbuf, 3125eb320b0eSRobert Watson .mpo_inpcb_destroy_label = test_inpcb_destroy_label, 3126eb320b0eSRobert Watson .mpo_inpcb_init_label = test_inpcb_init_label, 3127eb320b0eSRobert Watson .mpo_inpcb_sosetlabel = test_inpcb_sosetlabel, 3128eb320b0eSRobert Watson 3129048e1287SRobert Watson .mpo_ip6q_create = test_ip6q_create, 3130048e1287SRobert Watson .mpo_ip6q_destroy_label = test_ip6q_destroy_label, 3131048e1287SRobert Watson .mpo_ip6q_init_label = test_ip6q_init_label, 3132048e1287SRobert Watson .mpo_ip6q_match = test_ip6q_match, 3133048e1287SRobert Watson .mpo_ip6q_reassemble = test_ip6q_reassemble, 3134048e1287SRobert Watson .mpo_ip6q_update = test_ip6q_update, 3135048e1287SRobert Watson 3136eb320b0eSRobert Watson .mpo_ipq_create = test_ipq_create, 3137eb320b0eSRobert Watson .mpo_ipq_destroy_label = test_ipq_destroy_label, 3138eb320b0eSRobert Watson .mpo_ipq_init_label = test_ipq_init_label, 3139eb320b0eSRobert Watson .mpo_ipq_match = test_ipq_match, 3140eb320b0eSRobert Watson .mpo_ipq_reassemble = test_ipq_reassemble, 3141eb320b0eSRobert Watson .mpo_ipq_update = test_ipq_update, 3142eb320b0eSRobert Watson 31432449b9e5SMitchell Horne .mpo_kdb_check_backend = test_kdb_check_backend, 31442449b9e5SMitchell Horne 31453f1a7a90SRobert Watson .mpo_kenv_check_dump = test_kenv_check_dump, 31463f1a7a90SRobert Watson .mpo_kenv_check_get = test_kenv_check_get, 31473f1a7a90SRobert Watson .mpo_kenv_check_set = test_kenv_check_set, 31483f1a7a90SRobert Watson .mpo_kenv_check_unset = test_kenv_check_unset, 3149eb320b0eSRobert Watson 31503f1a7a90SRobert Watson .mpo_kld_check_load = test_kld_check_load, 31513f1a7a90SRobert Watson .mpo_kld_check_stat = test_kld_check_stat, 3152eb320b0eSRobert Watson 3153eb320b0eSRobert Watson .mpo_mbuf_copy_label = test_mbuf_copy_label, 3154eb320b0eSRobert Watson .mpo_mbuf_destroy_label = test_mbuf_destroy_label, 3155eb320b0eSRobert Watson .mpo_mbuf_init_label = test_mbuf_init_label, 3156eb320b0eSRobert Watson 31573f1a7a90SRobert Watson .mpo_mount_check_stat = test_mount_check_stat, 3158eb320b0eSRobert Watson .mpo_mount_create = test_mount_create, 3159eb320b0eSRobert Watson .mpo_mount_destroy_label = test_mount_destroy_label, 3160eb320b0eSRobert Watson .mpo_mount_init_label = test_mount_init_label, 3161eb320b0eSRobert Watson 3162eb320b0eSRobert Watson .mpo_netinet_arp_send = test_netinet_arp_send, 3163eb320b0eSRobert Watson .mpo_netinet_fragment = test_netinet_fragment, 3164eb320b0eSRobert Watson .mpo_netinet_icmp_reply = test_netinet_icmp_reply, 3165eb320b0eSRobert Watson .mpo_netinet_icmp_replyinplace = test_netinet_icmp_replyinplace, 3166eb320b0eSRobert Watson .mpo_netinet_igmp_send = test_netinet_igmp_send, 3167eb320b0eSRobert Watson .mpo_netinet_tcp_reply = test_netinet_tcp_reply, 3168eb320b0eSRobert Watson 3169eb320b0eSRobert Watson .mpo_netinet6_nd6_send = test_netinet6_nd6_send, 3170eb320b0eSRobert Watson 31713f1a7a90SRobert Watson .mpo_pipe_check_ioctl = test_pipe_check_ioctl, 31723f1a7a90SRobert Watson .mpo_pipe_check_poll = test_pipe_check_poll, 31733f1a7a90SRobert Watson .mpo_pipe_check_read = test_pipe_check_read, 31743f1a7a90SRobert Watson .mpo_pipe_check_relabel = test_pipe_check_relabel, 31753f1a7a90SRobert Watson .mpo_pipe_check_stat = test_pipe_check_stat, 31763f1a7a90SRobert Watson .mpo_pipe_check_write = test_pipe_check_write, 3177eb320b0eSRobert Watson .mpo_pipe_copy_label = test_pipe_copy_label, 3178eb320b0eSRobert Watson .mpo_pipe_create = test_pipe_create, 3179eb320b0eSRobert Watson .mpo_pipe_destroy_label = test_pipe_destroy_label, 3180eb320b0eSRobert Watson .mpo_pipe_externalize_label = test_pipe_externalize_label, 3181eb320b0eSRobert Watson .mpo_pipe_init_label = test_pipe_init_label, 31821876fb21SRobert Watson .mpo_pipe_internalize_label = test_pipe_internalize_label, 3183eb320b0eSRobert Watson .mpo_pipe_relabel = test_pipe_relabel, 3184eb320b0eSRobert Watson 3185438aeadfSRobert Watson .mpo_posixsem_check_getvalue = test_posixsem_check_getvalue, 3186438aeadfSRobert Watson .mpo_posixsem_check_open = test_posixsem_check_open, 3187438aeadfSRobert Watson .mpo_posixsem_check_post = test_posixsem_check_post, 31889c00bb91SKonstantin Belousov .mpo_posixsem_check_setmode = test_posixsem_check_setmode, 31899c00bb91SKonstantin Belousov .mpo_posixsem_check_setowner = test_posixsem_check_setowner, 31906bc1e9cdSJohn Baldwin .mpo_posixsem_check_stat = test_posixsem_check_stat, 3191438aeadfSRobert Watson .mpo_posixsem_check_unlink = test_posixsem_check_unlink, 3192438aeadfSRobert Watson .mpo_posixsem_check_wait = test_posixsem_check_wait, 3193eb320b0eSRobert Watson .mpo_posixsem_create = test_posixsem_create, 3194eb320b0eSRobert Watson .mpo_posixsem_destroy_label = test_posixsem_destroy_label, 3195eb320b0eSRobert Watson .mpo_posixsem_init_label = test_posixsem_init_label, 3196eb320b0eSRobert Watson 31979b6dd12eSRobert Watson .mpo_posixshm_check_create = test_posixshm_check_create, 31988e38aeffSJohn Baldwin .mpo_posixshm_check_mmap = test_posixshm_check_mmap, 31998e38aeffSJohn Baldwin .mpo_posixshm_check_open = test_posixshm_check_open, 3200940cb0e2SKonstantin Belousov .mpo_posixshm_check_read = test_posixshm_check_read, 32019c00bb91SKonstantin Belousov .mpo_posixshm_check_setmode = test_posixshm_check_setmode, 32029c00bb91SKonstantin Belousov .mpo_posixshm_check_setowner = test_posixshm_check_setowner, 32038e38aeffSJohn Baldwin .mpo_posixshm_check_stat = test_posixshm_check_stat, 32048e38aeffSJohn Baldwin .mpo_posixshm_check_truncate = test_posixshm_check_truncate, 32058e38aeffSJohn Baldwin .mpo_posixshm_check_unlink = test_posixshm_check_unlink, 3206940cb0e2SKonstantin Belousov .mpo_posixshm_check_write = test_posixshm_check_write, 32078e38aeffSJohn Baldwin .mpo_posixshm_create = test_posixshm_create, 32088e38aeffSJohn Baldwin .mpo_posixshm_destroy_label = test_posixshm_destroy_label, 32098e38aeffSJohn Baldwin .mpo_posixshm_init_label = test_posixshm_init_label, 32108e38aeffSJohn Baldwin 32113f1a7a90SRobert Watson .mpo_proc_check_debug = test_proc_check_debug, 32123f1a7a90SRobert Watson .mpo_proc_check_sched = test_proc_check_sched, 32133f1a7a90SRobert Watson .mpo_proc_check_signal = test_proc_check_signal, 32143f1a7a90SRobert Watson .mpo_proc_check_wait = test_proc_check_wait, 3215eb320b0eSRobert Watson .mpo_proc_destroy_label = test_proc_destroy_label, 3216eb320b0eSRobert Watson .mpo_proc_init_label = test_proc_init_label, 3217eb320b0eSRobert Watson 32183f1a7a90SRobert Watson .mpo_socket_check_accept = test_socket_check_accept, 32193f1a7a90SRobert Watson .mpo_socket_check_bind = test_socket_check_bind, 32203f1a7a90SRobert Watson .mpo_socket_check_connect = test_socket_check_connect, 32213f1a7a90SRobert Watson .mpo_socket_check_deliver = test_socket_check_deliver, 32223f1a7a90SRobert Watson .mpo_socket_check_listen = test_socket_check_listen, 32233f1a7a90SRobert Watson .mpo_socket_check_poll = test_socket_check_poll, 32243f1a7a90SRobert Watson .mpo_socket_check_receive = test_socket_check_receive, 32253f1a7a90SRobert Watson .mpo_socket_check_relabel = test_socket_check_relabel, 32263f1a7a90SRobert Watson .mpo_socket_check_send = test_socket_check_send, 32273f1a7a90SRobert Watson .mpo_socket_check_stat = test_socket_check_stat, 32283f1a7a90SRobert Watson .mpo_socket_check_visible = test_socket_check_visible, 3229eb320b0eSRobert Watson .mpo_socket_copy_label = test_socket_copy_label, 3230eb320b0eSRobert Watson .mpo_socket_create = test_socket_create, 3231eb320b0eSRobert Watson .mpo_socket_create_mbuf = test_socket_create_mbuf, 3232eb320b0eSRobert Watson .mpo_socket_destroy_label = test_socket_destroy_label, 3233eb320b0eSRobert Watson .mpo_socket_externalize_label = test_socket_externalize_label, 3234eb320b0eSRobert Watson .mpo_socket_init_label = test_socket_init_label, 32351876fb21SRobert Watson .mpo_socket_internalize_label = test_socket_internalize_label, 3236eb320b0eSRobert Watson .mpo_socket_newconn = test_socket_newconn, 3237eb320b0eSRobert Watson .mpo_socket_relabel = test_socket_relabel, 3238eb320b0eSRobert Watson 3239eb320b0eSRobert Watson .mpo_socketpeer_destroy_label = test_socketpeer_destroy_label, 3240eb320b0eSRobert Watson .mpo_socketpeer_externalize_label = test_socketpeer_externalize_label, 3241eb320b0eSRobert Watson .mpo_socketpeer_init_label = test_socketpeer_init_label, 3242eb320b0eSRobert Watson .mpo_socketpeer_set_from_mbuf = test_socketpeer_set_from_mbuf, 3243eb320b0eSRobert Watson .mpo_socketpeer_set_from_socket = test_socketpeer_set_from_socket, 3244eb320b0eSRobert Watson 3245eb320b0eSRobert Watson .mpo_syncache_create = test_syncache_create, 3246eb320b0eSRobert Watson .mpo_syncache_create_mbuf = test_syncache_create_mbuf, 3247eb320b0eSRobert Watson 32483f1a7a90SRobert Watson .mpo_system_check_acct = test_system_check_acct, 32493f1a7a90SRobert Watson .mpo_system_check_audit = test_system_check_audit, 32503f1a7a90SRobert Watson .mpo_system_check_auditctl = test_system_check_auditctl, 32513f1a7a90SRobert Watson .mpo_system_check_auditon = test_system_check_auditon, 32523f1a7a90SRobert Watson .mpo_system_check_reboot = test_system_check_reboot, 32533f1a7a90SRobert Watson .mpo_system_check_swapoff = test_system_check_swapoff, 32543f1a7a90SRobert Watson .mpo_system_check_swapon = test_system_check_swapon, 32553f1a7a90SRobert Watson .mpo_system_check_sysctl = test_system_check_sysctl, 3256eb320b0eSRobert Watson 32573f1a7a90SRobert Watson .mpo_vnode_check_access = test_vnode_check_access, 3258eb320b0eSRobert Watson .mpo_sysvmsg_cleanup = test_sysvmsg_cleanup, 3259eb320b0eSRobert Watson .mpo_sysvmsg_create = test_sysvmsg_create, 3260eb320b0eSRobert Watson 3261eb320b0eSRobert Watson .mpo_sysvmsq_check_msgmsq = test_sysvmsq_check_msgmsq, 3262eb320b0eSRobert Watson .mpo_sysvmsq_check_msgrcv = test_sysvmsq_check_msgrcv, 3263eb320b0eSRobert Watson .mpo_sysvmsq_check_msgrmid = test_sysvmsq_check_msgrmid, 3264eb320b0eSRobert Watson .mpo_sysvmsq_check_msqget = test_sysvmsq_check_msqget, 3265eb320b0eSRobert Watson .mpo_sysvmsq_check_msqsnd = test_sysvmsq_check_msqsnd, 3266eb320b0eSRobert Watson .mpo_sysvmsq_check_msqrcv = test_sysvmsq_check_msqrcv, 3267eb320b0eSRobert Watson .mpo_sysvmsq_check_msqctl = test_sysvmsq_check_msqctl, 3268eb320b0eSRobert Watson .mpo_sysvmsq_cleanup = test_sysvmsq_cleanup, 3269eb320b0eSRobert Watson .mpo_sysvmsq_create = test_sysvmsq_create, 3270eb320b0eSRobert Watson 3271eb320b0eSRobert Watson .mpo_sysvsem_check_semctl = test_sysvsem_check_semctl, 3272eb320b0eSRobert Watson .mpo_sysvsem_check_semget = test_sysvsem_check_semget, 3273eb320b0eSRobert Watson .mpo_sysvsem_check_semop = test_sysvsem_check_semop, 3274eb320b0eSRobert Watson .mpo_sysvsem_cleanup = test_sysvsem_cleanup, 3275eb320b0eSRobert Watson .mpo_sysvsem_create = test_sysvsem_create, 3276eb320b0eSRobert Watson 3277eb320b0eSRobert Watson .mpo_sysvshm_check_shmat = test_sysvshm_check_shmat, 3278eb320b0eSRobert Watson .mpo_sysvshm_check_shmctl = test_sysvshm_check_shmctl, 3279eb320b0eSRobert Watson .mpo_sysvshm_check_shmdt = test_sysvshm_check_shmdt, 3280eb320b0eSRobert Watson .mpo_sysvshm_check_shmget = test_sysvshm_check_shmget, 3281eb320b0eSRobert Watson .mpo_sysvshm_cleanup = test_sysvshm_cleanup, 3282eb320b0eSRobert Watson .mpo_sysvshm_create = test_sysvshm_create, 3283eb320b0eSRobert Watson 3284eb320b0eSRobert Watson .mpo_thread_userret = test_thread_userret, 3285eb320b0eSRobert Watson 3286eb320b0eSRobert Watson .mpo_vnode_associate_extattr = test_vnode_associate_extattr, 3287eb320b0eSRobert Watson .mpo_vnode_associate_singlelabel = test_vnode_associate_singlelabel, 32883f1a7a90SRobert Watson .mpo_vnode_check_chdir = test_vnode_check_chdir, 32893f1a7a90SRobert Watson .mpo_vnode_check_chroot = test_vnode_check_chroot, 32903f1a7a90SRobert Watson .mpo_vnode_check_create = test_vnode_check_create, 32913f1a7a90SRobert Watson .mpo_vnode_check_deleteacl = test_vnode_check_deleteacl, 32923f1a7a90SRobert Watson .mpo_vnode_check_deleteextattr = test_vnode_check_deleteextattr, 32933f1a7a90SRobert Watson .mpo_vnode_check_exec = test_vnode_check_exec, 32943f1a7a90SRobert Watson .mpo_vnode_check_getacl = test_vnode_check_getacl, 32953f1a7a90SRobert Watson .mpo_vnode_check_getextattr = test_vnode_check_getextattr, 32963f1a7a90SRobert Watson .mpo_vnode_check_link = test_vnode_check_link, 32973f1a7a90SRobert Watson .mpo_vnode_check_listextattr = test_vnode_check_listextattr, 32983f1a7a90SRobert Watson .mpo_vnode_check_lookup = test_vnode_check_lookup, 32993f1a7a90SRobert Watson .mpo_vnode_check_mmap = test_vnode_check_mmap, 33003f1a7a90SRobert Watson .mpo_vnode_check_open = test_vnode_check_open, 33013f1a7a90SRobert Watson .mpo_vnode_check_poll = test_vnode_check_poll, 33023f1a7a90SRobert Watson .mpo_vnode_check_read = test_vnode_check_read, 33033f1a7a90SRobert Watson .mpo_vnode_check_readdir = test_vnode_check_readdir, 33043f1a7a90SRobert Watson .mpo_vnode_check_readlink = test_vnode_check_readlink, 33053f1a7a90SRobert Watson .mpo_vnode_check_relabel = test_vnode_check_relabel, 33063f1a7a90SRobert Watson .mpo_vnode_check_rename_from = test_vnode_check_rename_from, 33073f1a7a90SRobert Watson .mpo_vnode_check_rename_to = test_vnode_check_rename_to, 33083f1a7a90SRobert Watson .mpo_vnode_check_revoke = test_vnode_check_revoke, 33093f1a7a90SRobert Watson .mpo_vnode_check_setacl = test_vnode_check_setacl, 33103f1a7a90SRobert Watson .mpo_vnode_check_setextattr = test_vnode_check_setextattr, 33113f1a7a90SRobert Watson .mpo_vnode_check_setflags = test_vnode_check_setflags, 33123f1a7a90SRobert Watson .mpo_vnode_check_setmode = test_vnode_check_setmode, 33133f1a7a90SRobert Watson .mpo_vnode_check_setowner = test_vnode_check_setowner, 33143f1a7a90SRobert Watson .mpo_vnode_check_setutimes = test_vnode_check_setutimes, 33153f1a7a90SRobert Watson .mpo_vnode_check_stat = test_vnode_check_stat, 33163f1a7a90SRobert Watson .mpo_vnode_check_unlink = test_vnode_check_unlink, 33173f1a7a90SRobert Watson .mpo_vnode_check_write = test_vnode_check_write, 3318eb320b0eSRobert Watson .mpo_vnode_copy_label = test_vnode_copy_label, 3319eb320b0eSRobert Watson .mpo_vnode_create_extattr = test_vnode_create_extattr, 3320eb320b0eSRobert Watson .mpo_vnode_destroy_label = test_vnode_destroy_label, 3321eb320b0eSRobert Watson .mpo_vnode_execve_transition = test_vnode_execve_transition, 3322eb320b0eSRobert Watson .mpo_vnode_execve_will_transition = test_vnode_execve_will_transition, 3323eb320b0eSRobert Watson .mpo_vnode_externalize_label = test_vnode_externalize_label, 3324eb320b0eSRobert Watson .mpo_vnode_init_label = test_vnode_init_label, 33251876fb21SRobert Watson .mpo_vnode_internalize_label = test_vnode_internalize_label, 3326eb320b0eSRobert Watson .mpo_vnode_relabel = test_vnode_relabel, 3327eb320b0eSRobert Watson .mpo_vnode_setlabel_extattr = test_vnode_setlabel_extattr, 3328d8a7b7a3SRobert Watson }; 3329d8a7b7a3SRobert Watson 33303f1a7a90SRobert Watson MAC_POLICY_SET(&test_ops, mac_test, "TrustedBSD MAC/Test", 33319162f64bSRobert Watson MPC_LOADTIME_FLAG_UNLOADOK, &test_slot); 3332