MCPcopy Create free account
hub / github.com/F-Stack/f-stack / mac_policy_unregister

Function mac_policy_unregister

freebsd/security/mac/mac_framework.c:594–640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

592}
593
594static int
595mac_policy_unregister(struct mac_policy_conf *mpc)
596{
597
598 /*
599 * If we fail the load, we may get a request to unload. Check to see
600 * if we did the run-time registration, and if not, silently succeed.
601 */
602 mac_policy_xlock();
603 if ((mpc->mpc_runtime_flags & MPC_RUNTIME_FLAG_REGISTERED) == 0) {
604 mac_policy_xunlock();
605 return (0);
606 }
607#if 0
608 /*
609 * Don't allow unloading modules with private data.
610 */
611 if (mpc->mpc_field_off != NULL) {
612 mac_policy_xunlock();
613 return (EBUSY);
614 }
615#endif
616 /*
617 * Only allow the unload to proceed if the module is unloadable by
618 * its own definition.
619 */
620 if ((mpc->mpc_loadtime_flags & MPC_LOADTIME_FLAG_UNLOADOK) == 0) {
621 mac_policy_xunlock();
622 return (EBUSY);
623 }
624
625 mac_policy_fastpath_unregister(mpc);
626
627 if (mpc->mpc_ops->mpo_destroy != NULL)
628 (*(mpc->mpc_ops->mpo_destroy))(mpc);
629
630 LIST_REMOVE(mpc, mpc_list);
631 mpc->mpc_runtime_flags &= ~MPC_RUNTIME_FLAG_REGISTERED;
632 mac_policy_update();
633 mac_policy_xunlock();
634
635 SDT_PROBE1(mac, , policy, unregister, mpc);
636 printf("Security policy unload: %s (%s)\n", mpc->mpc_fullname,
637 mpc->mpc_name);
638
639 return (0);
640}
641
642/*
643 * Allow MAC policy modules to register during boot, etc.

Callers 1

mac_policy_modeventFunction · 0.85

Calls 5

mac_policy_xlockFunction · 0.85
mac_policy_xunlockFunction · 0.85
mac_policy_updateFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected