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:57 -0500 |
commit | 23bdecb000c806cf4ec52764499a600f7200d7a9 (patch) | |
tree | f13a523f6bec22c5e7ec58ea02a4988aefe7c8ac /security/selinux/ss/services.c | |
parent | c41ab6a1b9028de33e74101cb0aae13098a56fdb (diff) |
selinux: convert type_val_to_struct to flex_array
In rawhide type_val_to_struct will allocate 26848 bytes, an order 3
allocations. While this hasn't been seen to fail it isn't outside the
realm of possibiliy on systems with severe memory fragmentation. Convert
to flex_array so no allocation will ever be bigger than PAGE_SIZE.
Signed-off-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security/selinux/ss/services.c')
-rw-r--r-- | security/selinux/ss/services.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index ab6dbce5fd2a..afcbc19817f7 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
@@ -530,12 +530,18 @@ static void type_attribute_bounds_av(struct context *scontext, | |||
530 | struct context lo_scontext; | 530 | struct context lo_scontext; |
531 | struct context lo_tcontext; | 531 | struct context lo_tcontext; |
532 | struct av_decision lo_avd; | 532 | struct av_decision lo_avd; |
533 | struct type_datum *source | 533 | struct type_datum *source; |
534 | = policydb.type_val_to_struct[scontext->type - 1]; | 534 | struct type_datum *target; |
535 | struct type_datum *target | ||
536 | = policydb.type_val_to_struct[tcontext->type - 1]; | ||
537 | u32 masked = 0; | 535 | u32 masked = 0; |
538 | 536 | ||
537 | source = flex_array_get_ptr(policydb.type_val_to_struct_array, | ||
538 | scontext->type - 1); | ||
539 | BUG_ON(!source); | ||
540 | |||
541 | target = flex_array_get_ptr(policydb.type_val_to_struct_array, | ||
542 | tcontext->type - 1); | ||
543 | BUG_ON(!target); | ||
544 | |||
539 | if (source->bounds) { | 545 | if (source->bounds) { |
540 | memset(&lo_avd, 0, sizeof(lo_avd)); | 546 | memset(&lo_avd, 0, sizeof(lo_avd)); |
541 | 547 | ||
@@ -828,7 +834,8 @@ int security_bounded_transition(u32 old_sid, u32 new_sid) | |||
828 | 834 | ||
829 | index = new_context->type; | 835 | index = new_context->type; |
830 | while (true) { | 836 | while (true) { |
831 | type = policydb.type_val_to_struct[index - 1]; | 837 | type = flex_array_get_ptr(policydb.type_val_to_struct_array, |
838 | index - 1); | ||
832 | BUG_ON(!type); | 839 | BUG_ON(!type); |
833 | 840 | ||
834 | /* not bounded anymore */ | 841 | /* not bounded anymore */ |