selinux: dump statistics for more hash tables
PATCH 2/6 selinux: dump statistics for more hash tables
Dump in the SELinux debug configuration the statistics for the conditional rules avtab, the role transition, and class and common permission hash tables.
--- security/selinux/ss/conditional.c | 3 +++ security/selinux/ss/policydb.c | 6 ++++++ 2 files changed, 9 insertions(+)
security/selinux/ss/conditional.c +3 -0
@@ -171,6 +171,9 @@ int cond_init_bool_indexes(struct policydb *p) GFP_KERNEL);if (!p->bool_val_to_struct)return -ENOMEM ; + +avtab_hash_eval (&p->te_cond_avtab,"conditional_rules" ); +return 0 ; }
security/selinux/ss/policydb.c +6 -0
@@ -1158,6 +1158,8 @@ static int common_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&comdatum->permissions.table,"common_permissions" ); + rc =symtab_insert (s, key, comdatum);if (rc) goto bad;
@@ -1339,6 +1341,8 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&cladatum->permissions.table,"class_permissions" ); + rc =read_cons_helper (p, &cladatum->constraints, ncons,0 , fp);if (rc) goto bad;
@@ -2616,6 +2620,8 @@ int policydb_read(struct policydb *p, void *fp) rtd =NULL ; } +hash_eval (&p->role_tr,"roletr" ); + rc =next_entry (buf, fp,sizeof (u32));if (rc) goto bad;
Signature · 1 line
2.40.1
PATCH 1/6 selinux: print sum of chain lengths^2 for hash tables
Print the sum of chain lengths squared as a metric for hash tables to provide more insights, similar to avtabs.
While on it add a comma in the avtab message to improve readability of the output.
--- security/selinux/ss/avtab.c | 2 +- security/selinux/ss/hashtab.c | 5 +++++ security/selinux/ss/hashtab.h | 1 + security/selinux/ss/policydb.c | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-)
security/selinux/ss/avtab.c +1 -1
@@ -349,7 +349,7 @@ void avtab_hash_eval(struct avtab *h, const char *tag) }pr_debug ("SELinux: %s: %d entries and %d/%d buckets used, " -"longest chain length %d sum of chain length^2 %llu\n" , +"longest chain length %d, sum of chain length^2 %llu\n" , tag, h->nel, slots_used, h->nslot, max_chain_len, chain2_len_sum); }
security/selinux/ss/hashtab.c +5 -0
@@ -107,10 +107,12 @@ int hashtab_map(struct hashtab *h,void hashtab_stat (struct hashtab *h,struct hashtab_info *info) {u32 i, chain_len, slots_used, max_chain_len; +u64 chain2_len_sum;struct hashtab_node *cur; slots_used =0 ; max_chain_len =0 ; + chain2_len_sum =0 ;for (i =0 ; i < h->size; i++) { cur = h->htable[i];if (cur) {
@@ -123,11 +125,14 @@ void hashtab_stat(struct hashtab *h, struct hashtab_info *info)if (chain_len > max_chain_len) max_chain_len = chain_len; + + chain2_len_sum += (u64)chain_len * chain_len; } } info->slots_used = slots_used; info->max_chain_len = max_chain_len; + info->chain2_len_sum = chain2_len_sum; }#endif /* CONFIG_SECURITY_SELINUX_DEBUG */
security/selinux/ss/hashtab.h +1 -0
@@ -38,6 +38,7 @@ struct hashtab {struct hashtab_info {u32 slots_used;u32 max_chain_len; +u64 chain2_len_sum; };/*
security/selinux/ss/policydb.c +2 -2
@@ -684,9 +684,9 @@ static void hash_eval(struct hashtab *h, const char *hash_name)struct hashtab_info info;hashtab_stat (h, &info); -pr_debug ("SELinux: %s: %d entries and %d/%d buckets used, longest chain length %d\n" , +pr_debug ("SELinux: %s: %d entries and %d/%d buckets used, longest chain length %d, sum of chain length^2 %llu\n" , hash_name, h->nel, info.slots_used, h->size, - info.max_chain_len); + info.max_chain_len, info.chain2_len_sum); }static void symtab_hash_eval (struct symtab *s)
Signature · 1 line
2.40.1
Re: [PATCH 1/6] selinux: print sum of chain lengths^2 for hash tables
Quoted 8 lines · Christian Göttsche
Print the sum of chain lengths squared as a metric for hash tables to provide more insights, similar to avtabs.
While on it add a comma in the avtab message to improve readability of the output.
Signed-off-by Christian Göttsche <[email protected]>
Re: [PATCH 1/6] selinux: print sum of chain lengths^2 for hash tables
In reply to Christian GöttscheQuoted 7 lines · On Aug 18, 2023 Stephen Smalley <[email protected]> wrote:
Print the sum of chain lengths squared as a metric for hash tables to provide more insights, similar to avtabs.
While on it add a comma in the avtab message to improve readability of the output.
Quoted 8 lines
Signed-off-by Christian Göttsche <[email protected]>Reviewed-by Stephen Smalley <[email protected]>--- security/selinux/ss/avtab.c | 2 +- security/selinux/ss/hashtab.c | 5 +++++ security/selinux/ss/hashtab.h | 1 + security/selinux/ss/policydb.c | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-)
Merged into selinux/next, thanks.
--
paul-moore.com
PATCH 3/6 selinux: improve debug configuration
In reply to Christian GöttscheIf the SELinux debug configuration is enabled define the macro DEBUG such that pr_debug() calls are always enabled, regardless of CONFIG_DYNAMIC_DEBUG, since those message are the main reason for this configuration in the first place.
Mention example usage in case CONFIG_DYNAMIC_DEBUG is enabled in the help section of the configuration.
--- security/selinux/Kconfig | 10 ++++++++++ security/selinux/Makefile | 2 ++ 2 files changed, 12 insertions(+)
security/selinux/Kconfig +10 -0
@@ -77,3 +77,13 @@ config SECURITY_SELINUX_DEBUG This enables debugging code designed to help SELinux kernel developers, unless you know what this does in the kernel code you should leave this disabled. + + To fine control the messages to be printed enable + CONFIG_DYNAMIC_DEBUG and see + Documentation/admin-guide/dynamic-debug-howto.rst for additional + information. + + Example usage: + + echo -n 'file "security/selinux/*" +p' > \ + /proc/dynamic_debug/control
security/selinux/Makefile +2 -0
@@ -12,6 +12,8 @@ obj-$(CONFIG_SECURITY_SELINUX) := selinux.o ccflags-y := -I$(srctree)/security/selinux -I$(srctree)/security/selinux/include +ccflags-$(CONFIG_SECURITY_SELINUX_DEBUG) += -DDEBUG + selinux-y := avc.o hooks.o selinuxfs.o netlink.o nlmsgtab.o netif.o \ netnode.o netport.o status.o \ ss/ebitmap.o ss/hashtab.o ss/symtab.o ss/sidtab.o ss/avtab.o \
Signature · 1 line
2.40.1
Re: [PATCH 3/6] selinux: improve debug configuration
Quoted 10 lines · Christian Göttsche
If the SELinux debug configuration is enabled define the macro DEBUG such that
pr_debug()calls are always enabled, regardless ofCONFIG_DYNAMIC_DEBUG, since those message are the main reason for this configuration in the first place.Mention example usage in case
CONFIG_DYNAMIC_DEBUGis enabled in the help section of the configuration.Signed-off-by Christian Göttsche <[email protected]>
Re: [PATCH 3/6] selinux: improve debug configuration
In reply to Christian GöttscheQuoted 9 lines · On Aug 18, 2023 Stephen Smalley <[email protected]> wrote:
If the SELinux debug configuration is enabled define the macro DEBUG such that
pr_debug()calls are always enabled, regardless ofCONFIG_DYNAMIC_DEBUG, since those message are the main reason for this configuration in the first place.Mention example usage in case
CONFIG_DYNAMIC_DEBUGis enabled in the help section of the configuration.
Quoted 6 lines
Signed-off-by Christian Göttsche <[email protected]>Reviewed-by Stephen Smalley <[email protected]>--- security/selinux/Kconfig | 10 ++++++++++ security/selinux/Makefile | 2 ++ 2 files changed, 12 insertions(+)
Merged into selinux/next, thanks!
--
paul-moore.com
PATCH 4/6 selinux: simplify avtab slot calculation
In reply to Christian GöttscheInstead of dividing by 8 and then performing log2 by hand, use a more readable calculation.
The behavior of rounddown_pow_of_two() for an input of 0 is undefined, so handle that case and small values manually to achieve the same results.
--- security/selinux/ss/avtab.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
security/selinux/ss/avtab.c +1 -7
@@ -298,13 +298,7 @@ int avtab_alloc(struct avtab *h, u32 nrules)u32 nslot =0 ;if (nrules !=0 ) { -u32 shift =1 ; -u32 work = nrules >>3 ; -while (work) { - work >>=1 ; - shift++; - } - nslot =1 << shift; + nslot = nrules >3 ?rounddown_pow_of_two (nrules /2 ) :2 ;if (nslot >MAX_AVTAB_HASH_BUCKETS ) nslot =MAX_AVTAB_HASH_BUCKETS ;
Signature · 1 line
2.40.1
Re: [PATCH 4/6] selinux: simplify avtab slot calculation
Quoted 9 lines · Christian Göttsche
Instead of dividing by 8 and then performing log2 by hand, use a more readable calculation.
The behavior of
rounddown_pow_of_two()for an input of 0 is undefined, so handle that case and small values manually to achieve the same results.Signed-off-by Christian Göttsche <[email protected]>
Paul Moore
maintainerRe: [PATCH 4/6] selinux: simplify avtab slot calculation
In reply to Christian GöttscheQuoted 8 lines · On Aug 18, 2023 Stephen Smalley <[email protected]> wrote:
Instead of dividing by 8 and then performing log2 by hand, use a more readable calculation.
The behavior of
rounddown_pow_of_two()for an input of 0 is undefined, so handle that case and small values manually to achieve the same results.
Quoted 5 lines
Signed-off-by Christian Göttsche <[email protected]>Reviewed-by Stephen Smalley <[email protected]>--- security/selinux/ss/avtab.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
Much nicer, thanks. Merged into selinux/next.
--
paul-moore.com
PATCH 5/6 selinux: improve role transition hashing
In reply to Christian GöttscheThe number of buckets is calculated by performing a binary AND against the mask of the hash table, which is one less than its size (which is a power of two). This leads to all top bits being discarded, e.g. with the Reference Policy on Debian there exists 376 entries, leading to a size of 512, discarding the top 23 bits.
Use jhash to improve the hash table utilization:
# current
roletr: 376 entries and 124/512 buckets used, longest chain length 8, sum of chain length^2 1496 # patch
roletr: 376 entries and 266/512 buckets used, longest chain length 4, sum of chain length^2 646--- security/selinux/ss/policydb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
security/selinux/ss/policydb.c +1 -1
@@ -491,7 +491,7 @@ static u32 role_trans_hash(const void *k) {const struct role_trans_key *key = k; -return key->role + (key->type <<3 ) + (key->tclass <<5 ); +return jhash_3words (key->role, key->type, (u32 )key->tclass <<16 | key->tclass,0 ); }static int role_trans_cmp (const void *k1,const void *k2)
Signature · 1 line
2.40.1
Re: [PATCH 5/6] selinux: improve role transition hashing
Quoted 9 lines · Christian Göttsche
The number of buckets is calculated by performing a binary AND against the mask of the hash table, which is one less than its size (which is a power of two). This leads to all top bits being discarded, e.g. with the Reference Policy on Debian there exists 376 entries, leading to a size of 512, discarding the top 23 bits.
Use jhash to improve the hash table utilization:
Quoted 7 lines
# current roletr: 376 entries and 124/512 buckets used, longest chain length 8, sum of chain length^2 1496# patch roletr: 376 entries and 266/512 buckets used, longest chain length 4, sum of chain length^2 646Signed-off-by Christian Göttsche <[email protected]>
Re: [PATCH 5/6] selinux: improve role transition hashing
In reply to Christian GöttscheQuoted 12 lines · On Aug 18, 2023 =?UTF-8?q?Christian=20G=C3=B6ttsche?= <[email protected]>…
The number of buckets is calculated by performing a binary AND against the mask of the hash table, which is one less than its size (which is a power of two). This leads to all top bits being discarded, e.g. with the Reference Policy on Debian there exists 376 entries, leading to a size of 512, discarding the top 23 bits.
Use jhash to improve the hash table utilization:
# current roletr: 376 entries and 124/512 buckets used, longest chain length 8, sum of chain length^2 1496
Quoted 8 lines
# patch roletr: 376 entries and 266/512 buckets used, longest chain length 4, sum of chain length^2 646Signed-off-by Christian Göttsche <[email protected]>Reviewed-by Stephen Smalley <[email protected]>--- security/selinux/ss/policydb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Merged into selinux/next, thanks.
--
paul-moore.com
PATCH 6/6 selinux: improve symtab string hashing
In reply to Christian GöttscheThe number of buckets is calculated by performing a binary AND against the mask of the hash table, which is one less than its size (which is a power of two). This leads to all top bits being discarded, requiring for short or similar inputs a hash function with a good avalanche effect.
Use djb2a:
# current
common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11
classes: 134 entries and 100/256 buckets used, longest chain length 5, sum of chain length^2 234
roles: 15 entries and 6/16 buckets used, longest chain length 5, sum of chain length^2 57
types: 4448 entries and 3016/8192 buckets used, longest chain length 41, sum of chain length^2 14922
users: 7 entries and 3/8 buckets used, longest chain length 3, sum of chain length^2 17
bools: 306 entries and 221/512 buckets used, longest chain length 4, sum of chain length^2 524
levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1
categories: 1024 entries and 400/1024 buckets used, longest chain length 4, sum of chain length^2 2740 # patch
common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11
classes: 134 entries and 101/256 buckets used, longest chain length 3, sum of chain length^2 210
roles: 15 entries and 9/16 buckets used, longest chain length 3, sum of chain length^2 31
types: 4448 entries and 3459/8192 buckets used, longest chain length 5, sum of chain length^2 6778
users: 7 entries and 5/8 buckets used, longest chain length 3, sum of chain length^2 13
bools: 306 entries and 236/512 buckets used, longest chain length 5, sum of chain length^2 470
levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1
categories: 1024 entries and 518/1024 buckets used, longest chain length 7, sum of chain length^2 2992--- security/selinux/ss/symtab.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
security/selinux/ss/symtab.c +8 -10
@@ -11,16 +11,14 @@static unsigned int symhash (const void *key) { -const char *p, *keyp; -unsigned int size; -unsigned int val; - - val =0 ; - keyp = key; - size =strlen (keyp); -for (p = keyp; (p - keyp) < size; p++) - val = (val <<4 | (val >> (8 *sizeof (unsigned int )-4 ))) ^ (*p); -return val; +/* djb2a */ +unsigned int hash =5381 ; +unsigned char c; + +while ((c = *(const unsigned char *)key++)) + hash = ((hash <<5 ) + hash) ^ c; + +return hash; }static int symcmp (const void *key1,const void *key2)
Signature · 1 line
2.40.1
Stephen Smalley
maintainerRe: [PATCH 6/6] selinux: improve symtab string hashing
Quoted 43 lines · Christian Göttsche
The number of buckets is calculated by performing a binary AND against the mask of the hash table, which is one less than its size (which is a power of two). This leads to all top bits being discarded, requiring for short or similar inputs a hash function with a good avalanche effect.
Use djb2a:
# current common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11 classes: 134 entries and 100/256 buckets used, longest chain length 5, sum of chain length^2 234 roles: 15 entries and 6/16 buckets used, longest chain length 5, sum of chain length^2 57 types: 4448 entries and 3016/8192 buckets used, longest chain length 41, sum of chain length^2 14922 users: 7 entries and 3/8 buckets used, longest chain length 3, sum of chain length^2 17 bools: 306 entries and 221/512 buckets used, longest chain length 4, sum of chain length^2 524 levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1 categories: 1024 entries and 400/1024 buckets used, longest chain length 4, sum of chain length^2 2740# patch common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11 classes: 134 entries and 101/256 buckets used, longest chain length 3, sum of chain length^2 210 roles: 15 entries and 9/16 buckets used, longest chain length 3, sum of chain length^2 31 types: 4448 entries and 3459/8192 buckets used, longest chain length 5, sum of chain length^2 6778 users: 7 entries and 5/8 buckets used, longest chain length 3, sum of chain length^2 13 bools: 306 entries and 236/512 buckets used, longest chain length 5, sum of chain length^2 470 levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1 categories: 1024 entries and 518/1024 buckets used, longest chain length 7, sum of chain length^2 2992Signed-off-by Christian Göttsche <[email protected]>--- security/selinux/ss/symtab.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)security/selinux/ss/symtab.c +0
-1@@ -11,16 +11,14 @@static unsigned int symhash (const void *key) { -const char *p, *keyp;
security/selinux/ss/symtab.c line 14
Quoted 10 lines
security/selinux/ss/symtab.c +1
-9-unsigned int size; -unsigned int val; - - val =0 ; - keyp = key; - size =strlen (keyp); -for (p = keyp; (p - keyp) < size; p++) - val = (val <<4 | (val >> (8 *sizeof (unsigned int )-4 ))) ^ (*p); -return val; +/* djb2a */
Do we need/want something that specifies the author/license (I assume public domain) of this code?
Quoted 13 lines
security/selinux/ss/symtab.c +7
-1+unsigned int hash =5381 ; +unsigned char c; + +while ((c = *(const unsigned char *)key++)) + hash = ((hash <<5 ) + hash) ^ c; + +return hash; }static int symcmp (const void *key1,const void *key2) --2.40.1
Paul Moore
maintainerRe: [PATCH 6/6] selinux: improve symtab string hashing
Quoted 42 lines · Stephen Smalley
Quoted 40 lines · Christian Göttsche
The number of buckets is calculated by performing a binary AND against the mask of the hash table, which is one less than its size (which is a power of two). This leads to all top bits being discarded, requiring for short or similar inputs a hash function with a good avalanche effect.
Use djb2a:
# current common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11 classes: 134 entries and 100/256 buckets used, longest chain length 5, sum of chain length^2 234 roles: 15 entries and 6/16 buckets used, longest chain length 5, sum of chain length^2 57 types: 4448 entries and 3016/8192 buckets used, longest chain length 41, sum of chain length^2 14922 users: 7 entries and 3/8 buckets used, longest chain length 3, sum of chain length^2 17 bools: 306 entries and 221/512 buckets used, longest chain length 4, sum of chain length^2 524 levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1 categories: 1024 entries and 400/1024 buckets used, longest chain length 4, sum of chain length^2 2740# patch common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11 classes: 134 entries and 101/256 buckets used, longest chain length 3, sum of chain length^2 210 roles: 15 entries and 9/16 buckets used, longest chain length 3, sum of chain length^2 31 types: 4448 entries and 3459/8192 buckets used, longest chain length 5, sum of chain length^2 6778 users: 7 entries and 5/8 buckets used, longest chain length 3, sum of chain length^2 13 bools: 306 entries and 236/512 buckets used, longest chain length 5, sum of chain length^2 470 levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1 categories: 1024 entries and 518/1024 buckets used, longest chain length 7, sum of chain length^2 2992Signed-off-by Christian Göttsche <[email protected]>--- security/selinux/ss/symtab.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)security/selinux/ss/symtab.c +0
-0@@ -11,16 +11,14 @@
Quoted 16 lines
security/selinux/ss/symtab.c line 14
Quoted 13 lines
security/selinux/ss/symtab.c +1
-10static unsigned int symhash (const void *key) { -const char *p, *keyp; -unsigned int size; -unsigned int val; - - val =0 ; - keyp = key; - size =strlen (keyp); -for (p = keyp; (p - keyp) < size; p++) - val = (val <<4 | (val >> (8 *sizeof (unsigned int )-4 ))) ^ (*p); -return val; +/* djb2a */ Do we need/want something that specifies the author/license (I assume public domain) of this code?
It would be a good idea, yes. I spent some time looking around, and while there are many references to djb2 (and the djb2a xor version), I had a hard time finding an explicit license statement from DJB. However, in the cdb v0.75 release there is a source file, cdb_hash.c, which has effectively the same hash (same algorithm, different implementation) with a "/* Public domain. */" statement at the top. IANAL, but I think that is good enough.
Christian, can you update this patch comments with this info?
Quoted 12 lines
Quoted 12 lines
security/selinux/ss/symtab.c +7
-1+unsigned int hash =5381 ; +unsigned char c; + +while ((c = *(const unsigned char *)key++)) + hash = ((hash <<5 ) + hash) ^ c; + +return hash; }static int symcmp (const void *key1,const void *key2) --2.40.1
Signature · 1 line
paul-moore.com
Re: [PATCH 6/6] selinux: improve symtab string hashing
In reply to Christian GöttscheQuoted 29 lines · Christian Göttsche
The number of buckets is calculated by performing a binary AND against the mask of the hash table, which is one less than its size (which is a power of two). This leads to all top bits being discarded, requiring for short or similar inputs a hash function with a good avalanche effect.
Use djb2a:
# current common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11 classes: 134 entries and 100/256 buckets used, longest chain length 5, sum of chain length^2 234 roles: 15 entries and 6/16 buckets used, longest chain length 5, sum of chain length^2 57 types: 4448 entries and 3016/8192 buckets used, longest chain length 41, sum of chain length^2 14922 users: 7 entries and 3/8 buckets used, longest chain length 3, sum of chain length^2 17 bools: 306 entries and 221/512 buckets used, longest chain length 4, sum of chain length^2 524 levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1 categories: 1024 entries and 400/1024 buckets used, longest chain length 4, sum of chain length^2 2740# patch common prefixes: 7 entries and 5/8 buckets used, longest chain length 2, sum of chain length^2 11 classes: 134 entries and 101/256 buckets used, longest chain length 3, sum of chain length^2 210 roles: 15 entries and 9/16 buckets used, longest chain length 3, sum of chain length^2 31 types: 4448 entries and 3459/8192 buckets used, longest chain length 5, sum of chain length^2 6778 users: 7 entries and 5/8 buckets used, longest chain length 3, sum of chain length^2 13 bools: 306 entries and 236/512 buckets used, longest chain length 5, sum of chain length^2 470 levels: 1 entries and 1/1 buckets used, longest chain length 1, sum of chain length^2 1 categories: 1024 entries and 518/1024 buckets used, longest chain length 7, sum of chain length^2 2992
Quoted 1 line
Signed-off-by Christian Göttsche <[email protected]>
Assuming this is in fact public domain,
Stephen Smalley
maintainerQuoted 22 lines · Christian Göttsche
Dump in the SELinux debug configuration the statistics for the conditional rules avtab, the role transition, and class and common permission hash tables.
Signed-off-by Christian Göttsche <[email protected]>---
security/selinux/ss/policydb.c +2
-0@@ -1158,6 +1158,8 @@ static int common_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&comdatum->permissions.table,"common_permissions" ); + rc =symtab_insert (s, key, comdatum);if (rc) goto bad;
security/selinux/ss/policydb.c static int class_read(struct policydb *p, struct symtab *s, void *fp) · line 1348
Quoted 8 lines
security/selinux/ss/policydb.c +2
-0@@ -1339,6 +1341,8 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&cladatum->permissions.table,"class_permissions" ); + rc =read_cons_helper (p, &cladatum->constraints, ncons,0 , fp);if (rc) goto bad;
Do we want to embed the actual common and class keys in the output to distinguish among the multiple common and class permissions tables?
Paul Moore
maintainerQuoted 27 lines · Stephen Smalley
Quoted 25 lines · Christian Göttsche
Dump in the SELinux debug configuration the statistics for the conditional rules avtab, the role transition, and class and common permission hash tables.
Signed-off-by Christian Göttsche <[email protected]>---
security/selinux/ss/policydb.c +2
-0@@ -1158,6 +1158,8 @@ static int common_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&comdatum->permissions.table,"common_permissions" ); + rc =symtab_insert (s, key, comdatum);if (rc) goto bad;@@ -1339,6 +1341,8 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) goto bad; }
Quoted 8 lines
security/selinux/ss/policydb.c static int class_read(struct policydb *p, struct symtab *s, void *fp) · line 1348
Quoted 5 lines
security/selinux/ss/policydb.c +2
-0+hash_eval (&cladatum->permissions.table,"class_permissions" ); + rc =read_cons_helper (p, &cladatum->constraints, ncons,0 , fp);if (rc) goto bad;Do we want to embed the actual common and class keys in the output to distinguish among the multiple common and class permissions tables?
That seems reasonable, were you thinking of just adding it to the hash_eval()'s hash name string, e.g. "common_permissions[XXX]"?
Signature · 1 line
paul-moore.com
Stephen Smalley
maintainerQuoted 39 lines · Paul Moore
Quoted 27 lines · Stephen Smalley
Quoted 25 lines · Christian Göttsche
Dump in the SELinux debug configuration the statistics for the conditional rules avtab, the role transition, and class and common permission hash tables.
Signed-off-by Christian Göttsche <[email protected]>---
security/selinux/ss/policydb.c +2
-0@@ -1158,6 +1158,8 @@ static int common_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&comdatum->permissions.table,"common_permissions" ); + rc =symtab_insert (s, key, comdatum);if (rc) goto bad;@@ -1339,6 +1341,8 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) goto bad; }Quoted 8 lines
security/selinux/ss/policydb.c static int class_read(struct policydb *p, struct symtab *s, void *fp) · line 1348
Quoted 5 lines
security/selinux/ss/policydb.c +2
-0+hash_eval (&cladatum->permissions.table,"class_permissions" ); + rc =read_cons_helper (p, &cladatum->constraints, ncons,0 , fp);if (rc) goto bad;Do we want to embed the actual common and class keys in the output to distinguish among the multiple common and class permissions tables?
Quoted 2 lines
That seems reasonable, were you thinking of just adding it to the hash_eval()'s hash name string, e.g. "common_permissions[XXX]"?
Yes, otherwise you get a bunch of common_permissions and class_permissions lines with no way to correlate.
Paul Moore
maintainerQuoted 39 lines · Stephen Smalley
Quoted 38 lines · Paul Moore
Quoted 35 lines · Stephen Smalley
Quoted 22 lines · Christian Göttsche
Dump in the SELinux debug configuration the statistics for the conditional rules avtab, the role transition, and class and common permission hash tables.
Signed-off-by Christian Göttsche <[email protected]>---
security/selinux/ss/policydb.c +2
-0@@ -1158,6 +1158,8 @@ static int common_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&comdatum->permissions.table,"common_permissions" ); + rc =symtab_insert (s, key, comdatum);if (rc) goto bad;security/selinux/ss/policydb.c static int class_read(struct policydb *p, struct symtab *s, void *fp) · line 1348
Quoted 8 lines
security/selinux/ss/policydb.c +2
-0@@ -1339,6 +1341,8 @@ static int class_read(struct policydb *p, struct symtab *s, void *fp) goto bad; } +hash_eval (&cladatum->permissions.table,"class_permissions" ); + rc =read_cons_helper (p, &cladatum->constraints, ncons,0 , fp);if (rc) goto bad;Do we want to embed the actual common and class keys in the output to distinguish among the multiple common and class permissions tables?
Quoted 5 lines
Quoted 2 lines
That seems reasonable, were you thinking of just adding it to the hash_eval()'s hash name string, e.g. "common_permissions[XXX]"?
Yes, otherwise you get a bunch of
common_permissionsandclass_permissionslines with no way to correlate.
Agreed, I was asking more to determine how you envisioned the keys in the output.
Christian, instead of creating the combined string in the caller I would suggest adding a third parameter to the hash_eval() function and having hash_eval() add the extra info (if present, NULL should be acceptable) to the output. This should ensure no extra work is done when debug is disabled.
Signature · 1 line
paul-moore.com
Quoted 6 lines · Christian Göttsche
Dump in the SELinux debug configuration the statistics for the conditional rules avtab, the role transition, and class and common permission hash tables.
Signed-off-by Christian Göttsche <[email protected]>
Aside from the question I asked, which I have no strong opinion about,