From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Paul Moore <paul.moore@hp.com>
Cc: linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
selinux@tycho.nsa.gov
Subject: Re: [RFC PATCH v2 2/2] selinux: Support for the new TUN LSM hooks
Date: Wed, 12 Aug 2009 18:07:49 -0500 [thread overview]
Message-ID: <20090812230749.GA11633@us.ibm.com> (raw)
In-Reply-To: <200908121855.24061.paul.moore@hp.com>
Quoting Paul Moore (paul.moore@hp.com):
> On Wednesday 12 August 2009 06:14:40 pm Serge E. Hallyn wrote:
> > Quoting Paul Moore (paul.moore@hp.com):
> > > +static int selinux_tun_dev_attach(struct sock *sk)
> > > +{
> > > + struct sk_security_struct *sksec = sk->sk_security;
> > > + u32 sid = current_sid();
> > > + int err;
> > > +
> > > + err = avc_has_perm(sid, sksec->sid, SECCLASS_TUN_SOCKET,
> > > + TUN_SOCKET__RELABELFROM, NULL);
> > > + if (err)
> > > + return err;
> > > + err = avc_has_perm(sid, sid, SECCLASS_RAWIP_SOCKET,
> >
> > Was RAWIP on purpose here?
>
> Nope, a mistake on my part that I hadn't caught yet. Thanks.
>
> > > + TUN_SOCKET__RELABELTO, NULL);
> > > + if (err)
> > > + return err;
> > > +
> > > + sksec->sid = sid;
> > > +
> > > + return 0;
> > > +}
> >
> > IIUC it is possible for multiple processes to attach to the same
> > tun device. Will it get confusing/incorrect to have each attach
> > potentially (if tasks have different sids) relabel?
>
> I may be reading the code wrong, but in drivers/net/tun.c:tun_attach() the
> code checks to see if the TUN device is already in use and if it is then the
> attach fails with -EBUSY (check where the tun_device->tfile is examined). I
Ah yes, you're right - I saw the check for (ifr->ifr_flags & IFF_TUN_EXCL) in
the attach path in tun_set_iff, and missed this one.
> believe this should ensure that only one process at a time has access to the
> TUN device so we shouldn't have to worry about a TUN socket getting relabeled
> while it is currently in use. As far as persistent TUN devices getting
> relabeled when a new process attaches to them, that is what we are trying to
> accomplish here so that the network traffic being sent via the TUN device is
> labeled according to the currently attached process; this is consistent with
> how SELinux currently labels locally generated outbound traffic - outbound
> packets inherit their security label from the sending process via the
> originating socket/sock.
Ok, thanks. To my untrained eye the class addition looks right too, so
with the trivial change:
Acked-by: Serge Hallyn <serue@us.ibm.com>
thanks,
-serge
--
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.
WARNING: multiple messages have this Message-ID (diff)
From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Paul Moore <paul.moore@hp.com>
Cc: linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
selinux@tycho.nsa.gov
Subject: Re: [RFC PATCH v2 2/2] selinux: Support for the new TUN LSM hooks
Date: Wed, 12 Aug 2009 18:07:49 -0500 [thread overview]
Message-ID: <20090812230749.GA11633@us.ibm.com> (raw)
In-Reply-To: <200908121855.24061.paul.moore@hp.com>
Quoting Paul Moore (paul.moore@hp.com):
> On Wednesday 12 August 2009 06:14:40 pm Serge E. Hallyn wrote:
> > Quoting Paul Moore (paul.moore@hp.com):
> > > +static int selinux_tun_dev_attach(struct sock *sk)
> > > +{
> > > + struct sk_security_struct *sksec = sk->sk_security;
> > > + u32 sid = current_sid();
> > > + int err;
> > > +
> > > + err = avc_has_perm(sid, sksec->sid, SECCLASS_TUN_SOCKET,
> > > + TUN_SOCKET__RELABELFROM, NULL);
> > > + if (err)
> > > + return err;
> > > + err = avc_has_perm(sid, sid, SECCLASS_RAWIP_SOCKET,
> >
> > Was RAWIP on purpose here?
>
> Nope, a mistake on my part that I hadn't caught yet. Thanks.
>
> > > + TUN_SOCKET__RELABELTO, NULL);
> > > + if (err)
> > > + return err;
> > > +
> > > + sksec->sid = sid;
> > > +
> > > + return 0;
> > > +}
> >
> > IIUC it is possible for multiple processes to attach to the same
> > tun device. Will it get confusing/incorrect to have each attach
> > potentially (if tasks have different sids) relabel?
>
> I may be reading the code wrong, but in drivers/net/tun.c:tun_attach() the
> code checks to see if the TUN device is already in use and if it is then the
> attach fails with -EBUSY (check where the tun_device->tfile is examined). I
Ah yes, you're right - I saw the check for (ifr->ifr_flags & IFF_TUN_EXCL) in
the attach path in tun_set_iff, and missed this one.
> believe this should ensure that only one process at a time has access to the
> TUN device so we shouldn't have to worry about a TUN socket getting relabeled
> while it is currently in use. As far as persistent TUN devices getting
> relabeled when a new process attaches to them, that is what we are trying to
> accomplish here so that the network traffic being sent via the TUN device is
> labeled according to the currently attached process; this is consistent with
> how SELinux currently labels locally generated outbound traffic - outbound
> packets inherit their security label from the sending process via the
> originating socket/sock.
Ok, thanks. To my untrained eye the class addition looks right too, so
with the trivial change:
Acked-by: Serge Hallyn <serue@us.ibm.com>
thanks,
-serge
next prev parent reply other threads:[~2009-08-12 23:07 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 17:28 [RFC PATCH v2 0/2] New LSM hooks for the TUN driver Paul Moore
2009-08-10 17:28 ` Paul Moore
2009-08-10 17:28 ` [RFC PATCH v2 1/2] lsm: Add hooks to " Paul Moore
2009-08-10 17:28 ` Paul Moore
2009-08-11 20:34 ` Eric Paris
2009-08-11 20:34 ` Eric Paris
2009-08-12 19:28 ` Serge E. Hallyn
2009-08-12 19:28 ` Serge E. Hallyn
2009-08-12 19:43 ` Paul Moore
2009-08-12 19:43 ` Paul Moore
2009-08-10 17:28 ` [RFC PATCH v2 2/2] selinux: Support for the new TUN LSM hooks Paul Moore
2009-08-10 17:28 ` Paul Moore
2009-08-11 20:36 ` Eric Paris
2009-08-11 20:36 ` Eric Paris
2009-08-12 14:59 ` Paul Moore
2009-08-12 14:59 ` Paul Moore
2009-08-12 22:14 ` Serge E. Hallyn
2009-08-12 22:14 ` Serge E. Hallyn
2009-08-12 22:55 ` Paul Moore
2009-08-12 22:55 ` Paul Moore
2009-08-12 23:07 ` Serge E. Hallyn [this message]
2009-08-12 23:07 ` Serge E. Hallyn
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=20090812230749.GA11633@us.ibm.com \
--to=serue@us.ibm.com \
--cc=linux-security-module@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paul.moore@hp.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 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.