Skip to content

Commit d42b2b6

Browse files
jrjohansengregkh
authored andcommitted
apparmor: fix: limit the number of levels of policy namespaces
commit 3060394 upstream. Currently the number of policy namespaces is not bounded relying on the user namespace limit. However policy namespaces aren't strictly tied to user namespaces and it is possible to create them and nest them arbitrarily deep which can be used to exhaust system resource. Hard cap policy namespaces to the same depth as user namespaces. Fixes: c88d4c7 ("AppArmor: core policy routines") Reported-by: Qualys Security Advisory <qsa@qualys.com> Reviewed-by: Ryan Lee <ryan.lee@canonical.com> Reviewed-by: Cengiz Can <cengiz.can@canonical.com> Signed-off-by: John Johansen <john.johansen@canonical.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7eade84 commit d42b2b6

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

security/apparmor/include/policy_ns.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "label.h"
1919
#include "policy.h"
2020

21+
/* Match max depth of user namespaces */
22+
#define MAX_NS_DEPTH 32
2123

2224
/* struct aa_ns_acct - accounting of profiles in namespace
2325
* @max_size: maximum space allowed for all profiles in namespace

security/apparmor/policy_ns.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ static struct aa_ns *__aa_create_ns(struct aa_ns *parent, const char *name,
223223
AA_BUG(!name);
224224
AA_BUG(!mutex_is_locked(&parent->lock));
225225

226+
if (parent->level > MAX_NS_DEPTH)
227+
return ERR_PTR(-ENOSPC);
226228
ns = alloc_ns(parent->base.hname, name);
227229
if (!ns)
228230
return ERR_PTR(-ENOMEM);

0 commit comments

Comments
 (0)