summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_subr.c
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2002-07-31 19:06:49 +0000
committerrwatson <rwatson@FreeBSD.org>2002-07-31 19:06:49 +0000
commita034d0cd3c7f0d940efed7491eb32a5501cc7f88 (patch)
tree5dbdb791ab0455bfa5e2c41167f506be54ce9568 /sys/netinet/tcp_subr.c
parentcf35cc4c684ae09caa3774b8e8971b0a1adfe19a (diff)
downloadFreeBSD-src-a034d0cd3c7f0d940efed7491eb32a5501cc7f88.zip
FreeBSD-src-a034d0cd3c7f0d940efed7491eb32a5501cc7f88.tar.gz
Introduce support for Mandatory Access Control and extensible
kernel access control. Instrument the TCP socket code for packet generation and delivery: label outgoing mbufs with the label of the socket, and check socket and mbuf labels before permitting delivery to a socket. Assign labels to newly accepted connections when the syncache/cookie code has done its business. Also set peer labels as convenient. Currently, MAC policies cannot influence the PCB matching algorithm, so cannot implement polyinstantiation. Note that there is at least one case where a PCB is not available due to the TCP packet not being associated with any socket, so we don't label in that case, but need to handle it in a special manner. Obtained from: TrustedBSD Project Sponsored by: DARPA, NAI Labs
Diffstat (limited to 'sys/netinet/tcp_subr.c')
-rw-r--r--sys/netinet/tcp_subr.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c
index 0c4b385..f960fc4 100644
--- a/sys/netinet/tcp_subr.c
+++ b/sys/netinet/tcp_subr.c
@@ -37,6 +37,7 @@
#include "opt_compat.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
+#include "opt_mac.h"
#include "opt_tcpdebug.h"
#include <sys/param.h>
@@ -44,6 +45,7 @@
#include <sys/callout.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
+#include <sys/mac.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#ifdef INET6
@@ -443,6 +445,21 @@ tcp_respond(tp, ipgen, th, m, ack, seq, flags)
m->m_len = tlen;
m->m_pkthdr.len = tlen;
m->m_pkthdr.rcvif = (struct ifnet *) 0;
+#ifdef MAC
+ if (tp != NULL) {
+ /*
+ * Packet is associated with a socket, so allow the
+ * label of the response to reflect the socket label.
+ */
+ mac_create_mbuf_from_socket(tp->t_inpcb->inp_socket, m);
+ } else {
+ /*
+ * XXXMAC: This will need to call a mac function that
+ * modifies the mbuf label in place for TCP datagrams
+ * not associated with a PCB.
+ */
+ }
+#endif
nth->th_seq = htonl(seq);
nth->th_ack = htonl(ack);
nth->th_x2 = 0;
OpenPOWER on IntegriCloud