diff options
author | rwatson <rwatson@FreeBSD.org> | 2002-10-05 17:44:49 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2002-10-05 17:44:49 +0000 |
commit | d273cfe761df48abbf27913a38e7e22118d95efc (patch) | |
tree | 59bbb9f14f4a347ee58f124d8180cfe091c061e3 /sys/security/mac/mac_net.c | |
parent | 7a8226480f73f6abb10c9d47928f8433521aac9b (diff) | |
download | FreeBSD-src-d273cfe761df48abbf27913a38e7e22118d95efc.zip FreeBSD-src-d273cfe761df48abbf27913a38e7e22118d95efc.tar.gz |
While the MAC API has supported the ability to handle M_NOWAIT passed
to mbuf label initialization, that functionality was never merged to
the main tree. Go ahead and merge that functionality now. Note that
this requires policy modules to accept the case where the label
element may be destroyed even if init has not succeeded on it (in
the event that policy failed the init). This will shortly also
apply to sockets.
Obtained from: TrustedBSD Project
Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'sys/security/mac/mac_net.c')
-rw-r--r-- | sys/security/mac/mac_net.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/security/mac/mac_net.c b/sys/security/mac/mac_net.c index dd5d2b3..d21d5df 100644 --- a/sys/security/mac/mac_net.c +++ b/sys/security/mac/mac_net.c @@ -1101,15 +1101,23 @@ mac_init_ipq(struct ipq *ipq) int mac_init_mbuf(struct mbuf *m, int flag) { + int error; + KASSERT(m->m_flags & M_PKTHDR, ("mac_init_mbuf on non-header mbuf")); mac_init_label(&m->m_pkthdr.label); - MAC_PERFORM(init_mbuf_label, &m->m_pkthdr.label, flag); + MAC_CHECK(init_mbuf_label, &m->m_pkthdr.label, flag); + if (error) { + MAC_PERFORM(destroy_mbuf_label, &m->m_pkthdr.label); + mac_destroy_label(&m->m_pkthdr.label); + } + #ifdef MAC_DEBUG - atomic_add_int(&nmacmbufs, 1); + if (error == 0) + atomic_add_int(&nmacmbufs, 1); #endif - return (0); + return (error); } void |