UBUNTU: SAUCE: (no-up) apparmor: use custom write_is_locked macro

replace usage of the write_can_lock macro with our own write_is_locked
macro. AppArmor's use of write_can_lock is with AA_BUG statements
to assert the correct lock is being held.

However on none SMP machines write_can_lock is always true causing
the AA_BUG assert to fail. Define our own macro that can have the
correct semantics for the assert on none SMP machines.

BugLink: http://bugs.launchpad.net/bugs/1323530

Signed-off-by: John Johansen <john.johansen@canonical.com>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
This commit is contained in:
John Johansen
2014-05-26 11:37:18 +02:00
committed by Tim Gardner
parent 9cac646bc9
commit 6dfb089e16
2 changed files with 15 additions and 4 deletions

View File

@@ -21,6 +21,17 @@
#include "backport.h" #include "backport.h"
#include "match.h" #include "match.h"
/* Provide our own test for whether a write lock is held for asserts
* this is because on none SMP systems write_can_lock will always
* resolve to true, which is what you want for code making decisions
* based on it, but wrong for asserts checking that the lock is held
*/
#ifdef CONFIG_SMP
#define write_is_locked(X) !write_can_lock(X)
#else
#define write_is_locked(X) (1)
#endif /* CONFIG_SMP */
/* /*
* Class of mediation types in the AppArmor policy db * Class of mediation types in the AppArmor policy db
*/ */

View File

@@ -280,7 +280,7 @@ static bool __aa_label_remove(struct aa_labelset *ls, struct aa_label *label)
{ {
AA_BUG(!ls); AA_BUG(!ls);
AA_BUG(!label); AA_BUG(!label);
AA_BUG(write_can_lock(&ls->lock)); AA_BUG(!write_is_locked(&ls->lock));
AA_BUG(labels_set(label) != ls); AA_BUG(labels_set(label) != ls);
if (label_invalid(label)) if (label_invalid(label))
@@ -324,7 +324,7 @@ static bool __aa_label_replace(struct aa_labelset *ls, struct aa_label *old,
AA_BUG(!ls); AA_BUG(!ls);
AA_BUG(!old); AA_BUG(!old);
AA_BUG(!new); AA_BUG(!new);
AA_BUG(write_can_lock(&ls->lock)); AA_BUG(!write_is_locked(&ls->lock));
AA_BUG(labels_set(old) != ls); AA_BUG(labels_set(old) != ls);
AA_BUG(new->flags & FLAG_IN_TREE); AA_BUG(new->flags & FLAG_IN_TREE);
@@ -353,7 +353,7 @@ static struct aa_label *__aa_label_remove_and_insert(struct aa_labelset *ls,
AA_BUG(!ls); AA_BUG(!ls);
AA_BUG(!remove); AA_BUG(!remove);
AA_BUG(!insert); AA_BUG(!insert);
AA_BUG(write_can_lock(&ls->lock)); AA_BUG(!write_is_locked(&ls->lock));
AA_BUG(labels_set(remove) != ls); AA_BUG(labels_set(remove) != ls);
AA_BUG(insert->flags & FLAG_IN_TREE); AA_BUG(insert->flags & FLAG_IN_TREE);
@@ -559,7 +559,7 @@ static struct aa_label *__aa_label_insert(struct aa_labelset *ls,
AA_BUG(!ls); AA_BUG(!ls);
AA_BUG(!l); AA_BUG(!l);
AA_BUG(write_can_lock(&ls->lock)); AA_BUG(!write_is_locked(&ls->lock));
AA_BUG(l->flags & FLAG_IN_TREE); AA_BUG(l->flags & FLAG_IN_TREE);
/* Figure out where to put new node */ /* Figure out where to put new node */