]> git.dujemihanovic.xyz Git - linux.git/commitdiff
apparmor: fix lsm_get_self_attr()
authorMickaël Salaün <mic@digikod.net>
Fri, 23 Feb 2024 19:05:46 +0000 (20:05 +0100)
committerPaul Moore <paul@paul-moore.com>
Fri, 23 Feb 2024 22:16:33 +0000 (17:16 -0500)
In apparmor_getselfattr() when an invalid AppArmor attribute is
requested, or a value hasn't been explicitly set for the requested
attribute, the label passed to aa_put_label() is not properly
initialized which can cause problems when the pointer value is non-NULL
and AppArmor attempts to drop a reference on the bogus label object.

Cc: Casey Schaufler <casey@schaufler-ca.com>
Cc: John Johansen <john.johansen@canonical.com>
Fixes: 223981db9baf ("AppArmor: Add selfattr hooks")
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Reviewed-by: Paul Moore <paul@paul-moore.com>
[PM: description changes as discussed with MS]
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/apparmor/lsm.c

index 7717354ce0950af9627939b787efa98b4e50621c..63df97418b468f0edb15b4f95a694425b3bacd87 100644 (file)
@@ -782,7 +782,7 @@ static int apparmor_getselfattr(unsigned int attr, struct lsm_ctx __user *lx,
        int error = -ENOENT;
        struct aa_task_ctx *ctx = task_ctx(current);
        struct aa_label *label = NULL;
-       char *value;
+       char *value = NULL;
 
        switch (attr) {
        case LSM_ATTR_CURRENT: