apparmor: fail task profile update if current_cred isn't real_cred
authorJohn Johansen <john.johansen@canonical.com>
Mon, 16 Jan 2017 08:42:59 +0000 (00:42 -0800)
committerJohn Johansen <john.johansen@canonical.com>
Mon, 16 Jan 2017 09:18:45 +0000 (01:18 -0800)
Trying to update the task cred while the task current cred is not the
real cred will result in an error at the cred layer. Avoid this by
failing early and delaying the update.

Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/context.c

index 3c4f534ef88cadfe35b4a183ef4d0679ff04637e..3f32f594c9999025aec4f6b2feac1dd57887a620 100644 (file)
@@ -100,6 +100,9 @@ int aa_replace_current_profile(struct aa_profile *profile)
        if (cxt->profile == profile)
                return 0;
 
+       if (current_cred() != current_real_cred())
+               return -EBUSY;
+
        new  = prepare_creds();
        if (!new)
                return -ENOMEM;