SELinux: put name based create rules in a hashtable

To shorten the list we need to run if filename trans rules exist for the type
of the given parent directory I put them in a hashtable.  Given the policy we
are expecting to use in Fedora this takes the worst case list run from about
5,000 entries to 17.

Signed-off-by: Eric Paris <eparis@redhat.com>
Reviewed-by: James Morris <jmorris@namei.org>
这个提交包含在:
Eric Paris
2011-04-28 15:11:21 -04:00
父节点 3f058ef778
当前提交 2463c26d50
修改 3 个文件,包含 135 行新增61 行删除

查看文件

@@ -1362,7 +1362,8 @@ static void filename_compute_type(struct policydb *p, struct context *newcontext
u32 stype, u32 ttype, u16 tclass,
const char *objname)
{
struct filename_trans *ft;
struct filename_trans ft;
struct filename_trans_datum *otype;
/*
* Most filename trans rules are going to live in specific directories
@@ -1372,15 +1373,14 @@ static void filename_compute_type(struct policydb *p, struct context *newcontext
if (!ebitmap_get_bit(&p->filename_trans_ttypes, ttype))
return;
for (ft = p->filename_trans; ft; ft = ft->next) {
if (ft->stype == stype &&
ft->ttype == ttype &&
ft->tclass == tclass &&
!strcmp(ft->name, objname)) {
newcontext->type = ft->otype;
return;
}
}
ft.stype = stype;
ft.ttype = ttype;
ft.tclass = tclass;
ft.name = objname;
otype = hashtab_search(p->filename_trans, &ft);
if (otype)
newcontext->type = otype->otype;
}
static int security_compute_sid(u32 ssid,