apparmor: fixup secid map conversion to using IDR

The IDR conversion did not handle an error case for when allocating a
mapping fails, and it did not ensure that mappings did not allocate or
use a 0 value, which is used as an invalid secid. Which is used when a
mapping fails.

Fixes: 3ae7eb49a2be ("apparmor: Use an IDR to allocate apparmor secids")
Signed-off-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
John Johansen
2018-06-04 19:44:59 -07:00
parent 99cc45e486
commit a4c3f89c9b
4 changed files with 29 additions and 8 deletions

View File

@@ -407,8 +407,7 @@ bool aa_label_init(struct aa_label *label, int size, gfp_t gfp)
AA_BUG(!label);
AA_BUG(size < 1);
label->secid = aa_alloc_secid(label, gfp);
if (label->secid == AA_SECID_INVALID)
if (aa_alloc_secid(label, gfp) < 0)
return false;
label->size = size; /* doesn't include null */