All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Ole Kliemann <ole@plastictree.net>, selinux@tycho.nsa.gov
Subject: Re: Strange context on unix_stream_socket
Date: Mon, 27 Jan 2014 11:20:23 -0500	[thread overview]
Message-ID: <52E68747.5020006@tycho.nsa.gov> (raw)
In-Reply-To: <20140126224640.GE2837@telmora.telvanni>

On 01/26/2014 05:46 PM, Ole Kliemann wrote:
> On Sun, Jan 26, 2014 at 01:29:22PM +0100, Ole Kliemann wrote:
>> On Sat, Jan 25, 2014 at 09:59:44PM +0100, Ole Kliemann wrote:
>>> I'm having an odd problem:
>>>
>>> I am running my own MCS constrainted policy on Ubuntu 12.04. At 
>>> some point I have a process with context 
>>>
>>>     sub_t:s0:c20-s0:c20.c29
>>>
>>> From this process I try to access a jack daemon with mplayer. For 
>>> this purpose unix stream sockets are being used. I then get an 
>>> avc denial saying that
>>>
>>>     process sub_t:s0:c20-s0:c20.c29
>>>
>>> tried to access 
>>>
>>>     unix_stream_socket sub_t:s0
>>>
>>> which is prohibited by mcs constrain. The socket is on sockfs and 
>>> has no file associated with it.
>>>
>>> The problem is that under no circumstances the policy allows the 
>>> creation of anything with 'sub_t:s0'. 
>>>
>>> Using an auditallow rule like
>>>
>>>     auditallow any_type sub_t:unix_stream_socket { create relabelto relabelfrom };
>>>
>>> clearly shows that indeed no socket with a context like that is 
>>> created nor relabel to.  And yet it exists.
>>
>> With strace and GDB I managed to find out this much:
>>
>> mplayer open several sockets and listens on at least one of them. 
>> All these sockets have correct context. I determined the context 
>> using
>>
>>     'stat -L /proc/PID/fd/FD'
>>
>> I hope that is a valid method.
>>
>> It then accept a connection on a listening socket, probably 
>> coming from the jack daemon. As we know, the system call 
>> accepting a connection on a socket returns a new socket itself. 
>> At the point the system call returns, this new socket is found in 
>> /proc/PID/fd/ and has the offending context.
>>
>> Now I don't know much about these sockets. Process A listens on 
>> socket S0 and accepts the connection of process B. A new socket 
>> S1 appears. Who, in terms of policy, is the creating process for 
>> socket S1? How does the kernel determine the context of such a 
>> socket?
> 
> I have written my own little socket test program. Process P1 with 
> context TYPE1:RANGE1 creates a socket and listens on it. P2 with 
> context TYPE2:RANGE2 connects to this socket.
> 
> Process P1 accepts the connection. The socket created throught 
> accept() in P1 has actually the context TYPE1:RANGE2.
> 
> Is this expected behavior? 

Yes.  That was the behavior desired by the MLS/LSPP community, as they
want the socket to mirror the client level for multi-level servers, and
in the single-level server case, you are only allowed to connect at the
same level.

  reply	other threads:[~2014-01-27 16:20 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-25 20:59 Strange context on unix_stream_socket Ole Kliemann
2014-01-26 12:29 ` Ole Kliemann
2014-01-26 22:46   ` Ole Kliemann
2014-01-27 16:20     ` Stephen Smalley [this message]
2014-01-28 17:12       ` Ole Kliemann
2014-01-28 17:22         ` Stephen Smalley
2014-01-30 15:10           ` Richard Haines
2014-01-30 15:15             ` Stephen Smalley
2014-01-30 18:33             ` Ole Kliemann
     [not found] ` <CAPJdAQCZ0W4Bbm5JGa+R4QQkkeddoZFdUn5icJyo07xAB7BvNw@mail.gmail.com>
2014-01-26 12:33   ` ole

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=52E68747.5020006@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=ole@plastictree.net \
    --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.