All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel J Walsh <dwalsh@redhat.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: Eric Paris <eparis@redhat.com>,
	selinux@tycho.nsa.gov, lennart@poettering.net
Subject: Re: A filename to label translation daemon
Date: Wed, 08 Aug 2012 16:52:56 -0400	[thread overview]
Message-ID: <5022D1A8.6010309@redhat.com> (raw)
In-Reply-To: <1344456337.22629.17.camel@moss-pluto.epoch.ncsc.mil>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/08/2012 04:05 PM, Stephen Smalley wrote:
> On Wed, 2012-08-08 at 15:31 -0400, Eric Paris wrote:
>> We know that utilities like install disable their SELinux support because
>> of the enormous amount of time it takes to load the matchpathcon regex
>> database.  We know that systemd spends time loading the database at least
>> twice.  Other utilities like the krb5libs complain about the size and
>> time it takes to load the database.  We've added hacks (I believe all in
>> Fedora, but maybe upstream as well) which try to pare down the database
>> to some prefix(es) on database load.  If systemd only needs to label in
>> /var why load all the stuff for /etc?  These prefix hacks don't work
>> particularly well as fallback labels (such as default_t) are hard to
>> capture and the prefixes cannot be long as the regexes are usually quite
>> short.  They also don't work well with label equivalencies.
>> 
>> So today I wrote a little daemon which listens in the abstract namespace 
>> for requests and returns the context.  It really really rough, I admit, 
>> but it works quite well.  My first perf numbers looking at /home/eparis 
>> make sense:
>> 
>> $ ./initonce /home/eparis 0.180 seconds used by the processor. $
>> ./initalways /home/eparis 19.200 seconds used by the processor. $
>> ./client /home/eparis 0.570 seconds used by the processor.
>> 
>> If I init the DB one time and do the same lookup (for /home/eparis) 1000 
>> times it takes .18 seconds.  Doing 1000 lookups init-ing and fini-ing the
>> db every time it took 19.2.  Connecting to the server and asking 1000
>> times took .57 seconds.  This means that if you have to do about 48 
>> lookups, it's faster to do your own init.  If <48, you should use the 
>> server.
>> 
>> The I tried again with a different pathname (and get very different 
>> results)
>> 
>> $ ./initonce /var/www/html/cgi-bin 1.510 seconds used by the processor. $
>> ./initalways /var/www/html/cgi-bin 42.790 seconds used by the processor. 
>> $ ./client /var/www/html/cgi-bin 0.600 seconds used by the processor.
>> 
>> These I cannot explain.  How the heck is local slower when the time to 
>> init the db is not taken into account at all?  I'm clueless here.  But 
>> still, the client server model doesn't look like a bad idea.
>> 
>> I'm attaching my server, my client, and my 2 local test programs. 
>> Thoughts?
>> 
>> *having the daemon listen and update the db on policy load is a todo
> 
> Not sure how this helps systemd, as it runs first (by definition) and loads
> the file_contexts configuration before it starts any other daemons, right?
> Now if you wanted systemd to export this as a service to everything else,
> that might make sense.
> 

That is our goal, to have systemd launch this as a service that it could use
for systemd-udev and friends, and then other apps that use kerberos libraries
or tools like install could start to take advantage.

We would still want to allow a tool like restorecon to override the behaviour
since a tools that is doing hundreds or thousands of matchpathcons is faster
if it loads the regex.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlAi0agACgkQrlYvE4MpobPawwCg4IEWgc6bGRhoflU3CCi/5cZg
OFwAoK3q2rZpg1dJQ9DryhiVJrCDvegx
=A4k6
-----END PGP SIGNATURE-----

--
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:[~2012-08-08 20:52 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-08 19:31 A filename to label translation daemon Eric Paris
2012-08-08 20:05 ` Stephen Smalley
2012-08-08 20:52   ` Daniel J Walsh [this message]
2012-08-08 20:55   ` Eric Paris
2012-08-08 21:26 ` Colin Walters
2012-08-09 14:37   ` Russell Coker
2012-08-09 17:06     ` Daniel J Walsh
2012-08-09 17:51       ` Colin Walters
     [not found]         ` <20120810141101.GC32076@tango.0pointer.de>
     [not found]           ` <20120810141747.GA909@tango.0pointer.de>
2012-08-13 17:36             ` Daniel J Walsh
2012-08-13 17:55               ` Colin Walters
2012-08-13 18:06                 ` Daniel J Walsh
2012-08-14 11:18                 ` Russell Coker
2012-08-14 12:38                   ` Eric Paris
2012-08-14 14:01                     ` Eric Paris
2012-08-14 16:48                       ` Stephen Smalley
2012-08-14 17:21                         ` Eric Paris
2012-08-14 22:34                         ` Russell Coker
2012-08-15  5:56                     ` Russell Coker
2012-08-15 13:22                       ` Eric Paris
2012-08-16 23:51                         ` Eric Paris
2012-08-10  2:28       ` Russell Coker
2012-08-10 12:39         ` Daniel J Walsh
2012-08-10 13:35           ` Russell Coker
2012-08-12 11:02             ` Daniel J Walsh
     [not found]           ` <20120810140503.GB32076@tango.0pointer.de>
2012-08-12 11:03             ` Daniel J Walsh
     [not found]               ` <20120813151821.GB4861@redhat.com>
2012-08-13 16:37                 ` Daniel J Walsh

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=5022D1A8.6010309@redhat.com \
    --to=dwalsh@redhat.com \
    --cc=eparis@redhat.com \
    --cc=lennart@poettering.net \
    --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.