Commit 456be6cd90dbbb9b0ea01d56932d56d110d51cf7
1 parent
37509e749d
Exists in
master
and in
7 other branches
[AUDIT] LOGIN message credentials
Attached is a new patch that solves the issue of getting valid credentials into the LOGIN message. The current code was assuming that the audit context had already been copied. This is not always the case for LOGIN messages. To solve the problem, the patch passes the task struct to the function that emits the message where it can get valid credentials. Signed-off-by: Steve Grubb <sgrubb@redhat.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Showing 3 changed files with 7 additions and 6 deletions Side-by-side Diff
fs/proc/base.c
include/linux/audit.h
... | ... | @@ -187,7 +187,7 @@ |
187 | 187 | void *data, uid_t loginuid); |
188 | 188 | extern void audit_get_stamp(struct audit_context *ctx, |
189 | 189 | struct timespec *t, unsigned int *serial); |
190 | -extern int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid); | |
190 | +extern int audit_set_loginuid(struct task_struct *task, uid_t loginuid); | |
191 | 191 | extern uid_t audit_get_loginuid(struct audit_context *ctx); |
192 | 192 | extern int audit_ipc_perms(unsigned long qbytes, uid_t uid, gid_t gid, mode_t mode); |
193 | 193 | #else |
kernel/auditsc.c
... | ... | @@ -1010,20 +1010,21 @@ |
1010 | 1010 | |
1011 | 1011 | extern int audit_set_type(struct audit_buffer *ab, int type); |
1012 | 1012 | |
1013 | -int audit_set_loginuid(struct audit_context *ctx, uid_t loginuid) | |
1013 | +int audit_set_loginuid(struct task_struct *task, uid_t loginuid) | |
1014 | 1014 | { |
1015 | - if (ctx) { | |
1015 | + if (task->audit_context) { | |
1016 | 1016 | struct audit_buffer *ab; |
1017 | 1017 | |
1018 | 1018 | ab = audit_log_start(NULL); |
1019 | 1019 | if (ab) { |
1020 | 1020 | audit_log_format(ab, "login pid=%d uid=%u " |
1021 | 1021 | "old loginuid=%u new loginuid=%u", |
1022 | - ctx->pid, ctx->uid, ctx->loginuid, loginuid); | |
1022 | + task->pid, task->uid, | |
1023 | + task->audit_context->loginuid, loginuid); | |
1023 | 1024 | audit_set_type(ab, AUDIT_LOGIN); |
1024 | 1025 | audit_log_end(ab); |
1025 | 1026 | } |
1026 | - ctx->loginuid = loginuid; | |
1027 | + task->audit_context->loginuid = loginuid; | |
1027 | 1028 | } |
1028 | 1029 | return 0; |
1029 | 1030 | } |