summaryrefslogtreecommitdiffstats
path: root/sys/netinet/tcp_input.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_input.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_input.c')
-rw-r--r--sys/netinet/tcp_input.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index 431c049..226be18 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -37,11 +37,13 @@
#include "opt_ipfw.h" /* for ipfw_fwd */
#include "opt_inet6.h"
#include "opt_ipsec.h"
+#include "opt_mac.h"
#include "opt_tcpdebug.h"
#include "opt_tcp_input.h"
#include <sys/param.h>
#include <sys/kernel.h>
+#include <sys/mac.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/proc.h> /* for proc0 declaration */
@@ -360,6 +362,9 @@ tcp_input(m, off0)
int isipv6;
#endif /* INET6 */
struct sockaddr_in *next_hop = NULL;
+#ifdef MAC
+ int error;
+#endif
int rstreason; /* For badport_bandlim accounting purposes */
/* Grab info from MT_TAG mbufs prepended to the chain. */
@@ -651,6 +656,11 @@ findpcb:
tiwin = th->th_win;
so = inp->inp_socket;
+#ifdef MAC
+ error = mac_check_socket_receive(so, m);
+ if (error)
+ goto drop;
+#endif
if (so->so_options & (SO_DEBUG|SO_ACCEPTCONN)) {
struct in_conninfo inc;
#ifdef TCPDEBUG
@@ -1171,6 +1181,9 @@ after_listen:
tp->t_flags &= ~TF_RCVD_CC;
tcpstat.tcps_connects++;
soisconnected(so);
+#ifdef MAC
+ mac_set_socket_peer_from_mbuf(m, so);
+#endif
/* Do window scaling on this connection? */
if ((tp->t_flags & (TF_RCVD_SCALE|TF_REQ_SCALE)) ==
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
OpenPOWER on IntegriCloud