diff options
| author | Eric Paris <eparis@redhat.com> | 2013-05-24 09:18:04 -0400 |
|---|---|---|
| committer | Eric Paris <eparis@redhat.com> | 2013-11-05 11:08:13 -0500 |
| commit | d040e5af380554c23ffe0a034ae5f3e53da93a1d (patch) | |
| tree | 637a2e206c56b1cd2be32f8ef92bea19e25a3e9c | |
| parent | 81407c84ace88368ff23abb81caaeacf050c8450 (diff) | |
audit: audit feature to only allow unsetting the loginuid
This is a new audit feature which only grants processes with
CAP_AUDIT_CONTROL the ability to unset their loginuid. They cannot
directly set it from a valid uid to another valid uid. The ability to
unset the loginuid is nice because a priviledged task, like that of
container creation, can unset the loginuid and then priv is not needed
inside the container when a login daemon needs to set the loginuid.
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>
| -rw-r--r-- | include/uapi/linux/audit.h | 3 | ||||
| -rw-r--r-- | kernel/audit.c | 3 | ||||
| -rw-r--r-- | kernel/auditsc.c | 3 |
3 files changed, 7 insertions, 2 deletions
diff --git a/include/uapi/linux/audit.h b/include/uapi/linux/audit.h index 9eddf2ca614f..05e5e8fc2ac4 100644 --- a/include/uapi/linux/audit.h +++ b/include/uapi/linux/audit.h | |||
| @@ -386,7 +386,8 @@ struct audit_features { | |||
| 386 | __u32 lock; /* which features to lock */ | 386 | __u32 lock; /* which features to lock */ |
| 387 | }; | 387 | }; |
| 388 | 388 | ||
| 389 | #define AUDIT_LAST_FEATURE -1 | 389 | #define AUDIT_FEATURE_ONLY_UNSET_LOGINUID 0 |
| 390 | #define AUDIT_LAST_FEATURE AUDIT_FEATURE_ONLY_UNSET_LOGINUID | ||
| 390 | 391 | ||
| 391 | #define audit_feature_valid(x) ((x) >= 0 && (x) <= AUDIT_LAST_FEATURE) | 392 | #define audit_feature_valid(x) ((x) >= 0 && (x) <= AUDIT_LAST_FEATURE) |
| 392 | #define AUDIT_FEATURE_TO_MASK(x) (1 << ((x) & 31)) /* mask for __u32 */ | 393 | #define AUDIT_FEATURE_TO_MASK(x) (1 << ((x) & 31)) /* mask for __u32 */ |
diff --git a/kernel/audit.c b/kernel/audit.c index 29ee6a421c6c..fbfa3a74decb 100644 --- a/kernel/audit.c +++ b/kernel/audit.c | |||
| @@ -144,7 +144,8 @@ static struct audit_features af = {.vers = AUDIT_FEATURE_VERSION, | |||
| 144 | .features = 0, | 144 | .features = 0, |
| 145 | .lock = 0,}; | 145 | .lock = 0,}; |
| 146 | 146 | ||
| 147 | static char *audit_feature_names[0] = { | 147 | static char *audit_feature_names[1] = { |
| 148 | "only_unset_loginuid", | ||
| 148 | }; | 149 | }; |
| 149 | 150 | ||
| 150 | 151 | ||
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index c75d7813aef2..924c0bf048d2 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
| @@ -1974,6 +1974,9 @@ static int audit_set_loginuid_perm(kuid_t loginuid) | |||
| 1974 | /* it is set, you need permission */ | 1974 | /* it is set, you need permission */ |
| 1975 | if (!capable(CAP_AUDIT_CONTROL)) | 1975 | if (!capable(CAP_AUDIT_CONTROL)) |
| 1976 | return -EPERM; | 1976 | return -EPERM; |
| 1977 | /* reject if this is not an unset and we don't allow that */ | ||
| 1978 | if (is_audit_feature_set(AUDIT_FEATURE_ONLY_UNSET_LOGINUID) && uid_valid(loginuid)) | ||
| 1979 | return -EPERM; | ||
| 1977 | return 0; | 1980 | return 0; |
| 1978 | } | 1981 | } |
| 1979 | 1982 | ||
