audit: audit feature to set loginuid immutable
authorEric Paris <eparis@redhat.com>
Thu, 23 May 2013 18:26:00 +0000 (14:26 -0400)
committerEric Paris <eparis@redhat.com>
Tue, 5 Nov 2013 16:08:17 +0000 (11:08 -0500)
This adds a new 'audit_feature' bit which allows userspace to set it
such that the loginuid is absolutely immutable, even if you have
CAP_AUDIT_CONTROL.

Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
include/uapi/linux/audit.h
kernel/audit.c
kernel/auditsc.c

index 05e5e8fc2ac41d89e55712d5486ecb19f0f80025..e2f0d997713125b1c47398d0ec97602e7e709b04 100644 (file)
@@ -387,7 +387,8 @@ struct audit_features {
 };
 
 #define AUDIT_FEATURE_ONLY_UNSET_LOGINUID      0
-#define AUDIT_LAST_FEATURE                     AUDIT_FEATURE_ONLY_UNSET_LOGINUID
+#define AUDIT_FEATURE_LOGINUID_IMMUTABLE       1
+#define AUDIT_LAST_FEATURE                     AUDIT_FEATURE_LOGINUID_IMMUTABLE
 
 #define audit_feature_valid(x)         ((x) >= 0 && (x) <= AUDIT_LAST_FEATURE)
 #define AUDIT_FEATURE_TO_MASK(x)       (1 << ((x) & 31)) /* mask for __u32 */
index fbfa3a74decb43820ee67b2e127c0256d8b5c62a..f3f36f5eb4ae4938c129ae225a95e1cf44da813f 100644 (file)
@@ -144,8 +144,9 @@ static struct audit_features af = {.vers = AUDIT_FEATURE_VERSION,
                                   .features = 0,
                                   .lock = 0,};
 
-static char *audit_feature_names[1] = {
+static char *audit_feature_names[2] = {
        "only_unset_loginuid",
+       "loginuid_immutable",
 };
 
 
index 924c0bf048d284876912d762cd5945b44a1c1130..63223d671a6ed0b7b433234de90886ff8392c048 100644 (file)
@@ -1971,6 +1971,9 @@ static int audit_set_loginuid_perm(kuid_t loginuid)
        /* if we are unset, we don't need privs */
        if (!audit_loginuid_set(current))
                return 0;
+       /* if AUDIT_FEATURE_LOGINUID_IMMUTABLE means never ever allow a change*/
+       if (is_audit_feature_set(AUDIT_FEATURE_LOGINUID_IMMUTABLE))
+               return -EPERM;
        /* it is set, you need permission */
        if (!capable(CAP_AUDIT_CONTROL))
                return -EPERM;