summaryrefslogtreecommitdiffstats
path: root/security/selinux/ss/policydb.h
diff options
context:
space:
mode:
authorEric Paris2010-11-29 21:47:09 +0100
committerEric Paris2010-11-30 23:28:58 +0100
commitac76c05becb6beedbb458d0827d3deaa6f479a72 (patch)
tree255276b52f7b031671ae5948b39d7c92e50ba420 /security/selinux/ss/policydb.h
parentselinux: convert type_val_to_struct to flex_array (diff)
downloadkernel-qcow2-linux-ac76c05becb6beedbb458d0827d3deaa6f479a72.tar.gz
kernel-qcow2-linux-ac76c05becb6beedbb458d0827d3deaa6f479a72.tar.xz
kernel-qcow2-linux-ac76c05becb6beedbb458d0827d3deaa6f479a72.zip
selinux: convert part of the sym_val_to_name array to use flex_array
The sym_val_to_name type array can be quite large as it grows linearly with the number of types. With known policies having over 5k types these allocations are growing large enough that they are likely to fail. Convert those to flex_array so no allocation is larger than PAGE_SIZE Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security/selinux/ss/policydb.h')
-rw-r--r--security/selinux/ss/policydb.h17
1 files changed, 8 insertions, 9 deletions
diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h
index 9826a92a6b0c..4e3ab9d0b315 100644
--- a/security/selinux/ss/policydb.h
+++ b/security/selinux/ss/policydb.h
@@ -203,15 +203,7 @@ struct policydb {
#define p_cats symtab[SYM_CATS]
/* symbol names indexed by (value - 1) */
- char **sym_val_to_name[SYM_NUM];
-#define p_common_val_to_name sym_val_to_name[SYM_COMMONS]
-#define p_class_val_to_name sym_val_to_name[SYM_CLASSES]
-#define p_role_val_to_name sym_val_to_name[SYM_ROLES]
-#define p_type_val_to_name sym_val_to_name[SYM_TYPES]
-#define p_user_val_to_name sym_val_to_name[SYM_USERS]
-#define p_bool_val_to_name sym_val_to_name[SYM_BOOLS]
-#define p_sens_val_to_name sym_val_to_name[SYM_LEVELS]
-#define p_cat_val_to_name sym_val_to_name[SYM_CATS]
+ struct flex_array *sym_val_to_name[SYM_NUM];
/* class, role, and user attributes indexed by (value - 1) */
struct class_datum **class_val_to_struct;
@@ -321,6 +313,13 @@ static inline int put_entry(void *buf, size_t bytes, int num, struct policy_file
return 0;
}
+static inline char *sym_name(struct policydb *p, unsigned int sym_num, unsigned int element_nr)
+{
+ struct flex_array *fa = p->sym_val_to_name[sym_num];
+
+ return flex_array_get_ptr(fa, element_nr);
+}
+
extern u16 string_to_security_class(struct policydb *p, const char *name);
extern u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name);