All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darrel Goeddel <DGoeddel@TrustedCS.com>
To: James Morris <jmorris@namei.org>
Cc: Paul Moore <paul.moore@hp.com>,
	Stephen Smalley <sds@tycho.nsa.gov>,
	selinux@tycho.nsa.gov, kaigai@ak.jp.nec.com, joe@nall.com,
	Eric Paris <eparis@parisplace.org>
Subject: Re: [RFC 0/5] Static/fallback external labels for NetLabel
Date: Tue, 14 Aug 2007 10:47:57 -0400	[thread overview]
Message-ID: <46C1C09D.4060909@trustedcs.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0708100857170.25010@us.intercode.com.au>

James Morris wrote:
> On Thu, 9 Aug 2007, Darrel Goeddel wrote:
> 
>> picture here: http://home.insightbb.com/~dgoeddel/networking/simple.png
>> (when commenting, please refrain from belittling my artistic skills)
> 
> I think this looks good in terms of labeling via secmark, although it 
> hides external labeling.

The external labeling was left (rather intentionally at this point) as a
black box.  The reason for this is that there can only be one label so just
wanted to show that the secmark field will be overidden with the
"peer provided" (external) label if it exists.  That could either be an xfrm
label, a netlbl label, or an *agreement* of the two.  In the case of CIPSO
over an labeled xfrm, I'd say that the xfrm context and the netlbl modified
context must be equal or the packet is dropped on the grounds that it is
invalid (can't be secret and top_secret all at once).  Once the peer
information has been taken into account, the idea of "external labeling"
goes away because we are now just dealing with the one and only label.

>> - A new SECFILTER iptables module is in place to perform flow control
>>   checks.  Just as we have used the expressiveness (either fine grained
>>   or coarse grained - your choice) of iptables to define fallback labels
>>   for packets based on their attributes, we want to be able to define
>>   access check based on those attributes.  It is here where we can say
>>   that only http_client_t can get to port 80 on this machine, or that
>>   only a secret packet can leave the machine through the eth1 device.
>>   The SECFILTER mechanism will be able to distinguish controls for
>>   incoming, outgoing, and forwarded traffic.  In the absence of a
>>   matching "target context" from SECFILTER, the secmark will be checked
>>   against the unlabeled context (no SECFILTER - no label).  
> 
> This seems problematic.  The secmark model is currently based upon 
> iptables rules being used to classify and label traffic, with access 
> control performed within SELinux based upon those labels and permission 
> types.  So, the access control decisions are performed via the AVC and 
> according to SELinux policy.

SECFILTER would be obtaining an access decision from the security server.
The subject of that access would be the secmark on the packet (peer domain)
and the object would be the context of the matching SECFILTER rule.  So
SECMARK provides the fallback for the subject label in the absense of a
peer-provided label and SECFILTER provides the object label.

An important aspect that is that there needs to be a check against the
unlabeled context if the SECFILTER mechanism did not provide a match to
ensure that the security server was consulted for every packet.  This
would catch the case where the modules was not active or the SECFILTER
ruleset was not able to match the traffic.

> In the case of local labeling, the packet is labeled based upon the port 
> (and any other iptables selector), so you don't need to have a separate 
> mechanism  i.e. the packet will only be labled as http_client_t if it's 
> leaving via port 80 and also part of a validated connection.
> 
> Not sure what the answer is for applying controls to externally labeled 
> packets.

There is no distinction here because the secmark is the only label, whether
or not the label came from a SECMARK rule like:

iptables -t mangle -A INPUT -p tcp --dport 80 -j SECMARK \
        --selctx system_u:object_r:http_client_t:s0

or from a labeled xfrm, it is treated the same.

Since the SECMARK facility is just providing the fallback labels, the
actual flow controls are provided by the SECFILTER rules.  These rules
specify the "gates" that the skb is going to traverse.  Let's say we want
to make eth0 an "internal" only network and eth1 and external network -
we would have SECFILTER rules like:

iptables -t filter -A INPUT -i eth0 -j SECFILTER \
        --selctx system_u:object_r:internal_t:s0
iptables -t filter -A INPUT -i eth1 -j SECFILTER \
        --selctx system_u:object_r:external_t:s0
iptables -t filter -A OUTPUT -o eth0 -j SECFILTER \
        --selctx system_u:object_r:internal_t:s0
iptables -t filter -A OPTPUT -o eth1 -j SECFILTER \
        --selctx system_u:object_r:external_t:s0
iptables -t filter -A FORWARD -i eth0 -o eth1 -j SECFILTER \
        --selctx system_u:object_r:cross_the_line_t:s0
iptables -t filter -A FORWARD -i eth1 -o eth0 -j SECFILTER \
        --selctx system_u:object_r:cross_the_line_t:s0

The flow control policy arbitration would be defined as:

allow http_client_t packet:internal_t { flow_in flow_out };
allow httpd_t packet:internal_t { flow_in flow_out };

Maybe we want to allow external access from an ssl connection.  A
SECMARK rule like:

iptables -t mangle -A INPUT -p tcp --dport 443 -j SECMARK \
        --selctx system_u:object_r:https_client_t:s0

and policy like:

allow https_client_t packet:external_t { flow_in flow_out };
allow httpd_t packet:external_t { flow_in flow_out };

take care of that.  Note that httpd_t is the domain of the webserver
in the above examples.

> It seems like a special case, though, and that typically, the 
> network interface is the only thing you really want to check here.  If so,

> perhaps we implement a secmark (packet label) vs. netif check once 
> external labeling has been applied.
> 
> So, the packet control permissions using secmark would be something like:
> 
> socket layer  : send, recv

The recv check at the socket layer becomes socket (proxy for local process)
receiving information from the secmark (peer process).  This process vs.
process style check didn't seem to have a natural fit with sending the
information because the peer isn't as well known as it could be in the
receive case.  For this reason, send is actually absent in this idea right
now.
If there were a process vs. process check on send the peer process could
only
be identified through the SECMARK fallback labels.

> network layer : flow_in, flow_forward, flow_out
> link layer    : netif_in, netif_out

The flexibility of the SECFILTER mechanism should make it adequate for
these two.  My example above shows SECFILTER being used for the link layer
checks.  The thought had crossed my mind to include another layer earlier,
but then I realized that I was adding another check that probably wasn't
necessary.

> I think this will make sense to users due to the layering, and separation 
> of labeling and access control.
> 
> The order of mediation is:
> 
> Inbound to local:
>  
>    netif_in -> flow_in -> recv
> 
> Forward:
> 
>    netif_in -> flow_forward -> netif_out
> 
> Outbound from local:
> 
>    send -> flow_out -> netif_out

There's that darn send again...  The flow_out check from SECFILTER is really
performing the duties of the current send operation.  It would be providing
a way to say "can information from this process (with it's context conveyed
through the secmark on the skb) flow through this security gate?".  It is
here that one could say only httpd_t could flow_out to port 80, just like
SECMARK currently allows.  Note that this is a more granular approach to
constructing SECFILTER rules than I presented above.

