diff options
author | Eric Paris <eparis@redhat.com> | 2011-04-28 15:11:21 -0400 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2011-04-28 15:15:52 -0400 |
commit | 03a4c0182a156547edd5f2717c1702590fe36bbf (patch) | |
tree | c4585fab7c37d4eb2cc46e93c925e7c2a5e7b1a2 /security/selinux/ss/services.c | |
parent | 2667991f60e67d28c495b8967aaabf84b4ccd560 (diff) |
SELinux: skip filename trans rules if ttype does not match parent dir
Right now we walk to filename trans rule list for every inode that is
created. First passes at policy using this facility creates around 5000
filename trans rules. Running a list of 5000 entries every time is a bad
idea. This patch adds a new ebitmap to policy which has a bit set for each
ttype that has at least 1 filename trans rule. Thus when an inode is
created we can quickly determine if any rules exist for this parent
directory type and can skip the list if we know there is definitely no
relevant entry.
Signed-off-by: Eric Paris <eparis@redhat.com>
Reviewed-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux/ss/services.c')
-rw-r--r-- | security/selinux/ss/services.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index 78bb8100b02e..6a22eaebf3b7 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
@@ -1363,6 +1363,15 @@ static void filename_compute_type(struct policydb *p, struct context *newcontext | |||
1363 | const char *objname) | 1363 | const char *objname) |
1364 | { | 1364 | { |
1365 | struct filename_trans *ft; | 1365 | struct filename_trans *ft; |
1366 | |||
1367 | /* | ||
1368 | * Most filename trans rules are going to live in specific directories | ||
1369 | * like /dev or /var/run. This bitmap will quickly skip rule searches | ||
1370 | * if the ttype does not contain any rules. | ||
1371 | */ | ||
1372 | if (!ebitmap_get_bit(&p->filename_trans_ttypes, ttype)) | ||
1373 | return; | ||
1374 | |||
1366 | for (ft = p->filename_trans; ft; ft = ft->next) { | 1375 | for (ft = p->filename_trans; ft; ft = ft->next) { |
1367 | if (ft->stype == stype && | 1376 | if (ft->stype == stype && |
1368 | ft->ttype == ttype && | 1377 | ft->ttype == ttype && |