All of lore.kernel.org
 help / color / mirror / Atom feed
From: KaiGai Kohei <kaigai@ak.jp.nec.com>
To: Stephen Smalley <sds@tycho.nsa.gov>
Cc: jmorris@namei.org, paul.moore@hp.com, jbrindle@tresys.com,
	selinux@tycho.nsa.gov
Subject: Re: [PATCH 1/3] Thread/Child-Domain Assignment (rev.6)
Date: Tue, 26 Aug 2008 16:11:31 +0900	[thread overview]
Message-ID: <48B3ACA3.5040601@ak.jp.nec.com> (raw)
In-Reply-To: <1219669066.2721.68.camel@moss-spartans.epoch.ncsc.mil>

[-- Attachment #1: Type: text/plain, Size: 3634 bytes --]

Stephen Smalley wrote:
> On Mon, 2008-08-25 at 21:32 +0900, KaiGai Kohei wrote:
>> The following patch is revised one for kernel.
>>
>> Updates:
>>  - This patch is rebased on James's security-testing-2.6 tree.
>>  - security_bounded_transition() is deployed just after read_unlock()
>>    within do_each_thread() { ... } while_each_thread() loop again.
>>  - The properties of type_datum are packed within the third word of
>>    type entries in the kernel policy.
>>  - Bounds checks on constraints are integrated within avc creation.
>>    Lazy bounds checks are invoked at the tail of context_struct_compute_av(),
>>    and it drops all of boundary violated permissions. It compares permissions
>>    of a bounded type based on both of TE and constraints by a bounds type in
>>    same time, so the bounded type always cannot have any wider permission than
>>    its parent.
>>    e.g)
>>      When a type of child_t is bounded by parent_t and has mcssetcats attribute,
>>      we cannot assign undominated categories because parent_t is not allowed to
>>      assign them and it bounds permissions of child_t.
>>  - Sanity checks for constraints are removed by the above reason.
> 
> This looks good to me in terms of the functionality.
> Have you run any benchmarks to assess the performance impact on AVC
> misses?

I measured it with attached program named as "avc_misses.c".
It invokes lstat() for given files, and iterates it 1,000 times.
The given files have inidividually different categories, so we can
see the performance impact on AVC misses when the number of files
is greater than /selinux/avc/cache_threshold .

This program is executed in a domain with/without its boundary on
pathed kernel, and did on vanilla kernel.

The following result shows elapsed times of avc_misses on the second
time scale. Because lstat() is invoked for all given files, we guess
the result is basically proportional to number of files (= # of categories).

| Number of  |  No bounds   |    Bounds    |  No bounds  |
| Files and  | 2.6.27-rc4   |  2.6.27-rc4  | 2.6.27-rc4  |
| Categories |   patched    |   patched    |   vanilla   |
+------------+--------------+--------------+-------------+
|     100    |     2.338    |     2.372    |     2.216   |
|     200    |     4.742    |     4.739    |     4.451   |
|     300    |     7.275    |     7.116    |     6.844   |
|     400    |     9.685    |     9.616    |     9.337   |
|     500    |    12.509    |    12.187    |    12.049   |___
|     600    |    28.532    |    29.736    |    26.092   | |  AVC misses for
|     700    |    45.554    |    50.631    |    40.878   | |  all lstat()
|     800    |    59.908    |    72.730    |    54.208   | V
+------------+--------------+--------------+-------------+
 (*)  /selinux/avc/cache_threshold is 512 (default)
      CPU: Pentium4 (3.20Ghz), single core

When # of files is less than cache_threshold, it shows a little performance
impact in both of Bounds/No-bounds cases.
When # of files is greater than cache_threshold, it shows a significant
performance impact. The difference between No-bounds ans Bounds cases
got grown. However, it is extremely artifactual measurement result.

In the typical case, the rate of AVC hits is greater than 99%.
I don't think we don't need to worry about such level of performance impact.

 e.g) avcstat just after rawhide bootup.
    [kaigai@saba ~]$ /usr/sbin/avcstat
       lookups       hits     misses     allocs   reclaims      frees
        619277     614912       4365       4365       3840       3863

Thanks,
-- 
OSS Platform Development Division, NEC
KaiGai Kohei <kaigai@ak.jp.nec.com>