The above layering makes perfect sense to me and I can live with that if it
is
deemed necessary.  Do you think the extra check will help with usability?
Usually
I would think that an extra thing to think about would make it harder, but I
am
not sure in this case.

> Now, labeling is not so simple :-)

Maybe that answers my question ;)

> We have local labeling via secmark, which needs to be applied first and 
> then potentially overridden.

Yep, this is our fallback in the absence of peer-provided information.

> Then we have two differnt forms of external labeling, with differing 
> mechanisms and policy constructs.
> 
> For general and non-legacy users, we need to be focused on IPsec labeling.


Yep, but they all convey the same information in this scheme - the label of
the peer process.  So the label is treated the same way no matter where it
comes from (as I mentioned above, I think simultaneous use of netlbl and
labeled xfrm should require and agreement on context).  IMHO, this
unification
of the label to one abstraction simplifies things greatly.  Now we can
always
perform the same check - "Can process A (local) receive info from process B
(peer)?".

> I'm not sure what the answer is for making it more usable at this stage, 
> although if we don't make significant improvements, people will never use 
> it.  Any bright ideas? :-)

Does anything I tried to clarify above shed a different light on things in
you eyes?  I think the basic tenants are:

- secmark is always the label of the peer, and getpeercon() returns it

- a packet goes though "filter points", the packet is the subject and the
 "filter point" is the object it must pass through (these filters happen
  at input, output, and forwarding)

- a socket reading a packet must be able to listen to the peer that created
 it - a slightly new meaning for current socket vs. secmark access check

This is a drastic simplification of the whole system.  I think it is much
easier from a conceptual level and it allows more control that the previous
system.  I'm just wondering what hidden problems there are with the
simplification?

-- 

