From: Paul Moore <paul.moore@hp.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org,
vyekkirala@TrustedCS.com, chanson@TrustedCS.com
Subject: Re: [RFC PATCH v8 18/18] SELinux: Add network ingress and egress control permission checks
Date: Mon, 17 Dec 2007 16:06:59 -0500 [thread overview]
Message-ID: <200712171606.59974.paul.moore@hp.com> (raw)
In-Reply-To: <1197921937.17307.114.camel@moss-spartans.epoch.ncsc.mil>
On Monday 17 December 2007 3:05:37 pm Stephen Smalley wrote:
> On Sun, 2007-12-16 at 11:47 -0500, Paul Moore wrote:
> > On Friday 14 December 2007 4:51:29 pm Paul Moore wrote:
> > > This patch implements packet ingress/egress controls for SELinux which
> > > allow SELinux security policy to control the flow of all IPv4 and IPv6
> > > packets into and out of the system. Currently SELinux does not have
> > > proper control over forwarded packets and this patch corrects this
> > > problem.
> > >
> > > Special thanks to Venkat Yekkirala <vyekkirala@trustedcs.com> whose
> > > earlier work on this topic eventually led to this patch.
> >
> > I've been thinking about this over the weekend and realized a few things
> > ...
> >
> > {snip}
> >
> > > +static int selinux_inet_sys_snd_skb(struct sk_buff *skb, int family)
> > > +{
> > > + int err = 0;
> > > +
> > > + if (!selinux_policycap_netpeer)
> > > + return 0;
> > > +
> > > + if (netlbl_enabled() || selinux_xfrm_enabled()) {
> > > + u32 if_sid;
> > > + u32 node_sid;
> > > + u32 peer_sid;
> > > + char *addrp;
> > > + struct avc_audit_data ad;
> > > +
> > > + AVC_AUDIT_DATA_INIT(&ad, NET);
> > > + ad.u.net.netif = skb->iif;
> > > + ad.u.net.family = family;
> > > + err = selinux_parse_skb(skb, &ad, &addrp, 0, NULL);
> > > + if (err)
> > > + return err;
> > > +
> > > + err = selinux_skb_peerlbl_sid(skb, family, &peer_sid);
> > > + if (err)
> > > + return err;
> >
> > I realized I made a mistake here: we should check to see if the skb has a
> > socket associated with it and if it does get the peer_sid from there
> > instead. If there is no socket to be found then do what we are already
> > going above.
>
> In what case do you expect the two SIDs to diverge?
The case of CIPSO immediately springs to mind. If you query the packet
directly you will get a SID similar to what you see on incoming packets:
the "netlabel_peer_t" type plus the CIPSO MLS sensitivity label. If you
query the socket which originated the packet you'll get the original, native
SELinux label/SID. In my mind using the socket's label is a shortcut to get
the full/true/original/etc. label quickly.
There is most likely also a performance advantage in pulling the SID from the
socket.
> What if we later provide an API to allow a sender to send a datagram
> with a particular label rather than always requiring them to be the same
> as the sending socket?
Then we can transition from using a mix between socket and packet labels to
just packet labels. I don't see any _significant_ barriers to that approach
in the ingress/egress controls as proposed. If you do, let me know.
> > > + err = sel_netif_sid(skb->iif, &if_sid);
> > > + if (err)
> > > + return err;
> > > + err = avc_has_perm(if_sid, peer_sid,
> > > + SECCLASS_PEER, PEER__EGRESS, &ad);
> > > + if (err)
> > > + return err;
> > > +
> > > + err = sel_netnode_sid(addrp, family, &node_sid);
> > > + if (err)
> > > + return err;
> > > + err = avc_has_perm(node_sid, peer_sid,
> > > + SECCLASS_PEER, PEER__EGRESS, &ad);
> >
> > We should probably have different permissions for the interface and node
> > cases. Take the example of an admin who is only interested in enforcing
> > interface controls and not node controls. They would most likely write
> > the following policy rule to nullify the node check ...
> >
> > allow unlabeled_t peer_t:peer egress;
> >
> > ... which would end up applying to both the interface and node checks
> > because they use the same permission. I'm thinking we should split the
> > permissions like this:
> >
> > allow netif_t peer_t:peer if_egress;
> > allow netnode_t peer_t: peer node_egress;
> >
> > ... and do something similar for the ingress side. Thoughts?
>
> That starts to sound a lot like using netif and node classes instead of
> the peer class.
> allow peer_t netif_t:netif egress;
> allow peer_t netnode_t:node egress;
I see you noticed that too :)
I've been mulling this over and over in my head for some time and I'm not sure
which is better. I'm leaning towards sticking with the peer object class
just because it reinforces the decision to treat the packet as an object.
Good or bad, that is how SELinux currently treats packets and I fear that
using the packet's peer label as the subject here could get confusing.
--
paul moore
linux security @ hp
--
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.
next prev parent reply other threads:[~2007-12-17 21:06 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-14 21:49 [RFC PATCH v8 00/18] Update to the labeled networking patches for 2.6.25 Paul Moore
2007-12-14 21:49 ` [RFC PATCH v8 01/18] NetLabel: Remove unneeded RCU read locks Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 02/18] NetLabel: Cleanup the LSM domain hash functions Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 03/18] NetLabel: Consolidate the LSM domain mapping/hashing locks Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 04/18] NetLabel: Add secid token support to the NetLabel secattr struct Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 05/18] LSM: Add secctx_to_secid() LSM hook Paul Moore
2007-12-17 19:49 ` Stephen Smalley
2007-12-17 20:42 ` Casey Schaufler
2007-12-18 8:25 ` James Morris
2007-12-18 13:44 ` Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 06/18] LSM: Add inet_sys_snd_skb() " Paul Moore
2007-12-17 19:45 ` Stephen Smalley
2007-12-17 20:48 ` Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 07/18] NetLabel: Add IP address family information to the netlbl_skbuff_getattr() function Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 08/18] SELinux: Convert the netif code to use ifindex values Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 09/18] SELinux: Only store the network interface's ifindex Paul Moore
2007-12-17 19:56 ` Stephen Smalley
2007-12-17 20:51 ` Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 10/18] SELinux: Add a network node caching mechanism similar to the sel_netif_*() functions Paul Moore
2007-12-17 20:35 ` Stephen Smalley
2007-12-17 20:56 ` Paul Moore
2007-12-18 8:16 ` James Morris
2007-12-18 13:26 ` Stephen Smalley
2007-12-18 13:37 ` Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 11/18] SELinux: Add a capabilities bitmap to SELinux policy version 22 Paul Moore
2007-12-14 21:50 ` [RFC PATCH v8 12/18] SELinux: Add new peer permissions to the Flask definitions Paul Moore
2007-12-14 21:51 ` [RFC PATCH v8 13/18] SELinux: Better integration between peer labeling subsystems Paul Moore
2007-12-14 21:51 ` [RFC PATCH v8 14/18] SELinux: Enable dynamic enable/disable of the network access checks Paul Moore
2007-12-14 21:51 ` [RFC PATCH v8 15/18] SELinux: Allow NetLabel to directly cache SIDs Paul Moore
2007-12-14 21:51 ` [RFC PATCH v8 16/18] NetLabel: Introduce static network labels for unlabeled connections Paul Moore
2007-12-14 21:51 ` [RFC PATCH v8 17/18] NetLabel: Add auditing to the static labeling mechanism Paul Moore
2007-12-14 21:51 ` [RFC PATCH v8 18/18] SELinux: Add network ingress and egress control permission checks Paul Moore
2007-12-16 16:47 ` Paul Moore
2007-12-17 20:05 ` Stephen Smalley
2007-12-17 21:06 ` Paul Moore [this message]
2007-12-18 13:59 ` Paul Moore
2007-12-18 15:14 ` Stephen Smalley
2007-12-18 17:03 ` 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=200712171606.59974.paul.moore@hp.com \
--to=paul.moore@hp.com \
--cc=chanson@TrustedCS.com \
--cc=linux-security-module@vger.kernel.org \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=vyekkirala@TrustedCS.com \
/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.