Skip to content

Commit cbf2d0e

Browse files
committed
apparmor: add more debug asserts to apparmorfs
Signed-off-by: John Johansen <[email protected]> Acked-by: Seth Arnold <[email protected]>
1 parent 2410aa9 commit cbf2d0e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

security/apparmor/apparmorfs.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,6 +1446,10 @@ void __aafs_profile_migrate_dents(struct aa_profile *old,
14461446
{
14471447
int i;
14481448

1449+
AA_BUG(!old);
1450+
AA_BUG(!new);
1451+
AA_BUG(!mutex_is_locked(&profiles_ns(old)->lock));
1452+
14491453
for (i = 0; i < AAFS_PROF_SIZEOF; i++) {
14501454
new->dents[i] = old->dents[i];
14511455
if (new->dents[i])
@@ -1509,6 +1513,9 @@ int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent)
15091513
struct dentry *dent = NULL, *dir;
15101514
int error;
15111515

1516+
AA_BUG(!profile);
1517+
AA_BUG(!mutex_is_locked(&profiles_ns(profile)->lock));
1518+
15121519
if (!parent) {
15131520
struct aa_profile *p;
15141521
p = aa_deref_parent(profile);
@@ -1734,6 +1741,7 @@ void __aafs_ns_rmdir(struct aa_ns *ns)
17341741

17351742
if (!ns)
17361743
return;
1744+
AA_BUG(!mutex_is_locked(&ns->lock));
17371745

17381746
list_for_each_entry(child, &ns->base.profiles, base.list)
17391747
__aafs_profile_rmdir(child);
@@ -1906,6 +1914,10 @@ static struct aa_ns *__next_ns(struct aa_ns *root, struct aa_ns *ns)
19061914
{
19071915
struct aa_ns *parent, *next;
19081916

1917+
AA_BUG(!root);
1918+
AA_BUG(!ns);
1919+
AA_BUG(ns != root && !mutex_is_locked(&ns->parent->lock));
1920+
19091921
/* is next namespace a child */
19101922
if (!list_empty(&ns->sub_ns)) {
19111923
next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
@@ -1940,6 +1952,9 @@ static struct aa_ns *__next_ns(struct aa_ns *root, struct aa_ns *ns)
19401952
static struct aa_profile *__first_profile(struct aa_ns *root,
19411953
struct aa_ns *ns)
19421954
{
1955+
AA_BUG(!root);
1956+
AA_BUG(ns && !mutex_is_locked(&ns->lock));
1957+
19431958
for (; ns; ns = __next_ns(root, ns)) {
19441959
if (!list_empty(&ns->base.profiles))
19451960
return list_first_entry(&ns->base.profiles,
@@ -1962,6 +1977,8 @@ static struct aa_profile *__next_profile(struct aa_profile *p)
19621977
struct aa_profile *parent;
19631978
struct aa_ns *ns = p->ns;
19641979

1980+
AA_BUG(!mutex_is_locked(&profiles_ns(p)->lock));
1981+
19651982
/* is next profile a child */
19661983
if (!list_empty(&p->base.profiles))
19671984
return list_first_entry(&p->base.profiles, typeof(*p),

0 commit comments

Comments
 (0)