summaryrefslogtreecommitdiffstats
path: root/sys/security/mac_biba
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2003-11-18 00:39:07 +0000
committerrwatson <rwatson@FreeBSD.org>2003-11-18 00:39:07 +0000
commit9c969b771a32651104f16586408deb67d7039014 (patch)
tree9ae16c9f3cb9780bbad2d9f596380ed1094d201c /sys/security/mac_biba
parentc428ace885437d38f0343448bc61807c6e7a690c (diff)
downloadFreeBSD-src-9c969b771a32651104f16586408deb67d7039014.zip
FreeBSD-src-9c969b771a32651104f16586408deb67d7039014.tar.gz
Introduce a MAC label reference in 'struct inpcb', which caches
the MAC label referenced from 'struct socket' in the IPv4 and IPv6-based protocols. This permits MAC labels to be checked during network delivery operations without dereferencing inp->inp_socket to get to so->so_label, which will eventually avoid our having to grab the socket lock during delivery at the network layer. This change introduces 'struct inpcb' as a labeled object to the MAC Framework, along with the normal circus of entry points: initialization, creation from socket, destruction, as well as a delivery access control check. For most policies, the inpcb label will simply be a cache of the socket label, so a new protocol switch method is introduced, pr_sosetlabel() to notify protocols that the socket layer label has been updated so that the cache can be updated while holding appropriate locks. Most protocols implement this using pru_sosetlabel_null(), but IPv4/IPv6 protocols using inpcbs use the the worker function in_pcbsosetlabel(), which calls into the MAC Framework to perform a cache update. Biba, LOMAC, and MLS implement these entry points, as do the stub policy, and test policy. Reviewed by: sam, bms Obtained from: TrustedBSD Project Sponsored by: DARPA, Network Associates Laboratories
Diffstat (limited to 'sys/security/mac_biba')
-rw-r--r--sys/security/mac_biba/mac_biba.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/sys/security/mac_biba/mac_biba.c b/sys/security/mac_biba/mac_biba.c
index 778532c..365c397 100644
--- a/sys/security/mac_biba/mac_biba.c
+++ b/sys/security/mac_biba/mac_biba.c
@@ -69,6 +69,7 @@
#include <net/if_var.h>
#include <netinet/in.h>
+#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <vm/vm.h>
@@ -980,6 +981,18 @@ mac_biba_setlabel_vnode_extattr(struct ucred *cred, struct vnode *vp,
* Labeling event operations: IPC object.
*/
static void
+mac_biba_create_inpcb_from_socket(struct socket *so, struct label *solabel,
+ struct inpcb *inp, struct label *inplabel)
+{
+ struct mac_biba *source, *dest;
+
+ source = SLOT(solabel);
+ dest = SLOT(inplabel);
+
+ mac_biba_copy_single(source, dest);
+}
+
+static void
mac_biba_create_mbuf_from_socket(struct socket *so, struct label *socketlabel,
struct mbuf *m, struct label *mbuflabel)
{
@@ -1299,6 +1312,18 @@ mac_biba_update_ipq(struct mbuf *fragment, struct label *fragmentlabel,
/* NOOP: we only accept matching labels, so no need to update */
}
+static void
+mac_biba_inpcb_sosetlabel(struct socket *so, struct label *solabel,
+ struct inpcb *inp, struct label *inplabel)
+{
+ struct mac_biba *source, *dest;
+
+ source = SLOT(solabel);
+ dest = SLOT(inplabel);
+
+ mac_biba_copy(source, dest);
+}
+
/*
* Labeling event operations: processes.
*/
@@ -1493,6 +1518,21 @@ mac_biba_check_ifnet_transmit(struct ifnet *ifnet, struct label *ifnetlabel,
}
static int
+mac_biba_check_inpcb_deliver(struct inpcb *inp, struct label *inplabel,
+ struct mbuf *m, struct label *mlabel)
+{
+ struct mac_biba *p, *i;
+
+ if (!mac_biba_enabled)
+ return (0);
+
+ p = SLOT(mlabel);
+ i = SLOT(inplabel);
+
+ return (mac_biba_equal_single(p, i) ? 0 : EACCES);
+}
+
+static int
mac_biba_check_kld_load(struct ucred *cred, struct vnode *vp,
struct label *label)
{
@@ -2606,6 +2646,7 @@ static struct mac_policy_ops mac_biba_ops =
.mpo_init_cred_label = mac_biba_init_label,
.mpo_init_devfsdirent_label = mac_biba_init_label,
.mpo_init_ifnet_label = mac_biba_init_label,
+ .mpo_init_inpcb_label = mac_biba_init_label_waitcheck,
.mpo_init_ipq_label = mac_biba_init_label_waitcheck,
.mpo_init_mbuf_label = mac_biba_init_label_waitcheck,
.mpo_init_mount_label = mac_biba_init_label,
@@ -2618,6 +2659,7 @@ static struct mac_policy_ops mac_biba_ops =
.mpo_destroy_cred_label = mac_biba_destroy_label,
.mpo_destroy_devfsdirent_label = mac_biba_destroy_label,
.mpo_destroy_ifnet_label = mac_biba_destroy_label,
+ .mpo_destroy_inpcb_label = mac_biba_destroy_label,
.mpo_destroy_ipq_label = mac_biba_destroy_label,
.mpo_destroy_mbuf_label = mac_biba_destroy_label,
.mpo_destroy_mount_label = mac_biba_destroy_label,
@@ -2665,6 +2707,7 @@ static struct mac_policy_ops mac_biba_ops =
.mpo_create_datagram_from_ipq = mac_biba_create_datagram_from_ipq,
.mpo_create_fragment = mac_biba_create_fragment,
.mpo_create_ifnet = mac_biba_create_ifnet,
+ .mpo_create_inpcb_from_socket = mac_biba_create_inpcb_from_socket,
.mpo_create_ipq = mac_biba_create_ipq,
.mpo_create_mbuf_from_mbuf = mac_biba_create_mbuf_from_mbuf,
.mpo_create_mbuf_linklayer = mac_biba_create_mbuf_linklayer,
@@ -2675,6 +2718,7 @@ static struct mac_policy_ops mac_biba_ops =
.mpo_fragment_match = mac_biba_fragment_match,
.mpo_relabel_ifnet = mac_biba_relabel_ifnet,
.mpo_update_ipq = mac_biba_update_ipq,
+ .mpo_inpcb_sosetlabel = mac_biba_inpcb_sosetlabel,
.mpo_create_cred = mac_biba_create_cred,
.mpo_create_proc0 = mac_biba_create_proc0,
.mpo_create_proc1 = mac_biba_create_proc1,
@@ -2684,6 +2728,7 @@ static struct mac_policy_ops mac_biba_ops =
.mpo_check_cred_visible = mac_biba_check_cred_visible,
.mpo_check_ifnet_relabel = mac_biba_check_ifnet_relabel,
.mpo_check_ifnet_transmit = mac_biba_check_ifnet_transmit,
+ .mpo_check_inpcb_deliver = mac_biba_check_inpcb_deliver,
.mpo_check_kld_load = mac_biba_check_kld_load,
.mpo_check_kld_unload = mac_biba_check_kld_unload,
.mpo_check_mount_stat = mac_biba_check_mount_stat,
OpenPOWER on IntegriCloud