Use UMA zone allocator for Biba and MLS labels rather than MALLOC(9).

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
This commit is contained in:
Robert Watson 2003-11-18 04:11:52 +00:00
parent d89c67bcba
commit 2e8c6b2654
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=122879
2 changed files with 12 additions and 12 deletions

View File

@ -72,6 +72,7 @@
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <vm/uma.h>
#include <vm/vm.h>
#include <sys/mac_policy.h>
@ -124,7 +125,7 @@ TUNABLE_INT("security.mac.biba.revocation_enabled", &revocation_enabled);
static int mac_biba_slot;
#define SLOT(l) ((struct mac_biba *)LABEL_TO_SLOT((l), mac_biba_slot).l_ptr)
MALLOC_DEFINE(M_MACBIBA, "biba label", "MAC/Biba labels");
static uma_zone_t zone_biba;
static __inline int
biba_bit_set_empty(u_char *set) {
@ -139,11 +140,8 @@ biba_bit_set_empty(u_char *set) {
static struct mac_biba *
biba_alloc(int flag)
{
struct mac_biba *mac_biba;
mac_biba = malloc(sizeof(struct mac_biba), M_MACBIBA, M_ZERO | flag);
return (mac_biba);
return (uma_zalloc(zone_biba, flag | M_ZERO));
}
static void
@ -151,7 +149,7 @@ biba_free(struct mac_biba *mac_biba)
{
if (mac_biba != NULL)
free(mac_biba, M_MACBIBA);
uma_zfree(zone_biba, mac_biba);
else
atomic_add_int(&destroyed_not_inited, 1);
}
@ -492,6 +490,8 @@ static void
mac_biba_init(struct mac_policy_conf *conf)
{
zone_biba = uma_zcreate("mac_biba", sizeof(struct mac_biba), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
}
/*

View File

@ -72,6 +72,7 @@
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <vm/uma.h>
#include <vm/vm.h>
#include <sys/mac_policy.h>
@ -113,7 +114,7 @@ SYSCTL_INT(_security_mac_mls, OID_AUTO, max_compartments, CTLFLAG_RD,
static int mac_mls_slot;
#define SLOT(l) ((struct mac_mls *)LABEL_TO_SLOT((l), mac_mls_slot).l_ptr)
MALLOC_DEFINE(M_MACMLS, "mls label", "MAC/MLS labels");
static uma_zone_t zone_mls;
static __inline int
mls_bit_set_empty(u_char *set) {
@ -128,11 +129,8 @@ mls_bit_set_empty(u_char *set) {
static struct mac_mls *
mls_alloc(int flag)
{
struct mac_mls *mac_mls;
mac_mls = malloc(sizeof(struct mac_mls), M_MACMLS, M_ZERO | flag);
return (mac_mls);
return (uma_zalloc(zone_mls, flag | M_ZERO));
}
static void
@ -140,7 +138,7 @@ mls_free(struct mac_mls *mac_mls)
{
if (mac_mls != NULL)
free(mac_mls, M_MACMLS);
uma_zfree(zone_mls, mac_mls);
else
atomic_add_int(&destroyed_not_inited, 1);
}
@ -458,6 +456,8 @@ static void
mac_mls_init(struct mac_policy_conf *conf)
{
zone_mls = uma_zcreate("mac_mls", sizeof(struct mac_mls), NULL,
NULL, NULL, NULL, UMA_ALIGN_PTR, 0);
}
/*