netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paul Moore <pmoore@redhat.com>
Cc: netdev@vger.kernel.org, linux-security-module@vger.kernel.org,
	selinux@tycho.nsa.gov, jasowang@redhat.com
Subject: Re: [RFC PATCH v2 3/3] tun: fix LSM/SELinux labeling of tun/tap devices
Date: Thu, 6 Dec 2012 18:12:00 +0200	[thread overview]
Message-ID: <20121206161200.GA4340@redhat.com> (raw)
In-Reply-To: <7448004.siKCIqQqTi@sifl>

On Thu, Dec 06, 2012 at 10:46:11AM -0500, Paul Moore wrote:
> On Thursday, December 06, 2012 12:33:25 PM Michael S. Tsirkin wrote:
> > On Wed, Dec 05, 2012 at 03:26:19PM -0500, Paul Moore wrote:
> > > This patch corrects some problems with LSM/SELinux that were introduced
> > > with the multiqueue patchset.  The problem stems from the fact that the
> > > multiqueue work changed the relationship between the tun device and its
> > > associated socket; before the socket persisted for the life of the
> > > device, however after the multiqueue changes the socket only persisted
> > > for the life of the userspace connection (fd open).  For non-persistent
> > > devices this is not an issue, but for persistent devices this can cause
> > > the tun device to lose its SELinux label.
> > > 
> > > We correct this problem by adding an opaque LSM security blob to the
> > > tun device struct which allows us to have the LSM security state, e.g.
> > > SELinux labeling information, persist for the lifetime of the tun
> > > device.  In the process we tweak the LSM hooks to work with this new
> > > approach to TUN device/socket labeling and introduce a new LSM hook,
> > > security_tun_dev_create_queue(), to approve requests to create a new
> > > TUN queue via TUNSETQUEUE.
> > > 
> > > The SELinux code has been adjusted to match the new LSM hooks, the
> > > other LSMs do not make use of the LSM TUN controls.  This patch makes
> > > use of the recently added "tun_socket:create_queue" permission to
> > > restrict access to the TUNSETQUEUE operation.  On older SELinux
> > > policies which do not define the "tun_socket:create_queue" permission
> > > the access control decision for TUNSETQUEUE will be handled according
> > > to the SELinux policy's unknown permission setting.
> > > 
> > > Signed-off-by: Paul Moore <pmoore@redhat.com>
> > 
> > OK so just to verify: this can be used to ensure that qemu
> > process that has the queue fd can only attach it to
> > a specific device, right?
> 
> Whenever a new queue is created via TUNSETQUEUE/tun_set_queue() the 
> security_tun_dev_create_queue() LSM hook is called.  When SELinux is enabled 
> this hook ends up calling selinux_tun_dev_create_queue() which checks that the 
> calling process (process_t) is allowed to create a new queue on the specified 
> device (tundev_t) .  If you are familiar with SELinux security policy, the 
> allow rule would look like this:
> 
>   allow process_t tundev_t:tun_socket create_queue;
> 
> In practice, if we assume libvirt is creating the TUN device and running with 
> a SELinux label of virtd_t and that QEMU instances are running with a SELinux 
> label of svirt_t then the allow rule would look like this:
> 
>   allow svirt_t virtd_t:tun_socket create_queue;
> 
> There is also the matter of the MLS/MCS constraints providing additional 
> separation but that is another level of detail which I don't believe is 
> important for our discussion.

Hmm. How do the rules for SETIFF look ATM?
I am just checking default policy does not let qemu do with
SETQUEUE something with a device which it can not
attach to using SETIFF.

> -- 
> paul moore
> security and virtualization @ redhat

  reply	other threads:[~2012-12-06 16:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05 20:25 [RFC PATCH v2 0/3] Fix some multiqueue TUN problems Paul Moore
2012-12-05 20:26 ` [RFC PATCH v2 1/3] tun: correctly report an error in tun_flow_init() Paul Moore
2012-12-06 10:31   ` Jason Wang
2012-12-06 15:46     ` Paul Moore
2012-12-05 20:26 ` [RFC PATCH v2 2/3] selinux: add the "create_queue" permission to the "tun_socket" class Paul Moore
2012-12-05 20:26 ` [RFC PATCH v2 3/3] tun: fix LSM/SELinux labeling of tun/tap devices Paul Moore
2012-12-06 10:29   ` Jason Wang
2012-12-06 15:36     ` Paul Moore
2012-12-07  5:29       ` Jason Wang
2012-12-06 10:33   ` Michael S. Tsirkin
2012-12-06 13:51     ` Jason Wang
2012-12-06 14:12       ` Michael S. Tsirkin
2012-12-06 15:46     ` Paul Moore
2012-12-06 16:12       ` Michael S. Tsirkin [this message]
2012-12-06 16:56         ` Paul Moore
2012-12-06 20:57           ` Michael S. Tsirkin
2012-12-06 21:09             ` Paul Moore
2012-12-07 12:25               ` Michael S. Tsirkin
2012-12-10 17:04                 ` Paul Moore
2012-12-10 17:26                   ` Michael S. Tsirkin
2012-12-10 17:33                     ` Paul Moore
2012-12-10 17:50                       ` Michael S. Tsirkin
2012-12-10 18:42                         ` Eric Paris
2012-12-10 22:21                           ` Paul Moore
2012-12-10 22:43                         ` Paul Moore
2012-12-11  6:41                           ` Jason Wang
2012-12-12  9:10                           ` Michael S. Tsirkin
2012-12-07  5:41             ` Jason Wang
2012-12-12  9:22   ` Michael S. Tsirkin
2012-12-12 18:49     ` 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=20121206161200.GA4340@redhat.com \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=linux-security-module@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pmoore@redhat.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).