1 /*- 2 * Copyright (c) 1999-2002, 2007-2009 Robert N. M. Watson 3 * Copyright (c) 2001-2005 McAfee, Inc. 4 * Copyright (c) 2006 SPARTA, Inc. 5 * Copyright (c) 2008 Apple Inc. 6 * All rights reserved. 7 * 8 * This software was developed by Robert Watson for the TrustedBSD Project. 9 * 10 * This software was developed for the FreeBSD Project in part by McAfee 11 * Research, the Security Research Division of McAfee, Inc. under 12 * DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the DARPA 13 * CHATS research program. 14 * 15 * This software was enhanced by SPARTA ISSO under SPAWAR contract 16 * N66001-04-C-6019 ("SEFOS"). 17 * 18 * This software was developed at the University of Cambridge Computer 19 * Laboratory with support from a grant from Google, Inc. 20 * 21 * Redistribution and use in source and binary forms, with or without 22 * modification, are permitted provided that the following conditions 23 * are met: 24 * 1. Redistributions of source code must retain the above copyright 25 * notice, this list of conditions and the following disclaimer. 26 * 2. Redistributions in binary form must reproduce the above copyright 27 * notice, this list of conditions and the following disclaimer in the 28 * documentation and/or other materials provided with the distribution. 29 * 30 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 36 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 * $FreeBSD$ 43 */ 44 45 /* 46 * Developed by the TrustedBSD Project. 47 * 48 * MAC Test policy - tests MAC Framework labeling by assigning object class 49 * magic numbers to each label and validates that each time an object label 50 * is passed into the policy, it has a consistent object type, catching 51 * incorrectly passed labels, labels passed after free, etc. 52 */ 53 54 #include <sys/param.h> 55 #include <sys/acl.h> 56 #include <sys/kdb.h> 57 #include <sys/kernel.h> 58 #include <sys/ksem.h> 59 #include <sys/malloc.h> 60 #include <sys/module.h> 61 #include <sys/mount.h> 62 #include <sys/msg.h> 63 #include <sys/proc.h> 64 #include <sys/vnode.h> 65 #include <sys/sem.h> 66 #include <sys/shm.h> 67 #include <sys/socket.h> 68 #include <sys/socketvar.h> 69 #include <sys/sx.h> 70 #include <sys/sysctl.h> 71 72 #include <fs/devfs/devfs.h> 73 74 #include <net/bpfdesc.h> 75 #include <net/if.h> 76 #include <net/if_types.h> 77 #include <net/if_var.h> 78 79 #include <security/mac/mac_policy.h> 80 81 SYSCTL_DECL(_security_mac); 82 83 SYSCTL_NODE(_security_mac, OID_AUTO, test, CTLFLAG_RW, 0, 84 "TrustedBSD mac_test policy controls"); 85 86 #define MAGIC_BPF 0xfe1ad1b6 87 #define MAGIC_DEVFS 0x9ee79c32 88 #define MAGIC_IFNET 0xc218b120 89 #define MAGIC_INPCB 0x4440f7bb 90 #define MAGIC_IP6Q 0x0870e1b7 91 #define MAGIC_IPQ 0x206188ef 92 #define MAGIC_MBUF 0xbbefa5bb 93 #define MAGIC_MOUNT 0xc7c46e47 94 #define MAGIC_SOCKET 0x9199c6cd 95 #define MAGIC_SYNCACHE 0x7fb838a8 96 #define MAGIC_SYSV_MSG 0x8bbba61e 97 #define MAGIC_SYSV_MSQ 0xea672391 98 #define MAGIC_SYSV_SEM 0x896e8a0b 99 #define MAGIC_SYSV_SHM 0x76119ab0 100 #define MAGIC_PIPE 0xdc6c9919 101 #define MAGIC_POSIX_SEM 0x78ae980c 102 #define MAGIC_POSIX_SHM 0x4e853fc9 103 #define MAGIC_PROC 0x3b4be98f 104 #define MAGIC_CRED 0x9a5a4987 105 #define MAGIC_VNODE 0x1a67a45c 106 #define MAGIC_FREE 0x849ba1fd 107 108 #define SLOT(x) mac_label_get((x), test_slot) 109 #define SLOT_SET(x, v) mac_label_set((x), test_slot, (v)) 110 111 static int test_slot; 112 SYSCTL_INT(_security_mac_test, OID_AUTO, slot, CTLFLAG_RD, 113 &test_slot, 0, "Slot allocated by framework"); 114 115 SYSCTL_NODE(_security_mac_test, OID_AUTO, counter, CTLFLAG_RW, 0, 116 "TrustedBSD mac_test counters controls"); 117 118 #define COUNTER_DECL(variable) \ 119 static int counter_##variable; \ 120 SYSCTL_INT(_security_mac_test_counter, OID_AUTO, variable, \ 121 CTLFLAG_RD, &counter_##variable, 0, #variable) 122 123 #define COUNTER_INC(variable) atomic_add_int(&counter_##variable, 1) 124 125 #ifdef KDB 126 #define DEBUGGER(func, string) kdb_enter(KDB_WHY_MAC, (string)) 127 #else 128 #define DEBUGGER(func, string) printf("mac_test: %s: %s\n", (func), (string)) 129 #endif 130 131 #define LABEL_CHECK(label, magic) do { \ 132 if (label != NULL) { \ 133 KASSERT(SLOT(label) == magic || SLOT(label) == 0, \ 134 ("%s: bad %s label", __func__, #magic)); \ 135 } \ 136 } while (0) 137 138 #define LABEL_DESTROY(label, magic) do { \ 139 if (SLOT(label) == magic || SLOT(label) == 0) { \ 140 SLOT_SET(label, MAGIC_FREE); \ 141 } else if (SLOT(label) == MAGIC_FREE) { \ 142 DEBUGGER("%s: dup destroy", __func__); \ 143 } else { \ 144 DEBUGGER("%s: corrupted label", __func__); \ 145 } \ 146 } while (0) 147 148 #define LABEL_INIT(label, magic) do { \ 149 SLOT_SET(label, magic); \ 150 } while (0) 151 152 #define LABEL_NOTFREE(label) do { \ 153 KASSERT(SLOT(label) != MAGIC_FREE, \ 154 ("%s: destroyed label", __func__)); \ 155 } while (0) 156 157 /* 158 * Object-specific entry point implementations are sorted alphabetically by 159 * object type name and then by operation. 160 */ 161 COUNTER_DECL(bpfdesc_check_receive); 162 static int 163 test_bpfdesc_check_receive(struct bpf_d *d, struct label *dlabel, 164 struct ifnet *ifp, struct label *ifplabel) 165 { 166 167 LABEL_CHECK(dlabel, MAGIC_BPF); 168 LABEL_CHECK(ifplabel, MAGIC_IFNET); 169 COUNTER_INC(bpfdesc_check_receive); 170 171 return (0); 172 } 173 174 COUNTER_DECL(bpfdesc_create); 175 static void 176 test_bpfdesc_create(struct ucred *cred, struct bpf_d *d, 177 struct label *dlabel) 178 { 179 180 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 181 LABEL_CHECK(dlabel, MAGIC_BPF); 182 COUNTER_INC(bpfdesc_create); 183 } 184 185 COUNTER_DECL(bpfdesc_create_mbuf); 186 static void 187 test_bpfdesc_create_mbuf(struct bpf_d *d, struct label *dlabel, 188 struct mbuf *m, struct label *mlabel) 189 { 190 191 LABEL_CHECK(dlabel, MAGIC_BPF); 192 LABEL_CHECK(mlabel, MAGIC_MBUF); 193 COUNTER_INC(bpfdesc_create_mbuf); 194 } 195 196 COUNTER_DECL(bpfdesc_destroy_label); 197 static void 198 test_bpfdesc_destroy_label(struct label *label) 199 { 200 201 LABEL_DESTROY(label, MAGIC_BPF); 202 COUNTER_INC(bpfdesc_destroy_label); 203 } 204 205 COUNTER_DECL(bpfdesc_init_label); 206 static void 207 test_bpfdesc_init_label(struct label *label) 208 { 209 210 LABEL_INIT(label, MAGIC_BPF); 211 COUNTER_INC(bpfdesc_init_label); 212 } 213 214 COUNTER_DECL(cred_check_relabel); 215 static int 216 test_cred_check_relabel(struct ucred *cred, struct label *newlabel) 217 { 218 219 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 220 LABEL_CHECK(newlabel, MAGIC_CRED); 221 COUNTER_INC(cred_check_relabel); 222 223 return (0); 224 } 225 226 COUNTER_DECL(cred_check_setaudit); 227 static int 228 test_cred_check_setaudit(struct ucred *cred, struct auditinfo *ai) 229 { 230 231 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 232 COUNTER_INC(cred_check_setaudit); 233 234 return (0); 235 } 236 237 COUNTER_DECL(cred_check_setaudit_addr); 238 static int 239 test_cred_check_setaudit_addr(struct ucred *cred, 240 struct auditinfo_addr *aia) 241 { 242 243 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 244 COUNTER_INC(cred_check_setaudit_addr); 245 246 return (0); 247 } 248 249 COUNTER_DECL(cred_check_setauid); 250 static int 251 test_cred_check_setauid(struct ucred *cred, uid_t auid) 252 { 253 254 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 255 COUNTER_INC(cred_check_setauid); 256 257 return (0); 258 } 259 260 COUNTER_DECL(cred_check_setegid); 261 static int 262 test_cred_check_setegid(struct ucred *cred, gid_t egid) 263 { 264 265 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 266 COUNTER_INC(cred_check_setegid); 267 268 return (0); 269 } 270 271 COUNTER_DECL(proc_check_euid); 272 static int 273 test_cred_check_seteuid(struct ucred *cred, uid_t euid) 274 { 275 276 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 277 COUNTER_INC(proc_check_euid); 278 279 return (0); 280 } 281 282 COUNTER_DECL(cred_check_setregid); 283 static int 284 test_cred_check_setregid(struct ucred *cred, gid_t rgid, gid_t egid) 285 { 286 287 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 288 COUNTER_INC(cred_check_setregid); 289 290 return (0); 291 } 292 293 COUNTER_DECL(cred_check_setreuid); 294 static int 295 test_cred_check_setreuid(struct ucred *cred, uid_t ruid, uid_t euid) 296 { 297 298 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 299 COUNTER_INC(cred_check_setreuid); 300 301 return (0); 302 } 303 304 COUNTER_DECL(cred_check_setgid); 305 static int 306 test_cred_check_setgid(struct ucred *cred, gid_t gid) 307 { 308 309 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 310 COUNTER_INC(cred_check_setgid); 311 312 return (0); 313 } 314 315 COUNTER_DECL(cred_check_setgroups); 316 static int 317 test_cred_check_setgroups(struct ucred *cred, int ngroups, 318 gid_t *gidset) 319 { 320 321 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 322 COUNTER_INC(cred_check_setgroups); 323 324 return (0); 325 } 326 327 COUNTER_DECL(cred_check_setresgid); 328 static int 329 test_cred_check_setresgid(struct ucred *cred, gid_t rgid, gid_t egid, 330 gid_t sgid) 331 { 332 333 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 334 COUNTER_INC(cred_check_setresgid); 335 336 return (0); 337 } 338 339 COUNTER_DECL(cred_check_setresuid); 340 static int 341 test_cred_check_setresuid(struct ucred *cred, uid_t ruid, uid_t euid, 342 uid_t suid) 343 { 344 345 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 346 COUNTER_INC(cred_check_setresuid); 347 348 return (0); 349 } 350 351 COUNTER_DECL(cred_check_setuid); 352 static int 353 test_cred_check_setuid(struct ucred *cred, uid_t uid) 354 { 355 356 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 357 COUNTER_INC(cred_check_setuid); 358 359 return (0); 360 } 361 362 COUNTER_DECL(cred_check_visible); 363 static int 364 test_cred_check_visible(struct ucred *u1, struct ucred *u2) 365 { 366 367 LABEL_CHECK(u1->cr_label, MAGIC_CRED); 368 LABEL_CHECK(u2->cr_label, MAGIC_CRED); 369 COUNTER_INC(cred_check_visible); 370 371 return (0); 372 } 373 374 COUNTER_DECL(cred_copy_label); 375 static void 376 test_cred_copy_label(struct label *src, struct label *dest) 377 { 378 379 LABEL_CHECK(src, MAGIC_CRED); 380 LABEL_CHECK(dest, MAGIC_CRED); 381 COUNTER_INC(cred_copy_label); 382 } 383 384 COUNTER_DECL(cred_create_init); 385 static void 386 test_cred_create_init(struct ucred *cred) 387 { 388 389 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 390 COUNTER_INC(cred_create_init); 391 } 392 393 COUNTER_DECL(cred_create_swapper); 394 static void 395 test_cred_create_swapper(struct ucred *cred) 396 { 397 398 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 399 COUNTER_INC(cred_create_swapper); 400 } 401 402 COUNTER_DECL(cred_destroy_label); 403 static void 404 test_cred_destroy_label(struct label *label) 405 { 406 407 LABEL_DESTROY(label, MAGIC_CRED); 408 COUNTER_INC(cred_destroy_label); 409 } 410 411 COUNTER_DECL(cred_externalize_label); 412 static int 413 test_cred_externalize_label(struct label *label, char *element_name, 414 struct sbuf *sb, int *claimed) 415 { 416 417 LABEL_CHECK(label, MAGIC_CRED); 418 COUNTER_INC(cred_externalize_label); 419 420 return (0); 421 } 422 423 COUNTER_DECL(cred_init_label); 424 static void 425 test_cred_init_label(struct label *label) 426 { 427 428 LABEL_INIT(label, MAGIC_CRED); 429 COUNTER_INC(cred_init_label); 430 } 431 432 COUNTER_DECL(cred_internalize_label); 433 static int 434 test_cred_internalize_label(struct label *label, char *element_name, 435 char *element_data, int *claimed) 436 { 437 438 LABEL_CHECK(label, MAGIC_CRED); 439 COUNTER_INC(cred_internalize_label); 440 441 return (0); 442 } 443 444 COUNTER_DECL(cred_relabel); 445 static void 446 test_cred_relabel(struct ucred *cred, struct label *newlabel) 447 { 448 449 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 450 LABEL_CHECK(newlabel, MAGIC_CRED); 451 COUNTER_INC(cred_relabel); 452 } 453 454 COUNTER_DECL(devfs_create_device); 455 static void 456 test_devfs_create_device(struct ucred *cred, struct mount *mp, 457 struct cdev *dev, struct devfs_dirent *de, struct label *delabel) 458 { 459 460 if (cred != NULL) 461 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 462 LABEL_CHECK(delabel, MAGIC_DEVFS); 463 COUNTER_INC(devfs_create_device); 464 } 465 466 COUNTER_DECL(devfs_create_directory); 467 static void 468 test_devfs_create_directory(struct mount *mp, char *dirname, 469 int dirnamelen, struct devfs_dirent *de, struct label *delabel) 470 { 471 472 LABEL_CHECK(delabel, MAGIC_DEVFS); 473 COUNTER_INC(devfs_create_directory); 474 } 475 476 COUNTER_DECL(devfs_create_symlink); 477 static void 478 test_devfs_create_symlink(struct ucred *cred, struct mount *mp, 479 struct devfs_dirent *dd, struct label *ddlabel, struct devfs_dirent *de, 480 struct label *delabel) 481 { 482 483 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 484 LABEL_CHECK(ddlabel, MAGIC_DEVFS); 485 LABEL_CHECK(delabel, MAGIC_DEVFS); 486 COUNTER_INC(devfs_create_symlink); 487 } 488 489 COUNTER_DECL(devfs_destroy_label); 490 static void 491 test_devfs_destroy_label(struct label *label) 492 { 493 494 LABEL_DESTROY(label, MAGIC_DEVFS); 495 COUNTER_INC(devfs_destroy_label); 496 } 497 498 COUNTER_DECL(devfs_init_label); 499 static void 500 test_devfs_init_label(struct label *label) 501 { 502 503 LABEL_INIT(label, MAGIC_DEVFS); 504 COUNTER_INC(devfs_init_label); 505 } 506 507 COUNTER_DECL(devfs_update); 508 static void 509 test_devfs_update(struct mount *mp, struct devfs_dirent *devfs_dirent, 510 struct label *direntlabel, struct vnode *vp, struct label *vplabel) 511 { 512 513 LABEL_CHECK(direntlabel, MAGIC_DEVFS); 514 LABEL_CHECK(vplabel, MAGIC_VNODE); 515 COUNTER_INC(devfs_update); 516 } 517 518 COUNTER_DECL(devfs_vnode_associate); 519 static void 520 test_devfs_vnode_associate(struct mount *mp, struct label *mplabel, 521 struct devfs_dirent *de, struct label *delabel, struct vnode *vp, 522 struct label *vplabel) 523 { 524 525 LABEL_CHECK(mplabel, MAGIC_MOUNT); 526 LABEL_CHECK(delabel, MAGIC_DEVFS); 527 LABEL_CHECK(vplabel, MAGIC_VNODE); 528 COUNTER_INC(devfs_vnode_associate); 529 } 530 531 COUNTER_DECL(ifnet_check_relabel); 532 static int 533 test_ifnet_check_relabel(struct ucred *cred, struct ifnet *ifp, 534 struct label *ifplabel, struct label *newlabel) 535 { 536 537 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 538 LABEL_CHECK(ifplabel, MAGIC_IFNET); 539 LABEL_CHECK(newlabel, MAGIC_IFNET); 540 COUNTER_INC(ifnet_check_relabel); 541 542 return (0); 543 } 544 545 COUNTER_DECL(ifnet_check_transmit); 546 static int 547 test_ifnet_check_transmit(struct ifnet *ifp, struct label *ifplabel, 548 struct mbuf *m, struct label *mlabel) 549 { 550 551 LABEL_CHECK(ifplabel, MAGIC_IFNET); 552 LABEL_CHECK(mlabel, MAGIC_MBUF); 553 COUNTER_INC(ifnet_check_transmit); 554 555 return (0); 556 } 557 558 COUNTER_DECL(ifnet_copy_label); 559 static void 560 test_ifnet_copy_label(struct label *src, struct label *dest) 561 { 562 563 LABEL_CHECK(src, MAGIC_IFNET); 564 LABEL_CHECK(dest, MAGIC_IFNET); 565 COUNTER_INC(ifnet_copy_label); 566 } 567 568 COUNTER_DECL(ifnet_create); 569 static void 570 test_ifnet_create(struct ifnet *ifp, struct label *ifplabel) 571 { 572 573 LABEL_CHECK(ifplabel, MAGIC_IFNET); 574 COUNTER_INC(ifnet_create); 575 } 576 577 COUNTER_DECL(ifnet_create_mbuf); 578 static void 579 test_ifnet_create_mbuf(struct ifnet *ifp, struct label *ifplabel, 580 struct mbuf *m, struct label *mlabel) 581 { 582 583 LABEL_CHECK(ifplabel, MAGIC_IFNET); 584 LABEL_CHECK(mlabel, MAGIC_MBUF); 585 COUNTER_INC(ifnet_create_mbuf); 586 } 587 588 COUNTER_DECL(ifnet_destroy_label); 589 static void 590 test_ifnet_destroy_label(struct label *label) 591 { 592 593 LABEL_DESTROY(label, MAGIC_IFNET); 594 COUNTER_INC(ifnet_destroy_label); 595 } 596 597 COUNTER_DECL(ifnet_externalize_label); 598 static int 599 test_ifnet_externalize_label(struct label *label, char *element_name, 600 struct sbuf *sb, int *claimed) 601 { 602 603 LABEL_CHECK(label, MAGIC_IFNET); 604 COUNTER_INC(ifnet_externalize_label); 605 606 return (0); 607 } 608 609 COUNTER_DECL(ifnet_init_label); 610 static void 611 test_ifnet_init_label(struct label *label) 612 { 613 614 LABEL_INIT(label, MAGIC_IFNET); 615 COUNTER_INC(ifnet_init_label); 616 } 617 618 COUNTER_DECL(ifnet_internalize_label); 619 static int 620 test_ifnet_internalize_label(struct label *label, char *element_name, 621 char *element_data, int *claimed) 622 { 623 624 LABEL_CHECK(label, MAGIC_IFNET); 625 COUNTER_INC(ifnet_internalize_label); 626 627 return (0); 628 } 629 630 COUNTER_DECL(ifnet_relabel); 631 static void 632 test_ifnet_relabel(struct ucred *cred, struct ifnet *ifp, 633 struct label *ifplabel, struct label *newlabel) 634 { 635 636 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 637 LABEL_CHECK(ifplabel, MAGIC_IFNET); 638 LABEL_CHECK(newlabel, MAGIC_IFNET); 639 COUNTER_INC(ifnet_relabel); 640 } 641 642 COUNTER_DECL(inpcb_check_deliver); 643 static int 644 test_inpcb_check_deliver(struct inpcb *inp, struct label *inplabel, 645 struct mbuf *m, struct label *mlabel) 646 { 647 648 LABEL_CHECK(inplabel, MAGIC_INPCB); 649 LABEL_CHECK(mlabel, MAGIC_MBUF); 650 COUNTER_INC(inpcb_check_deliver); 651 652 return (0); 653 } 654 655 COUNTER_DECL(inpcb_check_visible); 656 static int 657 test_inpcb_check_visible(struct ucred *cred, struct inpcb *inp, 658 struct label *inplabel) 659 { 660 661 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 662 LABEL_CHECK(inplabel, MAGIC_INPCB); 663 COUNTER_INC(inpcb_check_visible); 664 665 return (0); 666 } 667 668 COUNTER_DECL(inpcb_create); 669 static void 670 test_inpcb_create(struct socket *so, struct label *solabel, 671 struct inpcb *inp, struct label *inplabel) 672 { 673 674 SOCK_LOCK(so); 675 LABEL_CHECK(solabel, MAGIC_SOCKET); 676 SOCK_UNLOCK(so); 677 LABEL_CHECK(inplabel, MAGIC_INPCB); 678 COUNTER_INC(inpcb_create); 679 } 680 681 COUNTER_DECL(inpcb_create_mbuf); 682 static void 683 test_inpcb_create_mbuf(struct inpcb *inp, struct label *inplabel, 684 struct mbuf *m, struct label *mlabel) 685 { 686 687 LABEL_CHECK(inplabel, MAGIC_INPCB); 688 LABEL_CHECK(mlabel, MAGIC_MBUF); 689 COUNTER_INC(inpcb_create_mbuf); 690 } 691 692 COUNTER_DECL(inpcb_destroy_label); 693 static void 694 test_inpcb_destroy_label(struct label *label) 695 { 696 697 LABEL_DESTROY(label, MAGIC_INPCB); 698 COUNTER_INC(inpcb_destroy_label); 699 } 700 701 COUNTER_DECL(inpcb_init_label); 702 static int 703 test_inpcb_init_label(struct label *label, int flag) 704 { 705 706 if (flag & M_WAITOK) 707 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 708 "test_inpcb_init_label() at %s:%d", __FILE__, 709 __LINE__); 710 711 LABEL_INIT(label, MAGIC_INPCB); 712 COUNTER_INC(inpcb_init_label); 713 return (0); 714 } 715 716 COUNTER_DECL(inpcb_sosetlabel); 717 static void 718 test_inpcb_sosetlabel(struct socket *so, struct label *solabel, 719 struct inpcb *inp, struct label *inplabel) 720 { 721 722 SOCK_LOCK_ASSERT(so); 723 724 LABEL_CHECK(solabel, MAGIC_SOCKET); 725 LABEL_CHECK(inplabel, MAGIC_INPCB); 726 COUNTER_INC(inpcb_sosetlabel); 727 } 728 729 COUNTER_DECL(ip6q_create); 730 static void 731 test_ip6q_create(struct mbuf *fragment, struct label *fragmentlabel, 732 struct ip6q *q6, struct label *q6label) 733 { 734 735 LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 736 LABEL_CHECK(q6label, MAGIC_IP6Q); 737 COUNTER_INC(ip6q_create); 738 } 739 740 COUNTER_DECL(ip6q_destroy_label); 741 static void 742 test_ip6q_destroy_label(struct label *label) 743 { 744 745 LABEL_DESTROY(label, MAGIC_IP6Q); 746 COUNTER_INC(ip6q_destroy_label); 747 } 748 749 COUNTER_DECL(ip6q_init_label); 750 static int 751 test_ip6q_init_label(struct label *label, int flag) 752 { 753 754 if (flag & M_WAITOK) 755 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 756 "test_ip6q_init_label() at %s:%d", __FILE__, 757 __LINE__); 758 759 LABEL_INIT(label, MAGIC_IP6Q); 760 COUNTER_INC(ip6q_init_label); 761 return (0); 762 } 763 764 COUNTER_DECL(ip6q_match); 765 static int 766 test_ip6q_match(struct mbuf *fragment, struct label *fragmentlabel, 767 struct ip6q *q6, struct label *q6label) 768 { 769 770 LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 771 LABEL_CHECK(q6label, MAGIC_IP6Q); 772 COUNTER_INC(ip6q_match); 773 774 return (1); 775 } 776 777 COUNTER_DECL(ip6q_reassemble); 778 static void 779 test_ip6q_reassemble(struct ip6q *q6, struct label *q6label, struct mbuf *m, 780 struct label *mlabel) 781 { 782 783 LABEL_CHECK(q6label, MAGIC_IP6Q); 784 LABEL_CHECK(mlabel, MAGIC_MBUF); 785 COUNTER_INC(ip6q_reassemble); 786 } 787 788 COUNTER_DECL(ip6q_update); 789 static void 790 test_ip6q_update(struct mbuf *m, struct label *mlabel, struct ip6q *q6, 791 struct label *q6label) 792 { 793 794 LABEL_CHECK(mlabel, MAGIC_MBUF); 795 LABEL_CHECK(q6label, MAGIC_IP6Q); 796 COUNTER_INC(ip6q_update); 797 } 798 799 COUNTER_DECL(ipq_create); 800 static void 801 test_ipq_create(struct mbuf *fragment, struct label *fragmentlabel, 802 struct ipq *q, struct label *qlabel) 803 { 804 805 LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 806 LABEL_CHECK(qlabel, MAGIC_IPQ); 807 COUNTER_INC(ipq_create); 808 } 809 810 COUNTER_DECL(ipq_destroy_label); 811 static void 812 test_ipq_destroy_label(struct label *label) 813 { 814 815 LABEL_DESTROY(label, MAGIC_IPQ); 816 COUNTER_INC(ipq_destroy_label); 817 } 818 819 COUNTER_DECL(ipq_init_label); 820 static int 821 test_ipq_init_label(struct label *label, int flag) 822 { 823 824 if (flag & M_WAITOK) 825 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 826 "test_ipq_init_label() at %s:%d", __FILE__, 827 __LINE__); 828 829 LABEL_INIT(label, MAGIC_IPQ); 830 COUNTER_INC(ipq_init_label); 831 return (0); 832 } 833 834 COUNTER_DECL(ipq_match); 835 static int 836 test_ipq_match(struct mbuf *fragment, struct label *fragmentlabel, 837 struct ipq *q, struct label *qlabel) 838 { 839 840 LABEL_CHECK(fragmentlabel, MAGIC_MBUF); 841 LABEL_CHECK(qlabel, MAGIC_IPQ); 842 COUNTER_INC(ipq_match); 843 844 return (1); 845 } 846 847 COUNTER_DECL(ipq_reassemble); 848 static void 849 test_ipq_reassemble(struct ipq *q, struct label *qlabel, struct mbuf *m, 850 struct label *mlabel) 851 { 852 853 LABEL_CHECK(qlabel, MAGIC_IPQ); 854 LABEL_CHECK(mlabel, MAGIC_MBUF); 855 COUNTER_INC(ipq_reassemble); 856 } 857 858 COUNTER_DECL(ipq_update); 859 static void 860 test_ipq_update(struct mbuf *m, struct label *mlabel, struct ipq *q, 861 struct label *qlabel) 862 { 863 864 LABEL_CHECK(mlabel, MAGIC_MBUF); 865 LABEL_CHECK(qlabel, MAGIC_IPQ); 866 COUNTER_INC(ipq_update); 867 } 868 869 COUNTER_DECL(kenv_check_dump); 870 static int 871 test_kenv_check_dump(struct ucred *cred) 872 { 873 874 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 875 COUNTER_INC(kenv_check_dump); 876 877 return (0); 878 } 879 880 COUNTER_DECL(kenv_check_get); 881 static int 882 test_kenv_check_get(struct ucred *cred, char *name) 883 { 884 885 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 886 COUNTER_INC(kenv_check_get); 887 888 return (0); 889 } 890 891 COUNTER_DECL(kenv_check_set); 892 static int 893 test_kenv_check_set(struct ucred *cred, char *name, char *value) 894 { 895 896 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 897 COUNTER_INC(kenv_check_set); 898 899 return (0); 900 } 901 902 COUNTER_DECL(kenv_check_unset); 903 static int 904 test_kenv_check_unset(struct ucred *cred, char *name) 905 { 906 907 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 908 COUNTER_INC(kenv_check_unset); 909 910 return (0); 911 } 912 913 COUNTER_DECL(kld_check_load); 914 static int 915 test_kld_check_load(struct ucred *cred, struct vnode *vp, 916 struct label *label) 917 { 918 919 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 920 LABEL_CHECK(label, MAGIC_VNODE); 921 COUNTER_INC(kld_check_load); 922 923 return (0); 924 } 925 926 COUNTER_DECL(kld_check_stat); 927 static int 928 test_kld_check_stat(struct ucred *cred) 929 { 930 931 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 932 COUNTER_INC(kld_check_stat); 933 934 return (0); 935 } 936 937 COUNTER_DECL(mbuf_copy_label); 938 static void 939 test_mbuf_copy_label(struct label *src, struct label *dest) 940 { 941 942 LABEL_CHECK(src, MAGIC_MBUF); 943 LABEL_CHECK(dest, MAGIC_MBUF); 944 COUNTER_INC(mbuf_copy_label); 945 } 946 947 COUNTER_DECL(mbuf_destroy_label); 948 static void 949 test_mbuf_destroy_label(struct label *label) 950 { 951 952 /* 953 * If we're loaded dynamically, there may be mbufs in flight that 954 * didn't have label storage allocated for them. Handle this 955 * gracefully. 956 */ 957 if (label == NULL) 958 return; 959 960 LABEL_DESTROY(label, MAGIC_MBUF); 961 COUNTER_INC(mbuf_destroy_label); 962 } 963 964 COUNTER_DECL(mbuf_init_label); 965 static int 966 test_mbuf_init_label(struct label *label, int flag) 967 { 968 969 if (flag & M_WAITOK) 970 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 971 "test_mbuf_init_label() at %s:%d", __FILE__, 972 __LINE__); 973 974 LABEL_INIT(label, MAGIC_MBUF); 975 COUNTER_INC(mbuf_init_label); 976 return (0); 977 } 978 979 COUNTER_DECL(mount_check_stat); 980 static int 981 test_mount_check_stat(struct ucred *cred, struct mount *mp, 982 struct label *mplabel) 983 { 984 985 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 986 LABEL_CHECK(mplabel, MAGIC_MOUNT); 987 COUNTER_INC(mount_check_stat); 988 989 return (0); 990 } 991 992 COUNTER_DECL(mount_create); 993 static void 994 test_mount_create(struct ucred *cred, struct mount *mp, 995 struct label *mplabel) 996 { 997 998 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 999 LABEL_CHECK(mplabel, MAGIC_MOUNT); 1000 COUNTER_INC(mount_create); 1001 } 1002 1003 COUNTER_DECL(mount_destroy_label); 1004 static void 1005 test_mount_destroy_label(struct label *label) 1006 { 1007 1008 LABEL_DESTROY(label, MAGIC_MOUNT); 1009 COUNTER_INC(mount_destroy_label); 1010 } 1011 1012 COUNTER_DECL(mount_init_label); 1013 static void 1014 test_mount_init_label(struct label *label) 1015 { 1016 1017 LABEL_INIT(label, MAGIC_MOUNT); 1018 COUNTER_INC(mount_init_label); 1019 } 1020 1021 COUNTER_DECL(netatalk_aarp_send); 1022 static void 1023 test_netatalk_aarp_send(struct ifnet *ifp, struct label *ifplabel, 1024 struct mbuf *m, struct label *mlabel) 1025 { 1026 1027 LABEL_CHECK(ifplabel, MAGIC_IFNET); 1028 LABEL_CHECK(mlabel, MAGIC_MBUF); 1029 COUNTER_INC(netatalk_aarp_send); 1030 } 1031 1032 COUNTER_DECL(netinet_arp_send); 1033 static void 1034 test_netinet_arp_send(struct ifnet *ifp, struct label *ifplabel, 1035 struct mbuf *m, struct label *mlabel) 1036 { 1037 1038 LABEL_CHECK(ifplabel, MAGIC_IFNET); 1039 LABEL_CHECK(mlabel, MAGIC_MBUF); 1040 COUNTER_INC(netinet_arp_send); 1041 } 1042 1043 COUNTER_DECL(netinet_fragment); 1044 static void 1045 test_netinet_fragment(struct mbuf *m, struct label *mlabel, 1046 struct mbuf *frag, struct label *fraglabel) 1047 { 1048 1049 LABEL_CHECK(mlabel, MAGIC_MBUF); 1050 LABEL_CHECK(fraglabel, MAGIC_MBUF); 1051 COUNTER_INC(netinet_fragment); 1052 } 1053 1054 COUNTER_DECL(netinet_icmp_reply); 1055 static void 1056 test_netinet_icmp_reply(struct mbuf *mrecv, struct label *mrecvlabel, 1057 struct mbuf *msend, struct label *msendlabel) 1058 { 1059 1060 LABEL_CHECK(mrecvlabel, MAGIC_MBUF); 1061 LABEL_CHECK(msendlabel, MAGIC_MBUF); 1062 COUNTER_INC(netinet_icmp_reply); 1063 } 1064 1065 COUNTER_DECL(netinet_icmp_replyinplace); 1066 static void 1067 test_netinet_icmp_replyinplace(struct mbuf *m, struct label *mlabel) 1068 { 1069 1070 LABEL_CHECK(mlabel, MAGIC_MBUF); 1071 COUNTER_INC(netinet_icmp_replyinplace); 1072 } 1073 1074 COUNTER_DECL(netinet_igmp_send); 1075 static void 1076 test_netinet_igmp_send(struct ifnet *ifp, struct label *ifplabel, 1077 struct mbuf *m, struct label *mlabel) 1078 { 1079 1080 LABEL_CHECK(ifplabel, MAGIC_IFNET); 1081 LABEL_CHECK(mlabel, MAGIC_MBUF); 1082 COUNTER_INC(netinet_igmp_send); 1083 } 1084 1085 COUNTER_DECL(netinet_tcp_reply); 1086 static void 1087 test_netinet_tcp_reply(struct mbuf *m, struct label *mlabel) 1088 { 1089 1090 LABEL_CHECK(mlabel, MAGIC_MBUF); 1091 COUNTER_INC(netinet_tcp_reply); 1092 } 1093 1094 COUNTER_DECL(netinet6_nd6_send); 1095 static void 1096 test_netinet6_nd6_send(struct ifnet *ifp, struct label *ifplabel, 1097 struct mbuf *m, struct label *mlabel) 1098 { 1099 1100 LABEL_CHECK(ifplabel, MAGIC_IFNET); 1101 LABEL_CHECK(mlabel, MAGIC_MBUF); 1102 COUNTER_INC(netinet6_nd6_send); 1103 } 1104 1105 COUNTER_DECL(pipe_check_ioctl); 1106 static int 1107 test_pipe_check_ioctl(struct ucred *cred, struct pipepair *pp, 1108 struct label *pplabel, unsigned long cmd, void /* caddr_t */ *data) 1109 { 1110 1111 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1112 LABEL_CHECK(pplabel, MAGIC_PIPE); 1113 COUNTER_INC(pipe_check_ioctl); 1114 1115 return (0); 1116 } 1117 1118 COUNTER_DECL(pipe_check_poll); 1119 static int 1120 test_pipe_check_poll(struct ucred *cred, struct pipepair *pp, 1121 struct label *pplabel) 1122 { 1123 1124 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1125 LABEL_CHECK(pplabel, MAGIC_PIPE); 1126 COUNTER_INC(pipe_check_poll); 1127 1128 return (0); 1129 } 1130 1131 COUNTER_DECL(pipe_check_read); 1132 static int 1133 test_pipe_check_read(struct ucred *cred, struct pipepair *pp, 1134 struct label *pplabel) 1135 { 1136 1137 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1138 LABEL_CHECK(pplabel, MAGIC_PIPE); 1139 COUNTER_INC(pipe_check_read); 1140 1141 return (0); 1142 } 1143 1144 COUNTER_DECL(pipe_check_relabel); 1145 static int 1146 test_pipe_check_relabel(struct ucred *cred, struct pipepair *pp, 1147 struct label *pplabel, struct label *newlabel) 1148 { 1149 1150 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1151 LABEL_CHECK(pplabel, MAGIC_PIPE); 1152 LABEL_CHECK(newlabel, MAGIC_PIPE); 1153 COUNTER_INC(pipe_check_relabel); 1154 1155 return (0); 1156 } 1157 1158 COUNTER_DECL(pipe_check_stat); 1159 static int 1160 test_pipe_check_stat(struct ucred *cred, struct pipepair *pp, 1161 struct label *pplabel) 1162 { 1163 1164 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1165 LABEL_CHECK(pplabel, MAGIC_PIPE); 1166 COUNTER_INC(pipe_check_stat); 1167 1168 return (0); 1169 } 1170 1171 COUNTER_DECL(pipe_check_write); 1172 static int 1173 test_pipe_check_write(struct ucred *cred, struct pipepair *pp, 1174 struct label *pplabel) 1175 { 1176 1177 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1178 LABEL_CHECK(pplabel, MAGIC_PIPE); 1179 COUNTER_INC(pipe_check_write); 1180 1181 return (0); 1182 } 1183 1184 COUNTER_DECL(pipe_copy_label); 1185 static void 1186 test_pipe_copy_label(struct label *src, struct label *dest) 1187 { 1188 1189 LABEL_CHECK(src, MAGIC_PIPE); 1190 LABEL_CHECK(dest, MAGIC_PIPE); 1191 COUNTER_INC(pipe_copy_label); 1192 } 1193 1194 COUNTER_DECL(pipe_create); 1195 static void 1196 test_pipe_create(struct ucred *cred, struct pipepair *pp, 1197 struct label *pplabel) 1198 { 1199 1200 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1201 LABEL_CHECK(pplabel, MAGIC_PIPE); 1202 COUNTER_INC(pipe_create); 1203 } 1204 1205 COUNTER_DECL(pipe_destroy_label); 1206 static void 1207 test_pipe_destroy_label(struct label *label) 1208 { 1209 1210 LABEL_DESTROY(label, MAGIC_PIPE); 1211 COUNTER_INC(pipe_destroy_label); 1212 } 1213 1214 COUNTER_DECL(pipe_externalize_label); 1215 static int 1216 test_pipe_externalize_label(struct label *label, char *element_name, 1217 struct sbuf *sb, int *claimed) 1218 { 1219 1220 LABEL_CHECK(label, MAGIC_PIPE); 1221 COUNTER_INC(pipe_externalize_label); 1222 1223 return (0); 1224 } 1225 1226 COUNTER_DECL(pipe_init_label); 1227 static void 1228 test_pipe_init_label(struct label *label) 1229 { 1230 1231 LABEL_INIT(label, MAGIC_PIPE); 1232 COUNTER_INC(pipe_init_label); 1233 } 1234 1235 COUNTER_DECL(pipe_internalize_label); 1236 static int 1237 test_pipe_internalize_label(struct label *label, char *element_name, 1238 char *element_data, int *claimed) 1239 { 1240 1241 LABEL_CHECK(label, MAGIC_PIPE); 1242 COUNTER_INC(pipe_internalize_label); 1243 1244 return (0); 1245 } 1246 1247 COUNTER_DECL(pipe_relabel); 1248 static void 1249 test_pipe_relabel(struct ucred *cred, struct pipepair *pp, 1250 struct label *pplabel, struct label *newlabel) 1251 { 1252 1253 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1254 LABEL_CHECK(pplabel, MAGIC_PIPE); 1255 LABEL_CHECK(newlabel, MAGIC_PIPE); 1256 COUNTER_INC(pipe_relabel); 1257 } 1258 1259 COUNTER_DECL(posixsem_check_getvalue); 1260 static int 1261 test_posixsem_check_getvalue(struct ucred *active_cred, struct ucred *file_cred, 1262 struct ksem *ks, struct label *kslabel) 1263 { 1264 1265 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1266 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1267 LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1268 COUNTER_INC(posixsem_check_getvalue); 1269 1270 return (0); 1271 } 1272 1273 COUNTER_DECL(posixsem_check_open); 1274 static int 1275 test_posixsem_check_open(struct ucred *cred, struct ksem *ks, 1276 struct label *kslabel) 1277 { 1278 1279 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1280 LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1281 COUNTER_INC(posixsem_check_open); 1282 1283 return (0); 1284 } 1285 1286 COUNTER_DECL(posixsem_check_post); 1287 static int 1288 test_posixsem_check_post(struct ucred *active_cred, struct ucred *file_cred, 1289 struct ksem *ks, struct label *kslabel) 1290 { 1291 1292 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1293 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1294 LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1295 COUNTER_INC(posixsem_check_post); 1296 1297 return (0); 1298 } 1299 1300 COUNTER_DECL(posixsem_check_stat); 1301 static int 1302 test_posixsem_check_stat(struct ucred *active_cred, 1303 struct ucred *file_cred, struct ksem *ks, struct label *kslabel) 1304 { 1305 1306 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1307 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1308 LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1309 COUNTER_INC(posixsem_check_stat); 1310 return (0); 1311 } 1312 1313 COUNTER_DECL(posixsem_check_unlink); 1314 static int 1315 test_posixsem_check_unlink(struct ucred *cred, struct ksem *ks, 1316 struct label *kslabel) 1317 { 1318 1319 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1320 LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1321 COUNTER_INC(posixsem_check_unlink); 1322 1323 return (0); 1324 } 1325 1326 COUNTER_DECL(posixsem_check_wait); 1327 static int 1328 test_posixsem_check_wait(struct ucred *active_cred, struct ucred *file_cred, 1329 struct ksem *ks, struct label *kslabel) 1330 { 1331 1332 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1333 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1334 LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1335 COUNTER_INC(posixsem_check_wait); 1336 1337 return (0); 1338 } 1339 1340 COUNTER_DECL(posixsem_create); 1341 static void 1342 test_posixsem_create(struct ucred *cred, struct ksem *ks, 1343 struct label *kslabel) 1344 { 1345 1346 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1347 LABEL_CHECK(kslabel, MAGIC_POSIX_SEM); 1348 COUNTER_INC(posixsem_create); 1349 } 1350 1351 COUNTER_DECL(posixsem_destroy_label); 1352 static void 1353 test_posixsem_destroy_label(struct label *label) 1354 { 1355 1356 LABEL_DESTROY(label, MAGIC_POSIX_SEM); 1357 COUNTER_INC(posixsem_destroy_label); 1358 } 1359 1360 COUNTER_DECL(posixsem_init_label); 1361 static void 1362 test_posixsem_init_label(struct label *label) 1363 { 1364 1365 LABEL_INIT(label, MAGIC_POSIX_SEM); 1366 COUNTER_INC(posixsem_init_label); 1367 } 1368 1369 COUNTER_DECL(posixshm_check_mmap); 1370 static int 1371 test_posixshm_check_mmap(struct ucred *cred, struct shmfd *shmfd, 1372 struct label *shmfdlabel, int prot, int flags) 1373 { 1374 1375 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1376 LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1377 COUNTER_INC(posixshm_check_mmap); 1378 return (0); 1379 } 1380 1381 COUNTER_DECL(posixshm_check_open); 1382 static int 1383 test_posixshm_check_open(struct ucred *cred, struct shmfd *shmfd, 1384 struct label *shmfdlabel) 1385 { 1386 1387 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1388 LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1389 COUNTER_INC(posixshm_check_open); 1390 return (0); 1391 } 1392 1393 COUNTER_DECL(posixshm_check_stat); 1394 static int 1395 test_posixshm_check_stat(struct ucred *active_cred, 1396 struct ucred *file_cred, struct shmfd *shmfd, struct label *shmfdlabel) 1397 { 1398 1399 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1400 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1401 LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1402 COUNTER_INC(posixshm_check_stat); 1403 return (0); 1404 } 1405 1406 COUNTER_DECL(posixshm_check_truncate); 1407 static int 1408 test_posixshm_check_truncate(struct ucred *active_cred, 1409 struct ucred *file_cred, struct shmfd *shmfd, struct label *shmfdlabel) 1410 { 1411 1412 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 1413 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 1414 LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1415 COUNTER_INC(posixshm_check_truncate); 1416 return (0); 1417 } 1418 1419 COUNTER_DECL(posixshm_check_unlink); 1420 static int 1421 test_posixshm_check_unlink(struct ucred *cred, struct shmfd *shmfd, 1422 struct label *shmfdlabel) 1423 { 1424 1425 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1426 LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1427 COUNTER_INC(posixshm_check_unlink); 1428 return (0); 1429 } 1430 1431 COUNTER_DECL(posixshm_create); 1432 static void 1433 test_posixshm_create(struct ucred *cred, struct shmfd *shmfd, 1434 struct label *shmfdlabel) 1435 { 1436 1437 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1438 LABEL_CHECK(shmfdlabel, MAGIC_POSIX_SHM); 1439 COUNTER_INC(posixshm_create); 1440 } 1441 1442 COUNTER_DECL(posixshm_destroy_label); 1443 static void 1444 test_posixshm_destroy_label(struct label *label) 1445 { 1446 1447 LABEL_DESTROY(label, MAGIC_POSIX_SHM); 1448 COUNTER_INC(posixshm_destroy_label); 1449 } 1450 1451 COUNTER_DECL(posixshm_init_label); 1452 static void 1453 test_posixshm_init_label(struct label *label) 1454 { 1455 1456 LABEL_INIT(label, MAGIC_POSIX_SHM); 1457 COUNTER_INC(posixshm_init_label); 1458 } 1459 1460 COUNTER_DECL(proc_check_debug); 1461 static int 1462 test_proc_check_debug(struct ucred *cred, struct proc *p) 1463 { 1464 1465 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1466 LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 1467 COUNTER_INC(proc_check_debug); 1468 1469 return (0); 1470 } 1471 1472 COUNTER_DECL(proc_check_sched); 1473 static int 1474 test_proc_check_sched(struct ucred *cred, struct proc *p) 1475 { 1476 1477 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1478 LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 1479 COUNTER_INC(proc_check_sched); 1480 1481 return (0); 1482 } 1483 1484 COUNTER_DECL(proc_check_signal); 1485 static int 1486 test_proc_check_signal(struct ucred *cred, struct proc *p, int signum) 1487 { 1488 1489 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1490 LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 1491 COUNTER_INC(proc_check_signal); 1492 1493 return (0); 1494 } 1495 1496 COUNTER_DECL(proc_check_wait); 1497 static int 1498 test_proc_check_wait(struct ucred *cred, struct proc *p) 1499 { 1500 1501 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1502 LABEL_CHECK(p->p_ucred->cr_label, MAGIC_CRED); 1503 COUNTER_INC(proc_check_wait); 1504 1505 return (0); 1506 } 1507 1508 COUNTER_DECL(proc_destroy_label); 1509 static void 1510 test_proc_destroy_label(struct label *label) 1511 { 1512 1513 LABEL_DESTROY(label, MAGIC_PROC); 1514 COUNTER_INC(proc_destroy_label); 1515 } 1516 1517 COUNTER_DECL(proc_init_label); 1518 static void 1519 test_proc_init_label(struct label *label) 1520 { 1521 1522 LABEL_INIT(label, MAGIC_PROC); 1523 COUNTER_INC(proc_init_label); 1524 } 1525 1526 COUNTER_DECL(socket_check_accept); 1527 static int 1528 test_socket_check_accept(struct ucred *cred, struct socket *so, 1529 struct label *solabel) 1530 { 1531 1532 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1533 SOCK_LOCK(so); 1534 LABEL_CHECK(solabel, MAGIC_SOCKET); 1535 SOCK_UNLOCK(so); 1536 COUNTER_INC(socket_check_accept); 1537 1538 return (0); 1539 } 1540 1541 COUNTER_DECL(socket_check_bind); 1542 static int 1543 test_socket_check_bind(struct ucred *cred, struct socket *so, 1544 struct label *solabel, struct sockaddr *sa) 1545 { 1546 1547 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1548 SOCK_LOCK(so); 1549 LABEL_CHECK(solabel, MAGIC_SOCKET); 1550 SOCK_UNLOCK(so); 1551 COUNTER_INC(socket_check_bind); 1552 1553 return (0); 1554 } 1555 1556 COUNTER_DECL(socket_check_connect); 1557 static int 1558 test_socket_check_connect(struct ucred *cred, struct socket *so, 1559 struct label *solabel, struct sockaddr *sa) 1560 { 1561 1562 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1563 SOCK_LOCK(so); 1564 LABEL_CHECK(solabel, MAGIC_SOCKET); 1565 SOCK_UNLOCK(so); 1566 COUNTER_INC(socket_check_connect); 1567 1568 return (0); 1569 } 1570 1571 COUNTER_DECL(socket_check_deliver); 1572 static int 1573 test_socket_check_deliver(struct socket *so, struct label *solabel, 1574 struct mbuf *m, struct label *mlabel) 1575 { 1576 1577 SOCK_LOCK(so); 1578 LABEL_CHECK(solabel, MAGIC_SOCKET); 1579 SOCK_UNLOCK(so); 1580 LABEL_CHECK(mlabel, MAGIC_MBUF); 1581 COUNTER_INC(socket_check_deliver); 1582 1583 return (0); 1584 } 1585 1586 COUNTER_DECL(socket_check_listen); 1587 static int 1588 test_socket_check_listen(struct ucred *cred, struct socket *so, 1589 struct label *solabel) 1590 { 1591 1592 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1593 SOCK_LOCK(so); 1594 LABEL_CHECK(solabel, MAGIC_SOCKET); 1595 SOCK_UNLOCK(so); 1596 COUNTER_INC(socket_check_listen); 1597 1598 return (0); 1599 } 1600 1601 COUNTER_DECL(socket_check_poll); 1602 static int 1603 test_socket_check_poll(struct ucred *cred, struct socket *so, 1604 struct label *solabel) 1605 { 1606 1607 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1608 SOCK_LOCK(so); 1609 LABEL_CHECK(solabel, MAGIC_SOCKET); 1610 SOCK_UNLOCK(so); 1611 COUNTER_INC(socket_check_poll); 1612 1613 return (0); 1614 } 1615 1616 COUNTER_DECL(socket_check_receive); 1617 static int 1618 test_socket_check_receive(struct ucred *cred, struct socket *so, 1619 struct label *solabel) 1620 { 1621 1622 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1623 SOCK_LOCK(so); 1624 LABEL_CHECK(solabel, MAGIC_SOCKET); 1625 SOCK_UNLOCK(so); 1626 COUNTER_INC(socket_check_receive); 1627 1628 return (0); 1629 } 1630 1631 COUNTER_DECL(socket_check_relabel); 1632 static int 1633 test_socket_check_relabel(struct ucred *cred, struct socket *so, 1634 struct label *solabel, struct label *newlabel) 1635 { 1636 1637 SOCK_LOCK_ASSERT(so); 1638 1639 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1640 LABEL_CHECK(solabel, MAGIC_SOCKET); 1641 LABEL_CHECK(newlabel, MAGIC_SOCKET); 1642 COUNTER_INC(socket_check_relabel); 1643 1644 return (0); 1645 } 1646 1647 COUNTER_DECL(socket_check_send); 1648 static int 1649 test_socket_check_send(struct ucred *cred, struct socket *so, 1650 struct label *solabel) 1651 { 1652 1653 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1654 SOCK_LOCK(so); 1655 LABEL_CHECK(solabel, MAGIC_SOCKET); 1656 SOCK_UNLOCK(so); 1657 COUNTER_INC(socket_check_send); 1658 1659 return (0); 1660 } 1661 1662 COUNTER_DECL(socket_check_stat); 1663 static int 1664 test_socket_check_stat(struct ucred *cred, struct socket *so, 1665 struct label *solabel) 1666 { 1667 1668 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1669 SOCK_LOCK(so); 1670 LABEL_CHECK(solabel, MAGIC_SOCKET); 1671 SOCK_UNLOCK(so); 1672 COUNTER_INC(socket_check_stat); 1673 1674 return (0); 1675 } 1676 1677 COUNTER_DECL(socket_check_visible); 1678 static int 1679 test_socket_check_visible(struct ucred *cred, struct socket *so, 1680 struct label *solabel) 1681 { 1682 1683 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1684 SOCK_LOCK(so); 1685 LABEL_CHECK(solabel, MAGIC_SOCKET); 1686 SOCK_UNLOCK(so); 1687 COUNTER_INC(socket_check_visible); 1688 1689 return (0); 1690 } 1691 1692 COUNTER_DECL(socket_copy_label); 1693 static void 1694 test_socket_copy_label(struct label *src, struct label *dest) 1695 { 1696 1697 LABEL_CHECK(src, MAGIC_SOCKET); 1698 LABEL_CHECK(dest, MAGIC_SOCKET); 1699 COUNTER_INC(socket_copy_label); 1700 } 1701 1702 COUNTER_DECL(socket_create); 1703 static void 1704 test_socket_create(struct ucred *cred, struct socket *so, 1705 struct label *solabel) 1706 { 1707 1708 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1709 LABEL_CHECK(solabel, MAGIC_SOCKET); 1710 COUNTER_INC(socket_create); 1711 } 1712 1713 COUNTER_DECL(socket_create_mbuf); 1714 static void 1715 test_socket_create_mbuf(struct socket *so, struct label *solabel, 1716 struct mbuf *m, struct label *mlabel) 1717 { 1718 1719 SOCK_LOCK(so); 1720 LABEL_CHECK(solabel, MAGIC_SOCKET); 1721 SOCK_UNLOCK(so); 1722 LABEL_CHECK(mlabel, MAGIC_MBUF); 1723 COUNTER_INC(socket_create_mbuf); 1724 } 1725 1726 COUNTER_DECL(socket_destroy_label); 1727 static void 1728 test_socket_destroy_label(struct label *label) 1729 { 1730 1731 LABEL_DESTROY(label, MAGIC_SOCKET); 1732 COUNTER_INC(socket_destroy_label); 1733 } 1734 1735 COUNTER_DECL(socket_externalize_label); 1736 static int 1737 test_socket_externalize_label(struct label *label, char *element_name, 1738 struct sbuf *sb, int *claimed) 1739 { 1740 1741 LABEL_CHECK(label, MAGIC_SOCKET); 1742 COUNTER_INC(socket_externalize_label); 1743 1744 return (0); 1745 } 1746 1747 COUNTER_DECL(socket_init_label); 1748 static int 1749 test_socket_init_label(struct label *label, int flag) 1750 { 1751 1752 if (flag & M_WAITOK) 1753 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 1754 "test_socket_init_label() at %s:%d", __FILE__, 1755 __LINE__); 1756 1757 LABEL_INIT(label, MAGIC_SOCKET); 1758 COUNTER_INC(socket_init_label); 1759 return (0); 1760 } 1761 1762 COUNTER_DECL(socket_internalize_label); 1763 static int 1764 test_socket_internalize_label(struct label *label, char *element_name, 1765 char *element_data, int *claimed) 1766 { 1767 1768 LABEL_CHECK(label, MAGIC_SOCKET); 1769 COUNTER_INC(socket_internalize_label); 1770 1771 return (0); 1772 } 1773 1774 COUNTER_DECL(socket_newconn); 1775 static void 1776 test_socket_newconn(struct socket *oldso, struct label *oldsolabel, 1777 struct socket *newso, struct label *newsolabel) 1778 { 1779 1780 SOCK_LOCK(oldso); 1781 LABEL_CHECK(oldsolabel, MAGIC_SOCKET); 1782 SOCK_UNLOCK(oldso); 1783 SOCK_LOCK(newso); 1784 LABEL_CHECK(newsolabel, MAGIC_SOCKET); 1785 SOCK_UNLOCK(newso); 1786 COUNTER_INC(socket_newconn); 1787 } 1788 1789 COUNTER_DECL(socket_relabel); 1790 static void 1791 test_socket_relabel(struct ucred *cred, struct socket *so, 1792 struct label *solabel, struct label *newlabel) 1793 { 1794 1795 SOCK_LOCK_ASSERT(so); 1796 1797 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1798 LABEL_CHECK(solabel, MAGIC_SOCKET); 1799 LABEL_CHECK(newlabel, MAGIC_SOCKET); 1800 COUNTER_INC(socket_relabel); 1801 } 1802 1803 COUNTER_DECL(socketpeer_destroy_label); 1804 static void 1805 test_socketpeer_destroy_label(struct label *label) 1806 { 1807 1808 LABEL_DESTROY(label, MAGIC_SOCKET); 1809 COUNTER_INC(socketpeer_destroy_label); 1810 } 1811 1812 COUNTER_DECL(socketpeer_externalize_label); 1813 static int 1814 test_socketpeer_externalize_label(struct label *label, char *element_name, 1815 struct sbuf *sb, int *claimed) 1816 { 1817 1818 LABEL_CHECK(label, MAGIC_SOCKET); 1819 COUNTER_INC(socketpeer_externalize_label); 1820 1821 return (0); 1822 } 1823 1824 COUNTER_DECL(socketpeer_init_label); 1825 static int 1826 test_socketpeer_init_label(struct label *label, int flag) 1827 { 1828 1829 if (flag & M_WAITOK) 1830 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 1831 "test_socketpeer_init_label() at %s:%d", __FILE__, 1832 __LINE__); 1833 1834 LABEL_INIT(label, MAGIC_SOCKET); 1835 COUNTER_INC(socketpeer_init_label); 1836 return (0); 1837 } 1838 1839 COUNTER_DECL(socketpeer_set_from_mbuf); 1840 static void 1841 test_socketpeer_set_from_mbuf(struct mbuf *m, struct label *mlabel, 1842 struct socket *so, struct label *sopeerlabel) 1843 { 1844 1845 LABEL_CHECK(mlabel, MAGIC_MBUF); 1846 SOCK_LOCK(so); 1847 LABEL_CHECK(sopeerlabel, MAGIC_SOCKET); 1848 SOCK_UNLOCK(so); 1849 COUNTER_INC(socketpeer_set_from_mbuf); 1850 } 1851 1852 COUNTER_DECL(socketpeer_set_from_socket); 1853 static void 1854 test_socketpeer_set_from_socket(struct socket *oldso, 1855 struct label *oldsolabel, struct socket *newso, 1856 struct label *newsopeerlabel) 1857 { 1858 1859 SOCK_LOCK(oldso); 1860 LABEL_CHECK(oldsolabel, MAGIC_SOCKET); 1861 SOCK_UNLOCK(oldso); 1862 SOCK_LOCK(newso); 1863 LABEL_CHECK(newsopeerlabel, MAGIC_SOCKET); 1864 SOCK_UNLOCK(newso); 1865 COUNTER_INC(socketpeer_set_from_socket); 1866 } 1867 1868 COUNTER_DECL(syncache_create); 1869 static void 1870 test_syncache_create(struct label *label, struct inpcb *inp) 1871 { 1872 1873 LABEL_CHECK(label, MAGIC_SYNCACHE); 1874 COUNTER_INC(syncache_create); 1875 } 1876 1877 COUNTER_DECL(syncache_create_mbuf); 1878 static void 1879 test_syncache_create_mbuf(struct label *sc_label, struct mbuf *m, 1880 struct label *mlabel) 1881 { 1882 1883 LABEL_CHECK(sc_label, MAGIC_SYNCACHE); 1884 LABEL_CHECK(mlabel, MAGIC_MBUF); 1885 COUNTER_INC(syncache_create_mbuf); 1886 } 1887 1888 COUNTER_DECL(syncache_destroy_label); 1889 static void 1890 test_syncache_destroy_label(struct label *label) 1891 { 1892 1893 LABEL_DESTROY(label, MAGIC_SYNCACHE); 1894 COUNTER_INC(syncache_destroy_label); 1895 } 1896 1897 COUNTER_DECL(syncache_init_label); 1898 static int 1899 test_syncache_init_label(struct label *label, int flag) 1900 { 1901 1902 if (flag & M_WAITOK) 1903 WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, 1904 "test_syncache_init_label() at %s:%d", __FILE__, 1905 __LINE__); 1906 LABEL_INIT(label, MAGIC_SYNCACHE); 1907 COUNTER_INC(syncache_init_label); 1908 return (0); 1909 } 1910 1911 COUNTER_DECL(system_check_acct); 1912 static int 1913 test_system_check_acct(struct ucred *cred, struct vnode *vp, 1914 struct label *vplabel) 1915 { 1916 1917 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1918 LABEL_CHECK(vplabel, MAGIC_VNODE); 1919 COUNTER_INC(system_check_acct); 1920 1921 return (0); 1922 } 1923 1924 COUNTER_DECL(system_check_audit); 1925 static int 1926 test_system_check_audit(struct ucred *cred, void *record, int length) 1927 { 1928 1929 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1930 COUNTER_INC(system_check_audit); 1931 1932 return (0); 1933 } 1934 1935 COUNTER_DECL(system_check_auditctl); 1936 static int 1937 test_system_check_auditctl(struct ucred *cred, struct vnode *vp, 1938 struct label *vplabel) 1939 { 1940 1941 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1942 LABEL_CHECK(vplabel, MAGIC_VNODE); 1943 COUNTER_INC(system_check_auditctl); 1944 1945 return (0); 1946 } 1947 1948 COUNTER_DECL(system_check_auditon); 1949 static int 1950 test_system_check_auditon(struct ucred *cred, int cmd) 1951 { 1952 1953 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1954 COUNTER_INC(system_check_auditon); 1955 1956 return (0); 1957 } 1958 1959 COUNTER_DECL(system_check_reboot); 1960 static int 1961 test_system_check_reboot(struct ucred *cred, int how) 1962 { 1963 1964 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1965 COUNTER_INC(system_check_reboot); 1966 1967 return (0); 1968 } 1969 1970 COUNTER_DECL(system_check_swapoff); 1971 static int 1972 test_system_check_swapoff(struct ucred *cred, struct vnode *vp, 1973 struct label *vplabel) 1974 { 1975 1976 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1977 LABEL_CHECK(vplabel, MAGIC_VNODE); 1978 COUNTER_INC(system_check_swapoff); 1979 1980 return (0); 1981 } 1982 1983 COUNTER_DECL(system_check_swapon); 1984 static int 1985 test_system_check_swapon(struct ucred *cred, struct vnode *vp, 1986 struct label *vplabel) 1987 { 1988 1989 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 1990 LABEL_CHECK(vplabel, MAGIC_VNODE); 1991 COUNTER_INC(system_check_swapon); 1992 1993 return (0); 1994 } 1995 1996 COUNTER_DECL(system_check_sysctl); 1997 static int 1998 test_system_check_sysctl(struct ucred *cred, struct sysctl_oid *oidp, 1999 void *arg1, int arg2, struct sysctl_req *req) 2000 { 2001 2002 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2003 COUNTER_INC(system_check_sysctl); 2004 2005 return (0); 2006 } 2007 2008 COUNTER_DECL(sysvmsg_cleanup); 2009 static void 2010 test_sysvmsg_cleanup(struct label *msglabel) 2011 { 2012 2013 LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2014 COUNTER_INC(sysvmsg_cleanup); 2015 } 2016 2017 COUNTER_DECL(sysvmsg_create); 2018 static void 2019 test_sysvmsg_create(struct ucred *cred, struct msqid_kernel *msqkptr, 2020 struct label *msqlabel, struct msg *msgptr, struct label *msglabel) 2021 { 2022 2023 LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2024 LABEL_CHECK(msqlabel, MAGIC_SYSV_MSQ); 2025 COUNTER_INC(sysvmsg_create); 2026 } 2027 2028 COUNTER_DECL(sysvmsg_destroy_label); 2029 static void 2030 test_sysvmsg_destroy_label(struct label *label) 2031 { 2032 2033 LABEL_DESTROY(label, MAGIC_SYSV_MSG); 2034 COUNTER_INC(sysvmsg_destroy_label); 2035 } 2036 2037 COUNTER_DECL(sysvmsg_init_label); 2038 static void 2039 test_sysvmsg_init_label(struct label *label) 2040 { 2041 LABEL_INIT(label, MAGIC_SYSV_MSG); 2042 COUNTER_INC(sysvmsg_init_label); 2043 } 2044 2045 COUNTER_DECL(sysvmsq_check_msgmsq); 2046 static int 2047 test_sysvmsq_check_msgmsq(struct ucred *cred, struct msg *msgptr, 2048 struct label *msglabel, struct msqid_kernel *msqkptr, 2049 struct label *msqklabel) 2050 { 2051 2052 LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2053 LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2054 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2055 COUNTER_INC(sysvmsq_check_msgmsq); 2056 2057 return (0); 2058 } 2059 2060 COUNTER_DECL(sysvmsq_check_msgrcv); 2061 static int 2062 test_sysvmsq_check_msgrcv(struct ucred *cred, struct msg *msgptr, 2063 struct label *msglabel) 2064 { 2065 2066 LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2067 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2068 COUNTER_INC(sysvmsq_check_msgrcv); 2069 2070 return (0); 2071 } 2072 2073 COUNTER_DECL(sysvmsq_check_msgrmid); 2074 static int 2075 test_sysvmsq_check_msgrmid(struct ucred *cred, struct msg *msgptr, 2076 struct label *msglabel) 2077 { 2078 2079 LABEL_CHECK(msglabel, MAGIC_SYSV_MSG); 2080 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2081 COUNTER_INC(sysvmsq_check_msgrmid); 2082 2083 return (0); 2084 } 2085 2086 COUNTER_DECL(sysvmsq_check_msqget); 2087 static int 2088 test_sysvmsq_check_msqget(struct ucred *cred, 2089 struct msqid_kernel *msqkptr, struct label *msqklabel) 2090 { 2091 2092 LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2093 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2094 COUNTER_INC(sysvmsq_check_msqget); 2095 2096 return (0); 2097 } 2098 2099 COUNTER_DECL(sysvmsq_check_msqsnd); 2100 static int 2101 test_sysvmsq_check_msqsnd(struct ucred *cred, 2102 struct msqid_kernel *msqkptr, struct label *msqklabel) 2103 { 2104 2105 LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2106 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2107 COUNTER_INC(sysvmsq_check_msqsnd); 2108 2109 return (0); 2110 } 2111 2112 COUNTER_DECL(sysvmsq_check_msqrcv); 2113 static int 2114 test_sysvmsq_check_msqrcv(struct ucred *cred, 2115 struct msqid_kernel *msqkptr, struct label *msqklabel) 2116 { 2117 2118 LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2119 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2120 COUNTER_INC(sysvmsq_check_msqrcv); 2121 2122 return (0); 2123 } 2124 2125 COUNTER_DECL(sysvmsq_check_msqctl); 2126 static int 2127 test_sysvmsq_check_msqctl(struct ucred *cred, 2128 struct msqid_kernel *msqkptr, struct label *msqklabel, int cmd) 2129 { 2130 2131 LABEL_CHECK(msqklabel, MAGIC_SYSV_MSQ); 2132 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2133 COUNTER_INC(sysvmsq_check_msqctl); 2134 2135 return (0); 2136 } 2137 2138 COUNTER_DECL(sysvmsq_cleanup); 2139 static void 2140 test_sysvmsq_cleanup(struct label *msqlabel) 2141 { 2142 2143 LABEL_CHECK(msqlabel, MAGIC_SYSV_MSQ); 2144 COUNTER_INC(sysvmsq_cleanup); 2145 } 2146 2147 COUNTER_DECL(sysvmsq_create); 2148 static void 2149 test_sysvmsq_create(struct ucred *cred, 2150 struct msqid_kernel *msqkptr, struct label *msqlabel) 2151 { 2152 2153 LABEL_CHECK(msqlabel, MAGIC_SYSV_MSQ); 2154 COUNTER_INC(sysvmsq_create); 2155 } 2156 2157 COUNTER_DECL(sysvmsq_destroy_label); 2158 static void 2159 test_sysvmsq_destroy_label(struct label *label) 2160 { 2161 2162 LABEL_DESTROY(label, MAGIC_SYSV_MSQ); 2163 COUNTER_INC(sysvmsq_destroy_label); 2164 } 2165 2166 COUNTER_DECL(sysvmsq_init_label); 2167 static void 2168 test_sysvmsq_init_label(struct label *label) 2169 { 2170 LABEL_INIT(label, MAGIC_SYSV_MSQ); 2171 COUNTER_INC(sysvmsq_init_label); 2172 } 2173 2174 COUNTER_DECL(sysvsem_check_semctl); 2175 static int 2176 test_sysvsem_check_semctl(struct ucred *cred, 2177 struct semid_kernel *semakptr, struct label *semaklabel, int cmd) 2178 { 2179 2180 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2181 LABEL_CHECK(semaklabel, MAGIC_SYSV_SEM); 2182 COUNTER_INC(sysvsem_check_semctl); 2183 2184 return (0); 2185 } 2186 2187 COUNTER_DECL(sysvsem_check_semget); 2188 static int 2189 test_sysvsem_check_semget(struct ucred *cred, 2190 struct semid_kernel *semakptr, struct label *semaklabel) 2191 { 2192 2193 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2194 LABEL_CHECK(semaklabel, MAGIC_SYSV_SEM); 2195 COUNTER_INC(sysvsem_check_semget); 2196 2197 return (0); 2198 } 2199 2200 COUNTER_DECL(sysvsem_check_semop); 2201 static int 2202 test_sysvsem_check_semop(struct ucred *cred, 2203 struct semid_kernel *semakptr, struct label *semaklabel, size_t accesstype) 2204 { 2205 2206 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2207 LABEL_CHECK(semaklabel, MAGIC_SYSV_SEM); 2208 COUNTER_INC(sysvsem_check_semop); 2209 2210 return (0); 2211 } 2212 2213 COUNTER_DECL(sysvsem_cleanup); 2214 static void 2215 test_sysvsem_cleanup(struct label *semalabel) 2216 { 2217 2218 LABEL_CHECK(semalabel, MAGIC_SYSV_SEM); 2219 COUNTER_INC(sysvsem_cleanup); 2220 } 2221 2222 COUNTER_DECL(sysvsem_create); 2223 static void 2224 test_sysvsem_create(struct ucred *cred, struct semid_kernel *semakptr, 2225 struct label *semalabel) 2226 { 2227 2228 LABEL_CHECK(semalabel, MAGIC_SYSV_SEM); 2229 COUNTER_INC(sysvsem_create); 2230 } 2231 2232 COUNTER_DECL(sysvsem_destroy_label); 2233 static void 2234 test_sysvsem_destroy_label(struct label *label) 2235 { 2236 2237 LABEL_DESTROY(label, MAGIC_SYSV_SEM); 2238 COUNTER_INC(sysvsem_destroy_label); 2239 } 2240 2241 COUNTER_DECL(sysvsem_init_label); 2242 static void 2243 test_sysvsem_init_label(struct label *label) 2244 { 2245 LABEL_INIT(label, MAGIC_SYSV_SEM); 2246 COUNTER_INC(sysvsem_init_label); 2247 } 2248 2249 COUNTER_DECL(sysvshm_check_shmat); 2250 static int 2251 test_sysvshm_check_shmat(struct ucred *cred, 2252 struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) 2253 { 2254 2255 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2256 LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2257 COUNTER_INC(sysvshm_check_shmat); 2258 2259 return (0); 2260 } 2261 2262 COUNTER_DECL(sysvshm_check_shmctl); 2263 static int 2264 test_sysvshm_check_shmctl(struct ucred *cred, 2265 struct shmid_kernel *shmsegptr, struct label *shmseglabel, int cmd) 2266 { 2267 2268 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2269 LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2270 COUNTER_INC(sysvshm_check_shmctl); 2271 2272 return (0); 2273 } 2274 2275 COUNTER_DECL(sysvshm_check_shmdt); 2276 static int 2277 test_sysvshm_check_shmdt(struct ucred *cred, 2278 struct shmid_kernel *shmsegptr, struct label *shmseglabel) 2279 { 2280 2281 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2282 LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2283 COUNTER_INC(sysvshm_check_shmdt); 2284 2285 return (0); 2286 } 2287 2288 COUNTER_DECL(sysvshm_check_shmget); 2289 static int 2290 test_sysvshm_check_shmget(struct ucred *cred, 2291 struct shmid_kernel *shmsegptr, struct label *shmseglabel, int shmflg) 2292 { 2293 2294 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2295 LABEL_CHECK(shmseglabel, MAGIC_SYSV_SHM); 2296 COUNTER_INC(sysvshm_check_shmget); 2297 2298 return (0); 2299 } 2300 2301 COUNTER_DECL(sysvshm_cleanup); 2302 static void 2303 test_sysvshm_cleanup(struct label *shmlabel) 2304 { 2305 2306 LABEL_CHECK(shmlabel, MAGIC_SYSV_SHM); 2307 COUNTER_INC(sysvshm_cleanup); 2308 } 2309 2310 COUNTER_DECL(sysvshm_create); 2311 static void 2312 test_sysvshm_create(struct ucred *cred, struct shmid_kernel *shmsegptr, 2313 struct label *shmlabel) 2314 { 2315 2316 LABEL_CHECK(shmlabel, MAGIC_SYSV_SHM); 2317 COUNTER_INC(sysvshm_create); 2318 } 2319 2320 COUNTER_DECL(sysvshm_destroy_label); 2321 static void 2322 test_sysvshm_destroy_label(struct label *label) 2323 { 2324 2325 LABEL_DESTROY(label, MAGIC_SYSV_SHM); 2326 COUNTER_INC(sysvshm_destroy_label); 2327 } 2328 2329 COUNTER_DECL(sysvshm_init_label); 2330 static void 2331 test_sysvshm_init_label(struct label *label) 2332 { 2333 LABEL_INIT(label, MAGIC_SYSV_SHM); 2334 COUNTER_INC(sysvshm_init_label); 2335 } 2336 2337 COUNTER_DECL(thread_userret); 2338 static void 2339 test_thread_userret(struct thread *td) 2340 { 2341 2342 COUNTER_INC(thread_userret); 2343 } 2344 2345 COUNTER_DECL(vnode_associate_extattr); 2346 static int 2347 test_vnode_associate_extattr(struct mount *mp, struct label *mplabel, 2348 struct vnode *vp, struct label *vplabel) 2349 { 2350 2351 LABEL_CHECK(mplabel, MAGIC_MOUNT); 2352 LABEL_CHECK(vplabel, MAGIC_VNODE); 2353 COUNTER_INC(vnode_associate_extattr); 2354 2355 return (0); 2356 } 2357 2358 COUNTER_DECL(vnode_associate_singlelabel); 2359 static void 2360 test_vnode_associate_singlelabel(struct mount *mp, struct label *mplabel, 2361 struct vnode *vp, struct label *vplabel) 2362 { 2363 2364 LABEL_CHECK(mplabel, MAGIC_MOUNT); 2365 LABEL_CHECK(vplabel, MAGIC_VNODE); 2366 COUNTER_INC(vnode_associate_singlelabel); 2367 } 2368 2369 COUNTER_DECL(vnode_check_access); 2370 static int 2371 test_vnode_check_access(struct ucred *cred, struct vnode *vp, 2372 struct label *vplabel, accmode_t accmode) 2373 { 2374 2375 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2376 LABEL_CHECK(vplabel, MAGIC_VNODE); 2377 COUNTER_INC(vnode_check_access); 2378 2379 return (0); 2380 } 2381 2382 COUNTER_DECL(vnode_check_chdir); 2383 static int 2384 test_vnode_check_chdir(struct ucred *cred, struct vnode *dvp, 2385 struct label *dvplabel) 2386 { 2387 2388 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2389 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2390 COUNTER_INC(vnode_check_chdir); 2391 2392 return (0); 2393 } 2394 2395 COUNTER_DECL(vnode_check_chroot); 2396 static int 2397 test_vnode_check_chroot(struct ucred *cred, struct vnode *dvp, 2398 struct label *dvplabel) 2399 { 2400 2401 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2402 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2403 COUNTER_INC(vnode_check_chroot); 2404 2405 return (0); 2406 } 2407 2408 COUNTER_DECL(vnode_check_create); 2409 static int 2410 test_vnode_check_create(struct ucred *cred, struct vnode *dvp, 2411 struct label *dvplabel, struct componentname *cnp, struct vattr *vap) 2412 { 2413 2414 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2415 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2416 COUNTER_INC(vnode_check_create); 2417 2418 return (0); 2419 } 2420 2421 COUNTER_DECL(vnode_check_deleteacl); 2422 static int 2423 test_vnode_check_deleteacl(struct ucred *cred, struct vnode *vp, 2424 struct label *vplabel, acl_type_t type) 2425 { 2426 2427 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2428 LABEL_CHECK(vplabel, MAGIC_VNODE); 2429 COUNTER_INC(vnode_check_deleteacl); 2430 2431 return (0); 2432 } 2433 2434 COUNTER_DECL(vnode_check_deleteextattr); 2435 static int 2436 test_vnode_check_deleteextattr(struct ucred *cred, struct vnode *vp, 2437 struct label *vplabel, int attrnamespace, const char *name) 2438 { 2439 2440 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2441 LABEL_CHECK(vplabel, MAGIC_VNODE); 2442 COUNTER_INC(vnode_check_deleteextattr); 2443 2444 return (0); 2445 } 2446 2447 COUNTER_DECL(vnode_check_exec); 2448 static int 2449 test_vnode_check_exec(struct ucred *cred, struct vnode *vp, 2450 struct label *vplabel, struct image_params *imgp, 2451 struct label *execlabel) 2452 { 2453 2454 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2455 LABEL_CHECK(vplabel, MAGIC_VNODE); 2456 LABEL_CHECK(execlabel, MAGIC_CRED); 2457 COUNTER_INC(vnode_check_exec); 2458 2459 return (0); 2460 } 2461 2462 COUNTER_DECL(vnode_check_getacl); 2463 static int 2464 test_vnode_check_getacl(struct ucred *cred, struct vnode *vp, 2465 struct label *vplabel, acl_type_t type) 2466 { 2467 2468 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2469 LABEL_CHECK(vplabel, MAGIC_VNODE); 2470 COUNTER_INC(vnode_check_getacl); 2471 2472 return (0); 2473 } 2474 2475 COUNTER_DECL(vnode_check_getextattr); 2476 static int 2477 test_vnode_check_getextattr(struct ucred *cred, struct vnode *vp, 2478 struct label *vplabel, int attrnamespace, const char *name) 2479 { 2480 2481 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2482 LABEL_CHECK(vplabel, MAGIC_VNODE); 2483 COUNTER_INC(vnode_check_getextattr); 2484 2485 return (0); 2486 } 2487 2488 COUNTER_DECL(vnode_check_link); 2489 static int 2490 test_vnode_check_link(struct ucred *cred, struct vnode *dvp, 2491 struct label *dvplabel, struct vnode *vp, struct label *vplabel, 2492 struct componentname *cnp) 2493 { 2494 2495 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2496 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2497 LABEL_CHECK(vplabel, MAGIC_VNODE); 2498 COUNTER_INC(vnode_check_link); 2499 2500 return (0); 2501 } 2502 2503 COUNTER_DECL(vnode_check_listextattr); 2504 static int 2505 test_vnode_check_listextattr(struct ucred *cred, struct vnode *vp, 2506 struct label *vplabel, int attrnamespace) 2507 { 2508 2509 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2510 LABEL_CHECK(vplabel, MAGIC_VNODE); 2511 COUNTER_INC(vnode_check_listextattr); 2512 2513 return (0); 2514 } 2515 2516 COUNTER_DECL(vnode_check_lookup); 2517 static int 2518 test_vnode_check_lookup(struct ucred *cred, struct vnode *dvp, 2519 struct label *dvplabel, struct componentname *cnp) 2520 { 2521 2522 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2523 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2524 COUNTER_INC(vnode_check_lookup); 2525 2526 return (0); 2527 } 2528 2529 COUNTER_DECL(vnode_check_mmap); 2530 static int 2531 test_vnode_check_mmap(struct ucred *cred, struct vnode *vp, 2532 struct label *vplabel, int prot, int flags) 2533 { 2534 2535 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2536 LABEL_CHECK(vplabel, MAGIC_VNODE); 2537 COUNTER_INC(vnode_check_mmap); 2538 2539 return (0); 2540 } 2541 2542 COUNTER_DECL(vnode_check_open); 2543 static int 2544 test_vnode_check_open(struct ucred *cred, struct vnode *vp, 2545 struct label *vplabel, accmode_t accmode) 2546 { 2547 2548 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2549 LABEL_CHECK(vplabel, MAGIC_VNODE); 2550 COUNTER_INC(vnode_check_open); 2551 2552 return (0); 2553 } 2554 2555 COUNTER_DECL(vnode_check_poll); 2556 static int 2557 test_vnode_check_poll(struct ucred *active_cred, struct ucred *file_cred, 2558 struct vnode *vp, struct label *vplabel) 2559 { 2560 2561 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 2562 if (file_cred != NULL) 2563 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 2564 LABEL_CHECK(vplabel, MAGIC_VNODE); 2565 COUNTER_INC(vnode_check_poll); 2566 2567 return (0); 2568 } 2569 2570 COUNTER_DECL(vnode_check_read); 2571 static int 2572 test_vnode_check_read(struct ucred *active_cred, struct ucred *file_cred, 2573 struct vnode *vp, struct label *vplabel) 2574 { 2575 2576 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 2577 if (file_cred != NULL) 2578 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 2579 LABEL_CHECK(vplabel, MAGIC_VNODE); 2580 COUNTER_INC(vnode_check_read); 2581 2582 return (0); 2583 } 2584 2585 COUNTER_DECL(vnode_check_readdir); 2586 static int 2587 test_vnode_check_readdir(struct ucred *cred, struct vnode *dvp, 2588 struct label *dvplabel) 2589 { 2590 2591 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2592 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2593 COUNTER_INC(vnode_check_readdir); 2594 2595 return (0); 2596 } 2597 2598 COUNTER_DECL(vnode_check_readlink); 2599 static int 2600 test_vnode_check_readlink(struct ucred *cred, struct vnode *vp, 2601 struct label *vplabel) 2602 { 2603 2604 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2605 LABEL_CHECK(vplabel, MAGIC_VNODE); 2606 COUNTER_INC(vnode_check_readlink); 2607 2608 return (0); 2609 } 2610 2611 COUNTER_DECL(vnode_check_relabel); 2612 static int 2613 test_vnode_check_relabel(struct ucred *cred, struct vnode *vp, 2614 struct label *vplabel, struct label *newlabel) 2615 { 2616 2617 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2618 LABEL_CHECK(vplabel, MAGIC_VNODE); 2619 LABEL_CHECK(newlabel, MAGIC_VNODE); 2620 COUNTER_INC(vnode_check_relabel); 2621 2622 return (0); 2623 } 2624 2625 COUNTER_DECL(vnode_check_rename_from); 2626 static int 2627 test_vnode_check_rename_from(struct ucred *cred, struct vnode *dvp, 2628 struct label *dvplabel, struct vnode *vp, struct label *vplabel, 2629 struct componentname *cnp) 2630 { 2631 2632 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2633 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2634 LABEL_CHECK(vplabel, MAGIC_VNODE); 2635 COUNTER_INC(vnode_check_rename_from); 2636 2637 return (0); 2638 } 2639 2640 COUNTER_DECL(vnode_check_rename_to); 2641 static int 2642 test_vnode_check_rename_to(struct ucred *cred, struct vnode *dvp, 2643 struct label *dvplabel, struct vnode *vp, struct label *vplabel, 2644 int samedir, struct componentname *cnp) 2645 { 2646 2647 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2648 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2649 LABEL_CHECK(vplabel, MAGIC_VNODE); 2650 COUNTER_INC(vnode_check_rename_to); 2651 2652 return (0); 2653 } 2654 2655 COUNTER_DECL(vnode_check_revoke); 2656 static int 2657 test_vnode_check_revoke(struct ucred *cred, struct vnode *vp, 2658 struct label *vplabel) 2659 { 2660 2661 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2662 LABEL_CHECK(vplabel, MAGIC_VNODE); 2663 COUNTER_INC(vnode_check_revoke); 2664 2665 return (0); 2666 } 2667 2668 COUNTER_DECL(vnode_check_setacl); 2669 static int 2670 test_vnode_check_setacl(struct ucred *cred, struct vnode *vp, 2671 struct label *vplabel, acl_type_t type, struct acl *acl) 2672 { 2673 2674 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2675 LABEL_CHECK(vplabel, MAGIC_VNODE); 2676 COUNTER_INC(vnode_check_setacl); 2677 2678 return (0); 2679 } 2680 2681 COUNTER_DECL(vnode_check_setextattr); 2682 static int 2683 test_vnode_check_setextattr(struct ucred *cred, struct vnode *vp, 2684 struct label *vplabel, int attrnamespace, const char *name) 2685 { 2686 2687 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2688 LABEL_CHECK(vplabel, MAGIC_VNODE); 2689 COUNTER_INC(vnode_check_setextattr); 2690 2691 return (0); 2692 } 2693 2694 COUNTER_DECL(vnode_check_setflags); 2695 static int 2696 test_vnode_check_setflags(struct ucred *cred, struct vnode *vp, 2697 struct label *vplabel, u_long flags) 2698 { 2699 2700 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2701 LABEL_CHECK(vplabel, MAGIC_VNODE); 2702 COUNTER_INC(vnode_check_setflags); 2703 2704 return (0); 2705 } 2706 2707 COUNTER_DECL(vnode_check_setmode); 2708 static int 2709 test_vnode_check_setmode(struct ucred *cred, struct vnode *vp, 2710 struct label *vplabel, mode_t mode) 2711 { 2712 2713 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2714 LABEL_CHECK(vplabel, MAGIC_VNODE); 2715 COUNTER_INC(vnode_check_setmode); 2716 2717 return (0); 2718 } 2719 2720 COUNTER_DECL(vnode_check_setowner); 2721 static int 2722 test_vnode_check_setowner(struct ucred *cred, struct vnode *vp, 2723 struct label *vplabel, uid_t uid, gid_t gid) 2724 { 2725 2726 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2727 LABEL_CHECK(vplabel, MAGIC_VNODE); 2728 COUNTER_INC(vnode_check_setowner); 2729 2730 return (0); 2731 } 2732 2733 COUNTER_DECL(vnode_check_setutimes); 2734 static int 2735 test_vnode_check_setutimes(struct ucred *cred, struct vnode *vp, 2736 struct label *vplabel, struct timespec atime, struct timespec mtime) 2737 { 2738 2739 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2740 LABEL_CHECK(vplabel, MAGIC_VNODE); 2741 COUNTER_INC(vnode_check_setutimes); 2742 2743 return (0); 2744 } 2745 2746 COUNTER_DECL(vnode_check_stat); 2747 static int 2748 test_vnode_check_stat(struct ucred *active_cred, struct ucred *file_cred, 2749 struct vnode *vp, struct label *vplabel) 2750 { 2751 2752 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 2753 if (file_cred != NULL) 2754 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 2755 LABEL_CHECK(vplabel, MAGIC_VNODE); 2756 COUNTER_INC(vnode_check_stat); 2757 2758 return (0); 2759 } 2760 2761 COUNTER_DECL(vnode_check_unlink); 2762 static int 2763 test_vnode_check_unlink(struct ucred *cred, struct vnode *dvp, 2764 struct label *dvplabel, struct vnode *vp, struct label *vplabel, 2765 struct componentname *cnp) 2766 { 2767 2768 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2769 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2770 LABEL_CHECK(vplabel, MAGIC_VNODE); 2771 COUNTER_INC(vnode_check_unlink); 2772 2773 return (0); 2774 } 2775 2776 COUNTER_DECL(vnode_check_write); 2777 static int 2778 test_vnode_check_write(struct ucred *active_cred, 2779 struct ucred *file_cred, struct vnode *vp, struct label *vplabel) 2780 { 2781 2782 LABEL_CHECK(active_cred->cr_label, MAGIC_CRED); 2783 if (file_cred != NULL) 2784 LABEL_CHECK(file_cred->cr_label, MAGIC_CRED); 2785 LABEL_CHECK(vplabel, MAGIC_VNODE); 2786 COUNTER_INC(vnode_check_write); 2787 2788 return (0); 2789 } 2790 2791 COUNTER_DECL(vnode_copy_label); 2792 static void 2793 test_vnode_copy_label(struct label *src, struct label *dest) 2794 { 2795 2796 LABEL_CHECK(src, MAGIC_VNODE); 2797 LABEL_CHECK(dest, MAGIC_VNODE); 2798 COUNTER_INC(vnode_copy_label); 2799 } 2800 2801 COUNTER_DECL(vnode_create_extattr); 2802 static int 2803 test_vnode_create_extattr(struct ucred *cred, struct mount *mp, 2804 struct label *mplabel, struct vnode *dvp, struct label *dvplabel, 2805 struct vnode *vp, struct label *vplabel, struct componentname *cnp) 2806 { 2807 2808 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2809 LABEL_CHECK(mplabel, MAGIC_MOUNT); 2810 LABEL_CHECK(dvplabel, MAGIC_VNODE); 2811 COUNTER_INC(vnode_create_extattr); 2812 2813 return (0); 2814 } 2815 2816 COUNTER_DECL(vnode_destroy_label); 2817 static void 2818 test_vnode_destroy_label(struct label *label) 2819 { 2820 2821 LABEL_DESTROY(label, MAGIC_VNODE); 2822 COUNTER_INC(vnode_destroy_label); 2823 } 2824 2825 COUNTER_DECL(vnode_execve_transition); 2826 static void 2827 test_vnode_execve_transition(struct ucred *old, struct ucred *new, 2828 struct vnode *vp, struct label *filelabel, 2829 struct label *interpvplabel, struct image_params *imgp, 2830 struct label *execlabel) 2831 { 2832 2833 LABEL_CHECK(old->cr_label, MAGIC_CRED); 2834 LABEL_CHECK(new->cr_label, MAGIC_CRED); 2835 LABEL_CHECK(filelabel, MAGIC_VNODE); 2836 LABEL_CHECK(interpvplabel, MAGIC_VNODE); 2837 LABEL_CHECK(execlabel, MAGIC_CRED); 2838 COUNTER_INC(vnode_execve_transition); 2839 } 2840 2841 COUNTER_DECL(vnode_execve_will_transition); 2842 static int 2843 test_vnode_execve_will_transition(struct ucred *old, struct vnode *vp, 2844 struct label *filelabel, struct label *interpvplabel, 2845 struct image_params *imgp, struct label *execlabel) 2846 { 2847 2848 LABEL_CHECK(old->cr_label, MAGIC_CRED); 2849 LABEL_CHECK(filelabel, MAGIC_VNODE); 2850 LABEL_CHECK(interpvplabel, MAGIC_VNODE); 2851 LABEL_CHECK(execlabel, MAGIC_CRED); 2852 COUNTER_INC(vnode_execve_will_transition); 2853 2854 return (0); 2855 } 2856 2857 COUNTER_DECL(vnode_externalize_label); 2858 static int 2859 test_vnode_externalize_label(struct label *label, char *element_name, 2860 struct sbuf *sb, int *claimed) 2861 { 2862 2863 LABEL_CHECK(label, MAGIC_VNODE); 2864 COUNTER_INC(vnode_externalize_label); 2865 2866 return (0); 2867 } 2868 2869 COUNTER_DECL(vnode_init_label); 2870 static void 2871 test_vnode_init_label(struct label *label) 2872 { 2873 2874 LABEL_INIT(label, MAGIC_VNODE); 2875 COUNTER_INC(vnode_init_label); 2876 } 2877 2878 COUNTER_DECL(vnode_internalize_label); 2879 static int 2880 test_vnode_internalize_label(struct label *label, char *element_name, 2881 char *element_data, int *claimed) 2882 { 2883 2884 LABEL_CHECK(label, MAGIC_VNODE); 2885 COUNTER_INC(vnode_internalize_label); 2886 2887 return (0); 2888 } 2889 2890 COUNTER_DECL(vnode_relabel); 2891 static void 2892 test_vnode_relabel(struct ucred *cred, struct vnode *vp, 2893 struct label *vplabel, struct label *label) 2894 { 2895 2896 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2897 LABEL_CHECK(vplabel, MAGIC_VNODE); 2898 LABEL_CHECK(label, MAGIC_VNODE); 2899 COUNTER_INC(vnode_relabel); 2900 } 2901 2902 COUNTER_DECL(vnode_setlabel_extattr); 2903 static int 2904 test_vnode_setlabel_extattr(struct ucred *cred, struct vnode *vp, 2905 struct label *vplabel, struct label *intlabel) 2906 { 2907 2908 LABEL_CHECK(cred->cr_label, MAGIC_CRED); 2909 LABEL_CHECK(vplabel, MAGIC_VNODE); 2910 LABEL_CHECK(intlabel, MAGIC_VNODE); 2911 COUNTER_INC(vnode_setlabel_extattr); 2912 2913 return (0); 2914 } 2915 2916 static struct mac_policy_ops test_ops = 2917 { 2918 .mpo_bpfdesc_check_receive = test_bpfdesc_check_receive, 2919 .mpo_bpfdesc_create = test_bpfdesc_create, 2920 .mpo_bpfdesc_create_mbuf = test_bpfdesc_create_mbuf, 2921 .mpo_bpfdesc_destroy_label = test_bpfdesc_destroy_label, 2922 .mpo_bpfdesc_init_label = test_bpfdesc_init_label, 2923 2924 .mpo_cred_check_relabel = test_cred_check_relabel, 2925 .mpo_cred_check_setaudit = test_cred_check_setaudit, 2926 .mpo_cred_check_setaudit_addr = test_cred_check_setaudit_addr, 2927 .mpo_cred_check_setauid = test_cred_check_setauid, 2928 .mpo_cred_check_seteuid = test_cred_check_seteuid, 2929 .mpo_cred_check_setegid = test_cred_check_setegid, 2930 .mpo_cred_check_setgid = test_cred_check_setgid, 2931 .mpo_cred_check_setgroups = test_cred_check_setgroups, 2932 .mpo_cred_check_setregid = test_cred_check_setregid, 2933 .mpo_cred_check_setresgid = test_cred_check_setresgid, 2934 .mpo_cred_check_setresuid = test_cred_check_setresuid, 2935 .mpo_cred_check_setreuid = test_cred_check_setreuid, 2936 .mpo_cred_check_setuid = test_cred_check_setuid, 2937 .mpo_cred_check_visible = test_cred_check_visible, 2938 .mpo_cred_copy_label = test_cred_copy_label, 2939 .mpo_cred_create_init = test_cred_create_init, 2940 .mpo_cred_create_swapper = test_cred_create_swapper, 2941 .mpo_cred_destroy_label = test_cred_destroy_label, 2942 .mpo_cred_externalize_label = test_cred_externalize_label, 2943 .mpo_cred_init_label = test_cred_init_label, 2944 .mpo_cred_internalize_label = test_cred_internalize_label, 2945 .mpo_cred_relabel = test_cred_relabel, 2946 2947 .mpo_devfs_create_device = test_devfs_create_device, 2948 .mpo_devfs_create_directory = test_devfs_create_directory, 2949 .mpo_devfs_create_symlink = test_devfs_create_symlink, 2950 .mpo_devfs_destroy_label = test_devfs_destroy_label, 2951 .mpo_devfs_init_label = test_devfs_init_label, 2952 .mpo_devfs_update = test_devfs_update, 2953 .mpo_devfs_vnode_associate = test_devfs_vnode_associate, 2954 2955 .mpo_ifnet_check_relabel = test_ifnet_check_relabel, 2956 .mpo_ifnet_check_transmit = test_ifnet_check_transmit, 2957 .mpo_ifnet_copy_label = test_ifnet_copy_label, 2958 .mpo_ifnet_create = test_ifnet_create, 2959 .mpo_ifnet_create_mbuf = test_ifnet_create_mbuf, 2960 .mpo_ifnet_destroy_label = test_ifnet_destroy_label, 2961 .mpo_ifnet_externalize_label = test_ifnet_externalize_label, 2962 .mpo_ifnet_init_label = test_ifnet_init_label, 2963 .mpo_ifnet_internalize_label = test_ifnet_internalize_label, 2964 .mpo_ifnet_relabel = test_ifnet_relabel, 2965 2966 .mpo_syncache_destroy_label = test_syncache_destroy_label, 2967 .mpo_syncache_init_label = test_syncache_init_label, 2968 2969 .mpo_sysvmsg_destroy_label = test_sysvmsg_destroy_label, 2970 .mpo_sysvmsg_init_label = test_sysvmsg_init_label, 2971 2972 .mpo_sysvmsq_destroy_label = test_sysvmsq_destroy_label, 2973 .mpo_sysvmsq_init_label = test_sysvmsq_init_label, 2974 2975 .mpo_sysvsem_destroy_label = test_sysvsem_destroy_label, 2976 .mpo_sysvsem_init_label = test_sysvsem_init_label, 2977 2978 .mpo_sysvshm_destroy_label = test_sysvshm_destroy_label, 2979 .mpo_sysvshm_init_label = test_sysvshm_init_label, 2980 2981 .mpo_inpcb_check_deliver = test_inpcb_check_deliver, 2982 .mpo_inpcb_check_visible = test_inpcb_check_visible, 2983 .mpo_inpcb_create = test_inpcb_create, 2984 .mpo_inpcb_create_mbuf = test_inpcb_create_mbuf, 2985 .mpo_inpcb_destroy_label = test_inpcb_destroy_label, 2986 .mpo_inpcb_init_label = test_inpcb_init_label, 2987 .mpo_inpcb_sosetlabel = test_inpcb_sosetlabel, 2988 2989 .mpo_ip6q_create = test_ip6q_create, 2990 .mpo_ip6q_destroy_label = test_ip6q_destroy_label, 2991 .mpo_ip6q_init_label = test_ip6q_init_label, 2992 .mpo_ip6q_match = test_ip6q_match, 2993 .mpo_ip6q_reassemble = test_ip6q_reassemble, 2994 .mpo_ip6q_update = test_ip6q_update, 2995 2996 .mpo_ipq_create = test_ipq_create, 2997 .mpo_ipq_destroy_label = test_ipq_destroy_label, 2998 .mpo_ipq_init_label = test_ipq_init_label, 2999 .mpo_ipq_match = test_ipq_match, 3000 .mpo_ipq_reassemble = test_ipq_reassemble, 3001 .mpo_ipq_update = test_ipq_update, 3002 3003 .mpo_kenv_check_dump = test_kenv_check_dump, 3004 .mpo_kenv_check_get = test_kenv_check_get, 3005 .mpo_kenv_check_set = test_kenv_check_set, 3006 .mpo_kenv_check_unset = test_kenv_check_unset, 3007 3008 .mpo_kld_check_load = test_kld_check_load, 3009 .mpo_kld_check_stat = test_kld_check_stat, 3010 3011 .mpo_mbuf_copy_label = test_mbuf_copy_label, 3012 .mpo_mbuf_destroy_label = test_mbuf_destroy_label, 3013 .mpo_mbuf_init_label = test_mbuf_init_label, 3014 3015 .mpo_mount_check_stat = test_mount_check_stat, 3016 .mpo_mount_create = test_mount_create, 3017 .mpo_mount_destroy_label = test_mount_destroy_label, 3018 .mpo_mount_init_label = test_mount_init_label, 3019 3020 .mpo_netatalk_aarp_send = test_netatalk_aarp_send, 3021 3022 .mpo_netinet_arp_send = test_netinet_arp_send, 3023 .mpo_netinet_fragment = test_netinet_fragment, 3024 .mpo_netinet_icmp_reply = test_netinet_icmp_reply, 3025 .mpo_netinet_icmp_replyinplace = test_netinet_icmp_replyinplace, 3026 .mpo_netinet_igmp_send = test_netinet_igmp_send, 3027 .mpo_netinet_tcp_reply = test_netinet_tcp_reply, 3028 3029 .mpo_netinet6_nd6_send = test_netinet6_nd6_send, 3030 3031 .mpo_pipe_check_ioctl = test_pipe_check_ioctl, 3032 .mpo_pipe_check_poll = test_pipe_check_poll, 3033 .mpo_pipe_check_read = test_pipe_check_read, 3034 .mpo_pipe_check_relabel = test_pipe_check_relabel, 3035 .mpo_pipe_check_stat = test_pipe_check_stat, 3036 .mpo_pipe_check_write = test_pipe_check_write, 3037 .mpo_pipe_copy_label = test_pipe_copy_label, 3038 .mpo_pipe_create = test_pipe_create, 3039 .mpo_pipe_destroy_label = test_pipe_destroy_label, 3040 .mpo_pipe_externalize_label = test_pipe_externalize_label, 3041 .mpo_pipe_init_label = test_pipe_init_label, 3042 .mpo_pipe_internalize_label = test_pipe_internalize_label, 3043 .mpo_pipe_relabel = test_pipe_relabel, 3044 3045 .mpo_posixsem_check_getvalue = test_posixsem_check_getvalue, 3046 .mpo_posixsem_check_open = test_posixsem_check_open, 3047 .mpo_posixsem_check_post = test_posixsem_check_post, 3048 .mpo_posixsem_check_stat = test_posixsem_check_stat, 3049 .mpo_posixsem_check_unlink = test_posixsem_check_unlink, 3050 .mpo_posixsem_check_wait = test_posixsem_check_wait, 3051 .mpo_posixsem_create = test_posixsem_create, 3052 .mpo_posixsem_destroy_label = test_posixsem_destroy_label, 3053 .mpo_posixsem_init_label = test_posixsem_init_label, 3054 3055 .mpo_posixshm_check_mmap = test_posixshm_check_mmap, 3056 .mpo_posixshm_check_open = test_posixshm_check_open, 3057 .mpo_posixshm_check_stat = test_posixshm_check_stat, 3058 .mpo_posixshm_check_truncate = test_posixshm_check_truncate, 3059 .mpo_posixshm_check_unlink = test_posixshm_check_unlink, 3060 .mpo_posixshm_create = test_posixshm_create, 3061 .mpo_posixshm_destroy_label = test_posixshm_destroy_label, 3062 .mpo_posixshm_init_label = test_posixshm_init_label, 3063 3064 .mpo_proc_check_debug = test_proc_check_debug, 3065 .mpo_proc_check_sched = test_proc_check_sched, 3066 .mpo_proc_check_signal = test_proc_check_signal, 3067 .mpo_proc_check_wait = test_proc_check_wait, 3068 .mpo_proc_destroy_label = test_proc_destroy_label, 3069 .mpo_proc_init_label = test_proc_init_label, 3070 3071 .mpo_socket_check_accept = test_socket_check_accept, 3072 .mpo_socket_check_bind = test_socket_check_bind, 3073 .mpo_socket_check_connect = test_socket_check_connect, 3074 .mpo_socket_check_deliver = test_socket_check_deliver, 3075 .mpo_socket_check_listen = test_socket_check_listen, 3076 .mpo_socket_check_poll = test_socket_check_poll, 3077 .mpo_socket_check_receive = test_socket_check_receive, 3078 .mpo_socket_check_relabel = test_socket_check_relabel, 3079 .mpo_socket_check_send = test_socket_check_send, 3080 .mpo_socket_check_stat = test_socket_check_stat, 3081 .mpo_socket_check_visible = test_socket_check_visible, 3082 .mpo_socket_copy_label = test_socket_copy_label, 3083 .mpo_socket_create = test_socket_create, 3084 .mpo_socket_create_mbuf = test_socket_create_mbuf, 3085 .mpo_socket_destroy_label = test_socket_destroy_label, 3086 .mpo_socket_externalize_label = test_socket_externalize_label, 3087 .mpo_socket_init_label = test_socket_init_label, 3088 .mpo_socket_internalize_label = test_socket_internalize_label, 3089 .mpo_socket_newconn = test_socket_newconn, 3090 .mpo_socket_relabel = test_socket_relabel, 3091 3092 .mpo_socketpeer_destroy_label = test_socketpeer_destroy_label, 3093 .mpo_socketpeer_externalize_label = test_socketpeer_externalize_label, 3094 .mpo_socketpeer_init_label = test_socketpeer_init_label, 3095 .mpo_socketpeer_set_from_mbuf = test_socketpeer_set_from_mbuf, 3096 .mpo_socketpeer_set_from_socket = test_socketpeer_set_from_socket, 3097 3098 .mpo_syncache_create = test_syncache_create, 3099 .mpo_syncache_create_mbuf = test_syncache_create_mbuf, 3100 3101 .mpo_system_check_acct = test_system_check_acct, 3102 .mpo_system_check_audit = test_system_check_audit, 3103 .mpo_system_check_auditctl = test_system_check_auditctl, 3104 .mpo_system_check_auditon = test_system_check_auditon, 3105 .mpo_system_check_reboot = test_system_check_reboot, 3106 .mpo_system_check_swapoff = test_system_check_swapoff, 3107 .mpo_system_check_swapon = test_system_check_swapon, 3108 .mpo_system_check_sysctl = test_system_check_sysctl, 3109 3110 .mpo_vnode_check_access = test_vnode_check_access, 3111 .mpo_sysvmsg_cleanup = test_sysvmsg_cleanup, 3112 .mpo_sysvmsg_create = test_sysvmsg_create, 3113 3114 .mpo_sysvmsq_check_msgmsq = test_sysvmsq_check_msgmsq, 3115 .mpo_sysvmsq_check_msgrcv = test_sysvmsq_check_msgrcv, 3116 .mpo_sysvmsq_check_msgrmid = test_sysvmsq_check_msgrmid, 3117 .mpo_sysvmsq_check_msqget = test_sysvmsq_check_msqget, 3118 .mpo_sysvmsq_check_msqsnd = test_sysvmsq_check_msqsnd, 3119 .mpo_sysvmsq_check_msqrcv = test_sysvmsq_check_msqrcv, 3120 .mpo_sysvmsq_check_msqctl = test_sysvmsq_check_msqctl, 3121 .mpo_sysvmsq_cleanup = test_sysvmsq_cleanup, 3122 .mpo_sysvmsq_create = test_sysvmsq_create, 3123 3124 .mpo_sysvsem_check_semctl = test_sysvsem_check_semctl, 3125 .mpo_sysvsem_check_semget = test_sysvsem_check_semget, 3126 .mpo_sysvsem_check_semop = test_sysvsem_check_semop, 3127 .mpo_sysvsem_cleanup = test_sysvsem_cleanup, 3128 .mpo_sysvsem_create = test_sysvsem_create, 3129 3130 .mpo_sysvshm_check_shmat = test_sysvshm_check_shmat, 3131 .mpo_sysvshm_check_shmctl = test_sysvshm_check_shmctl, 3132 .mpo_sysvshm_check_shmdt = test_sysvshm_check_shmdt, 3133 .mpo_sysvshm_check_shmget = test_sysvshm_check_shmget, 3134 .mpo_sysvshm_cleanup = test_sysvshm_cleanup, 3135 .mpo_sysvshm_create = test_sysvshm_create, 3136 3137 .mpo_thread_userret = test_thread_userret, 3138 3139 .mpo_vnode_associate_extattr = test_vnode_associate_extattr, 3140 .mpo_vnode_associate_singlelabel = test_vnode_associate_singlelabel, 3141 .mpo_vnode_check_chdir = test_vnode_check_chdir, 3142 .mpo_vnode_check_chroot = test_vnode_check_chroot, 3143 .mpo_vnode_check_create = test_vnode_check_create, 3144 .mpo_vnode_check_deleteacl = test_vnode_check_deleteacl, 3145 .mpo_vnode_check_deleteextattr = test_vnode_check_deleteextattr, 3146 .mpo_vnode_check_exec = test_vnode_check_exec, 3147 .mpo_vnode_check_getacl = test_vnode_check_getacl, 3148 .mpo_vnode_check_getextattr = test_vnode_check_getextattr, 3149 .mpo_vnode_check_link = test_vnode_check_link, 3150 .mpo_vnode_check_listextattr = test_vnode_check_listextattr, 3151 .mpo_vnode_check_lookup = test_vnode_check_lookup, 3152 .mpo_vnode_check_mmap = test_vnode_check_mmap, 3153 .mpo_vnode_check_open = test_vnode_check_open, 3154 .mpo_vnode_check_poll = test_vnode_check_poll, 3155 .mpo_vnode_check_read = test_vnode_check_read, 3156 .mpo_vnode_check_readdir = test_vnode_check_readdir, 3157 .mpo_vnode_check_readlink = test_vnode_check_readlink, 3158 .mpo_vnode_check_relabel = test_vnode_check_relabel, 3159 .mpo_vnode_check_rename_from = test_vnode_check_rename_from, 3160 .mpo_vnode_check_rename_to = test_vnode_check_rename_to, 3161 .mpo_vnode_check_revoke = test_vnode_check_revoke, 3162 .mpo_vnode_check_setacl = test_vnode_check_setacl, 3163 .mpo_vnode_check_setextattr = test_vnode_check_setextattr, 3164 .mpo_vnode_check_setflags = test_vnode_check_setflags, 3165 .mpo_vnode_check_setmode = test_vnode_check_setmode, 3166 .mpo_vnode_check_setowner = test_vnode_check_setowner, 3167 .mpo_vnode_check_setutimes = test_vnode_check_setutimes, 3168 .mpo_vnode_check_stat = test_vnode_check_stat, 3169 .mpo_vnode_check_unlink = test_vnode_check_unlink, 3170 .mpo_vnode_check_write = test_vnode_check_write, 3171 .mpo_vnode_copy_label = test_vnode_copy_label, 3172 .mpo_vnode_create_extattr = test_vnode_create_extattr, 3173 .mpo_vnode_destroy_label = test_vnode_destroy_label, 3174 .mpo_vnode_execve_transition = test_vnode_execve_transition, 3175 .mpo_vnode_execve_will_transition = test_vnode_execve_will_transition, 3176 .mpo_vnode_externalize_label = test_vnode_externalize_label, 3177 .mpo_vnode_init_label = test_vnode_init_label, 3178 .mpo_vnode_internalize_label = test_vnode_internalize_label, 3179 .mpo_vnode_relabel = test_vnode_relabel, 3180 .mpo_vnode_setlabel_extattr = test_vnode_setlabel_extattr, 3181 }; 3182 3183 MAC_POLICY_SET(&test_ops, mac_test, "TrustedBSD MAC/Test", 3184 MPC_LOADTIME_FLAG_UNLOADOK, &test_slot); 3185