[-- Attachment #2: avc_misses.c --]
[-- Type: text/plain, Size: 949 bytes --]

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main(int argc, char *argv[])
{
	struct stat st_buf;
	struct timeval t1, t2;
	double delta;
	int nloops, rc, i, j;

	if (argc < 3) {
		fprintf(stderr, "usage: %s <# of loops> <files ...>\n", argv[0]);
		return 1;
	}

	nloops = atol(argv[1]);
	if (nloops < 1000)
		nloops = 1000;

	gettimeofday(&t1, NULL);
	for (i=0; i < nloops; i++) {
		for (j=2; argv[j]; j++) {
			rc = lstat(argv[j], &st_buf);
			if (rc < 0) {
				fprintf(stderr, "lstat(%s,...) : %s\n",
					argv[j], strerror(errno));
				return 1;
			}
		}
	}
	gettimeofday(&t2, NULL);

	delta = (((double)(t2.tv_sec - t1.tv_sec)) * 1000000.0
		 + ((double)(t2.tv_usec - t1.tv_usec))) / 1000000.0;
	printf("result: %.3f [s] (%d of files, %d of loops)\n",
	       delta, argc - 2, nloops);

	return 0;
}



[-- Attachment #3: avc_misses_figure.png --]
[-- Type: image/png, Size: 47810 bytes --]

  parent reply	other threads:[~2008-08-26  7:11 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-15 10:06 [RFC] An idea of thread/child-domain assignment KaiGai Kohei
2008-07-15 13:38 ` Stephen Smalley
2008-07-16  2:17   ` KaiGai Kohei
2008-07-16  6:08     ` KaiGai Kohei
2008-07-16 12:00       ` Stephen Smalley
2008-07-16 12:18     ` Stephen Smalley
2008-07-18  6:21       ` KaiGai Kohei
2008-07-23  3:58         ` KaiGai Kohei
2008-07-25 12:51           ` [PATCH 0/3] Thread/Child-Domain Assignment KaiGai Kohei
2008-07-25 13:03             ` [PATCH 1/3] " KaiGai Kohei
2008-07-25 13:44               ` Stephen Smalley
2008-07-25 17:06                 ` Joshua Brindle
2008-07-26  8:24                   ` KaiGai Kohei
2008-07-25 17:07                 ` Joshua Brindle
2008-07-26  7:55                 ` KaiGai Kohei
2008-07-26 17:28                   ` Stephen Smalley
2008-07-26 18:14                     ` Joshua Brindle
2008-07-28  3:06                       ` KaiGai Kohei
2008-07-28 17:31                       ` Stephen Smalley
2008-07-29  6:51                         ` KaiGai Kohei
2008-07-29 12:06                           ` Stephen Smalley
2008-07-30 14:10                             ` Joshua Brindle
2008-07-30 14:57                               ` Stephen Smalley
2008-08-01  6:26                             ` KaiGai Kohei
2008-07-25 13:03             ` [PATCH 2/3] " KaiGai Kohei
2008-07-29  7:15               ` KaiGai Kohei
2008-07-29 12:25                 ` Scott Schmit
2008-07-29 13:28                   ` Stephen Smalley
2008-07-25 13:04             ` [PATCH 3/3] " KaiGai Kohei
2008-07-25 13:04             ` [PATCH 4/3] " KaiGai Kohei
2008-08-05  5:47             ` [PATCH 0/3] Thread/Child-Domain Assignment (rev.2) KaiGai Kohei
2008-08-05  5:55               ` [PATCH 1/3] " KaiGai Kohei
2008-08-05 12:53                 ` Stephen Smalley
2008-08-06 10:05                   ` KaiGai Kohei
2008-08-06 10:13                   ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.3) KaiGai Kohei
2008-08-14  7:38                     ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.4) KaiGai Kohei
2008-08-15 18:13                       ` Stephen Smalley
2008-08-20  9:41                         ` KaiGai Kohei
2008-08-25 12:32                         ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.6) KaiGai Kohei
2008-08-25 12:57                           ` Stephen Smalley
2008-08-25 13:45                             ` KaiGai Kohei
2008-08-26  7:11                             ` KaiGai Kohei [this message]
2008-08-26  9:01                           ` James Morris
2008-08-26 10:29                           ` James Morris
2008-08-26 10:47                             ` James Morris
2008-08-27  1:15                               ` KaiGai Kohei
2008-08-27  8:04                               ` [LTP][PATCH 1/2] Replacement of deprecated interfaces KaiGai Kohei
2008-08-27 12:14                                 ` Stephen Smalley
2008-08-28  6:26                                   ` KaiGai Kohei
2008-08-28 12:10                                     ` Subrata Modak
2008-08-28 12:52                                       ` KaiGai Kohei
2008-08-28 13:34                                         ` Subrata Modak
2008-10-23  9:48                                     ` Subrata Modak
2008-08-27  8:05                               ` [LTP][PATCH 2/2] Add a new test case for bounds types KaiGai Kohei
2008-10-22 13:00                                 ` Subrata Modak
2008-10-23  8:10                                   ` KaiGai Kohei
2008-10-23  9:30                                     ` Subrata Modak
2008-08-27  1:11                             ` [PATCH 1/3] Thread/Child-Domain Assignment (rev.6) KaiGai Kohei
2008-08-28  7:35                             ` [PATCH] SELinux: add boundary support and thread context assignment KaiGai Kohei
2008-08-28 12:43                               ` Stephen Smalley
2008-08-28 15:06                               ` James Morris
2008-08-05  5:55               ` [PATCH 2/3] Thread/Child-Domain Assignment (rev.2) KaiGai Kohei
2008-08-06 10:14                 ` [PATCH 2/3] Thread/Child-Domain Assignment (rev.3) KaiGai Kohei
2008-10-09 17:10                 ` [PATCH 2/3] Thread/Child-Domain Assignment (rev.2) Joshua Brindle
2008-10-10  1:19                   ` KaiGai Kohei
2008-10-10  1:22                     ` Joshua Brindle
2008-08-05  5:55               ` [PATCH 3/3] " KaiGai Kohei
2008-08-06 10:13                 ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.3) KaiGai Kohei
2008-08-25 12:32                 ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.4) KaiGai Kohei
2008-08-28 15:51                   ` Joshua Brindle
2008-08-29  1:54                     ` KaiGai Kohei
2008-08-29  3:01                       ` Joshua Brindle
2008-09-01  6:26                         ` KaiGai Kohei
2008-09-01  9:08                           ` [PATCH] libsepol : Add support for a new policy version (POLICYDB_VERSION_BOUNDARY) KaiGai Kohei
2008-09-01 14:47                           ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.4) Joshua Brindle
2008-09-01 16:11                             ` KaiGai Kohei
2008-09-09  2:04                               ` [PATCH 3/3] Thread/Child-Domain Assignment (rev.6) KaiGai Kohei
2008-09-12 18:17                                 ` Joshua Brindle
2008-09-12 23:20                                   ` KaiGai Kohei
2008-09-15 13:44                                     ` Joshua Brindle
2008-09-16  1:50                                       ` KaiGai Kohei
2008-09-30 14:00                                     ` Joshua Brindle
2008-10-01  7:53                                       ` KaiGai Kohei
2008-10-01 19:56                                         ` Joshua Brindle
2008-10-04 23:30                                         ` Joshua Brindle
2008-10-06  9:19                                           ` KaiGai Kohei
2008-10-06 19:13                                             ` Joshua Brindle
2008-10-07  6:39                                               ` KaiGai Kohei
2008-10-09 15:30                                                 ` Joshua Brindle
2008-10-09 17:00                                                   ` Joshua Brindle
2008-10-10  0:57                                                   ` KaiGai Kohei
2008-10-09 17:11                                                 ` Joshua Brindle
2008-10-06 12:30                                           ` Stephen Smalley
2008-10-06 19:13                                             ` Joshua Brindle
2008-08-11 17:58               ` [PATCH 0/3] Thread/Child-Domain Assignment (rev.2) Joshua Brindle
2008-08-13  5:53                 ` KaiGai Kohei
2008-08-14  8:55             ` A toy of SQL injection (Re: [PATCH 0/3] Thread/Child-Domain Assignment) KaiGai Kohei

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=48B3ACA3.5040601@ak.jp.nec.com \
    --to=kaigai@ak.jp.nec.com \
    --cc=jbrindle@tresys.com \
    --cc=jmorris@namei.org \
    --cc=paul.moore@hp.com \
    --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.