diff options
author | Eric Paris <eparis@redhat.com> | 2010-11-29 15:47:09 -0500 |
---|---|---|
committer | Eric Paris <eparis@redhat.com> | 2010-11-30 17:28:58 -0500 |
commit | ac76c05becb6beedbb458d0827d3deaa6f479a72 (patch) | |
tree | 255276b52f7b031671ae5948b39d7c92e50ba420 /security/selinux/ss/policydb.h | |
parent | 23bdecb000c806cf4ec52764499a600f7200d7a9 (diff) |
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.h | 17 |
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 { | |||
203 | #define p_cats symtab[SYM_CATS] | 203 | #define p_cats symtab[SYM_CATS] |
204 | 204 | ||
205 | /* symbol names indexed by (value - 1) */ | 205 | /* symbol names indexed by (value - 1) */ |
206 | char **sym_val_to_name[SYM_NUM]; | 206 | struct flex_array *sym_val_to_name[SYM_NUM]; |
207 | #define p_common_val_to_name sym_val_to_name[SYM_COMMONS] | ||
208 | #define p_class_val_to_name sym_val_to_name[SYM_CLASSES] | ||
209 | #define p_role_val_to_name sym_val_to_name[SYM_ROLES] | ||
210 | #define p_type_val_to_name sym_val_to_name[SYM_TYPES] | ||
211 | #define p_user_val_to_name sym_val_to_name[SYM_USERS] | ||
212 | #define p_bool_val_to_name sym_val_to_name[SYM_BOOLS] | ||
213 | #define p_sens_val_to_name sym_val_to_name[SYM_LEVELS] | ||
214 | #define p_cat_val_to_name sym_val_to_name[SYM_CATS] | ||
215 | 207 | ||
216 | /* class, role, and user attributes indexed by (value - 1) */ | 208 | /* class, role, and user attributes indexed by (value - 1) */ |
217 | struct class_datum **class_val_to_struct; | 209 | 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 | |||
321 | return 0; | 313 | return 0; |
322 | } | 314 | } |
323 | 315 | ||
316 | static inline char *sym_name(struct policydb *p, unsigned int sym_num, unsigned int element_nr) | ||
317 | { | ||
318 | struct flex_array *fa = p->sym_val_to_name[sym_num]; | ||
319 | |||
320 | return flex_array_get_ptr(fa, element_nr); | ||
321 | } | ||
322 | |||
324 | extern u16 string_to_security_class(struct policydb *p, const char *name); | 323 | extern u16 string_to_security_class(struct policydb *p, const char *name); |
325 | extern u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name); | 324 | extern u32 string_to_av_perm(struct policydb *p, u16 tclass, const char *name); |
326 | 325 | ||