Skip to content

Commit

Permalink
selinux: don't waste ebitmap space when importing NetLabel categories
Browse files Browse the repository at this point in the history
At present we don't create efficient ebitmaps when importing NetLabel
category bitmaps.  This can present a problem when comparing ebitmaps
since ebitmap_cmp() is very strict about these things and considers
these wasteful ebitmaps not equal when compared to their more
efficient counterparts, even if their values are the same.  This isn't
likely to cause problems on 64-bit systems due to a bit of luck on
how NetLabel/CIPSO works and the default ebitmap size, but it can be
a problem on 32-bit systems.

This patch fixes this problem by being a bit more intelligent when
importing NetLabel category bitmaps by skipping over empty sections
which should result in a nice, efficient ebitmap.

Cc: [email protected] # 3.17
Signed-off-by: Paul Moore <[email protected]>
  • Loading branch information
pcmoore committed Jul 9, 2015
1 parent 9fc2b4b commit 3324603
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions security/selinux/ss/ebitmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ int ebitmap_netlbl_import(struct ebitmap *ebmap,
if (offset == (u32)-1)
return 0;

/* don't waste ebitmap space if the netlabel bitmap is empty */
if (bitmap == 0) {
offset += EBITMAP_UNIT_SIZE;
continue;
}

if (e_iter == NULL ||
offset >= e_iter->startbit + EBITMAP_SIZE) {
e_prev = e_iter;
Expand Down

0 comments on commit 3324603

Please sign in to comment.