Darrel

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2007-08-14 14:47 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07 14:14 [RFC 0/5] Static/fallback external labels for NetLabel Paul Moore
2007-08-07 14:14 ` [RFC 1/5] SELinux: add secctx_to_secid() LSM hook Paul Moore
2007-08-07 14:14 ` [RFC 2/5] NetLabel: Add secid token support to the NetLabel secattr struct Paul Moore
2007-08-07 14:14 ` [RFC 3/5] NetLabel: add IP address family information to the netlbl_skbuff_getattr() function Paul Moore
2007-08-07 14:14 ` [RFC 4/5] NetLabel: introduce static network labels for unlabeled connections Paul Moore
2007-08-07 14:14 ` [RFC 5/5] NetLabel: add auditing to the static labeling mechanism Paul Moore
2007-08-09 10:57 ` [RFC 0/5] Static/fallback external labels for NetLabel KaiGai Kohei
2007-08-09 11:48   ` Paul Moore
2007-08-09 12:42 ` Stephen Smalley
2007-08-09 13:29   ` Paul Moore
2007-08-09 13:54     ` Stephen Smalley
2007-08-09 14:48       ` Paul Moore
2007-08-09 15:49         ` James Morris
2007-08-09 16:01         ` Stephen Smalley
2007-08-09 22:35           ` Paul Moore
2007-08-09 13:59     ` James Morris
2007-08-09 14:50       ` Paul Moore
2007-08-09 15:13         ` Stephen Smalley
2007-08-09 14:41     ` Darrel Goeddel
2007-08-09 14:57       ` Paul Moore
2007-08-09 15:07         ` Darrel Goeddel
2007-08-09 15:32     ` Casey Schaufler
2007-08-09 15:39       ` Stephen Smalley
2007-08-09 16:16         ` Casey Schaufler
2007-08-09 14:09   ` Darrel Goeddel
2007-08-09 14:24     ` James Morris
2007-08-09 16:42       ` Darrel Goeddel
2007-08-09 19:20         ` Joe Nall
2007-08-09 19:47           ` Darrel Goeddel
2007-08-09 20:12             ` Joe Nall
2007-08-09 21:15               ` Stephen Smalley
2007-08-09 21:18               ` Darrel Goeddel
2007-08-09 22:48                 ` Paul Moore
2007-08-09 20:17             ` Paul Moore
2007-08-09 14:53     ` Paul Moore
2007-08-09 16:08       ` Darrel Goeddel
2007-08-09 22:55       ` Darrel Goeddel
2007-08-10 16:49         ` James Morris
2007-08-14 14:47           ` Darrel Goeddel [this message]
2007-08-15  4:24             ` James Morris
2007-08-15 22:35               ` Darrel Goeddel
2007-08-16 15:04                 ` James Morris
2007-08-24 16:31                   ` Paul Moore
2007-08-24 18:34                     ` James Morris
2007-08-24 19:02                     ` Casey Schaufler
2007-08-24 19:49                       ` Paul Moore
2007-08-24 20:17                         ` James Morris
2007-08-24 20:24                           ` Paul Moore
2007-08-24 20:47                             ` Joshua Brindle
2007-08-24 20:42                         ` Casey Schaufler
2007-08-24 21:10                           ` Paul Moore
2007-08-24 21:37                             ` Casey Schaufler
2007-08-24 20:29                       ` Joshua Brindle
2007-08-28 14:03                     ` Darrel Goeddel
2007-08-28 15:16                       ` Paul Moore
2007-08-09 15:48 ` Casey Schaufler
2007-08-09 19:38   ` Paul Moore
  -- strict thread matches above, loose matches on Subject: below --
2007-08-24 17:37 Venkat Yekkirala
2007-08-25 21:01 ` Paul Moore
2007-08-24 18:11 Venkat Yekkirala
2007-08-27 12:44 Venkat Yekkirala
2007-08-27 14:37 ` Paul Moore
2007-08-27 12:57 Venkat Yekkirala
2007-08-27 12:59 Venkat Yekkirala
2007-08-27 13:02 Venkat Yekkirala
2007-08-27 13:48 ` Paul Moore
2007-08-27 22:09 Venkat Yekkirala
2007-08-28 14:51 ` Paul Moore
2007-08-28 14:58 ` Darrel Goeddel
2007-08-28 15:12   ` Darrel Goeddel
2007-08-28 15:51   ` Paul Moore
2007-08-28 16:18     ` Joe Nall
2007-08-28 18:51       ` Paul Moore
2007-08-28 19:10         ` Joe Nall
2007-08-28 19:08           ` Stephen Smalley
2007-08-28 19:48           ` Joshua Brindle
2007-08-28 22:26             ` Joe Nall
2007-08-29  0:16               ` Joshua Brindle
2007-08-29  3:45                 ` Joshua Brindle
2007-08-29  4:11                   ` Joshua Brindle
2007-08-29  4:49                     ` Joe Nall
2007-08-29 14:04                       ` Joshua Brindle
2007-08-29 15:50                         ` Joe Nall
2007-08-29 16:31                           ` Joshua Brindle
2007-08-29 12:21                     ` Paul Moore
2007-08-29 14:26                       ` Joshua Brindle
2007-08-29 14:56                         ` Paul Moore
2007-08-29 15:08                           ` Joshua Brindle
2007-08-29 16:55                             ` Paul Moore
2007-08-28 17:23     ` Darrel Goeddel
2007-08-28 19:07       ` Paul Moore
2007-08-28 16:13 Venkat Yekkirala
2007-08-28 16:32 ` Joe Nall
2007-08-28 19:08 ` Paul Moore
2007-08-28 16:30 Venkat Yekkirala
2007-08-28 17:39 ` Darrel Goeddel
2007-08-28 19:36   ` Paul Moore
2007-08-28 19:26 ` Paul Moore
2007-08-28 18:02 Venkat Yekkirala
2007-08-28 19:47 ` Paul Moore
2007-08-29 15:07 Venkat Yekkirala
2007-08-29 15:29 Venkat Yekkirala
2007-08-29 15:45 ` Stephen Smalley
2007-08-29 16:15 Venkat Yekkirala
2007-08-29 16:41 ` Paul Moore

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=46C1C09D.4060909@trustedcs.com \
    --to=dgoeddel@trustedcs.com \
    --cc=eparis@parisplace.org \
    --cc=jmorris@namei.org \
    --cc=joe@nall.com \
    --cc=kaigai@ak.jp.nec.com \
    --cc=paul.moore@hp.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.