diff options
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/auditsc.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index a222e73fec74..4e67abb02904 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -178,6 +178,7 @@ struct audit_aux_data_pids { | |||
178 | pid_t target_pid[AUDIT_AUX_PIDS]; | 178 | pid_t target_pid[AUDIT_AUX_PIDS]; |
179 | uid_t target_auid[AUDIT_AUX_PIDS]; | 179 | uid_t target_auid[AUDIT_AUX_PIDS]; |
180 | uid_t target_uid[AUDIT_AUX_PIDS]; | 180 | uid_t target_uid[AUDIT_AUX_PIDS]; |
181 | unsigned int target_sessionid[AUDIT_AUX_PIDS]; | ||
181 | u32 target_sid[AUDIT_AUX_PIDS]; | 182 | u32 target_sid[AUDIT_AUX_PIDS]; |
182 | char target_comm[AUDIT_AUX_PIDS][TASK_COMM_LEN]; | 183 | char target_comm[AUDIT_AUX_PIDS][TASK_COMM_LEN]; |
183 | int pid_count; | 184 | int pid_count; |
@@ -219,6 +220,7 @@ struct audit_context { | |||
219 | pid_t target_pid; | 220 | pid_t target_pid; |
220 | uid_t target_auid; | 221 | uid_t target_auid; |
221 | uid_t target_uid; | 222 | uid_t target_uid; |
223 | unsigned int target_sessionid; | ||
222 | u32 target_sid; | 224 | u32 target_sid; |
223 | char target_comm[TASK_COMM_LEN]; | 225 | char target_comm[TASK_COMM_LEN]; |
224 | 226 | ||
@@ -936,7 +938,8 @@ static void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk | |||
936 | } | 938 | } |
937 | 939 | ||
938 | static int audit_log_pid_context(struct audit_context *context, pid_t pid, | 940 | static int audit_log_pid_context(struct audit_context *context, pid_t pid, |
939 | uid_t auid, uid_t uid, u32 sid, char *comm) | 941 | uid_t auid, uid_t uid, unsigned int sessionid, |
942 | u32 sid, char *comm) | ||
940 | { | 943 | { |
941 | struct audit_buffer *ab; | 944 | struct audit_buffer *ab; |
942 | char *s = NULL; | 945 | char *s = NULL; |
@@ -947,7 +950,8 @@ static int audit_log_pid_context(struct audit_context *context, pid_t pid, | |||
947 | if (!ab) | 950 | if (!ab) |
948 | return 1; | 951 | return 1; |
949 | 952 | ||
950 | audit_log_format(ab, "opid=%d oauid=%d ouid=%d", pid, auid, uid); | 953 | audit_log_format(ab, "opid=%d oauid=%d ouid=%d oses=%d", pid, auid, |
954 | uid, sessionid); | ||
951 | if (selinux_sid_to_string(sid, &s, &len)) { | 955 | if (selinux_sid_to_string(sid, &s, &len)) { |
952 | audit_log_format(ab, " obj=(none)"); | 956 | audit_log_format(ab, " obj=(none)"); |
953 | rc = 1; | 957 | rc = 1; |
@@ -1056,7 +1060,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1056 | " a0=%lx a1=%lx a2=%lx a3=%lx items=%d" | 1060 | " a0=%lx a1=%lx a2=%lx a3=%lx items=%d" |
1057 | " ppid=%d pid=%d auid=%u uid=%u gid=%u" | 1061 | " ppid=%d pid=%d auid=%u uid=%u gid=%u" |
1058 | " euid=%u suid=%u fsuid=%u" | 1062 | " euid=%u suid=%u fsuid=%u" |
1059 | " egid=%u sgid=%u fsgid=%u tty=%s", | 1063 | " egid=%u sgid=%u fsgid=%u tty=%s ses=%u", |
1060 | context->argv[0], | 1064 | context->argv[0], |
1061 | context->argv[1], | 1065 | context->argv[1], |
1062 | context->argv[2], | 1066 | context->argv[2], |
@@ -1068,7 +1072,8 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1068 | context->uid, | 1072 | context->uid, |
1069 | context->gid, | 1073 | context->gid, |
1070 | context->euid, context->suid, context->fsuid, | 1074 | context->euid, context->suid, context->fsuid, |
1071 | context->egid, context->sgid, context->fsgid, tty); | 1075 | context->egid, context->sgid, context->fsgid, tty, |
1076 | tsk->sessionid); | ||
1072 | 1077 | ||
1073 | mutex_unlock(&tty_mutex); | 1078 | mutex_unlock(&tty_mutex); |
1074 | 1079 | ||
@@ -1187,6 +1192,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1187 | if (audit_log_pid_context(context, axs->target_pid[i], | 1192 | if (audit_log_pid_context(context, axs->target_pid[i], |
1188 | axs->target_auid[i], | 1193 | axs->target_auid[i], |
1189 | axs->target_uid[i], | 1194 | axs->target_uid[i], |
1195 | axs->target_sessionid[i], | ||
1190 | axs->target_sid[i], | 1196 | axs->target_sid[i], |
1191 | axs->target_comm[i])) | 1197 | axs->target_comm[i])) |
1192 | call_panic = 1; | 1198 | call_panic = 1; |
@@ -1195,6 +1201,7 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1195 | if (context->target_pid && | 1201 | if (context->target_pid && |
1196 | audit_log_pid_context(context, context->target_pid, | 1202 | audit_log_pid_context(context, context->target_pid, |
1197 | context->target_auid, context->target_uid, | 1203 | context->target_auid, context->target_uid, |
1204 | context->target_sessionid, | ||
1198 | context->target_sid, context->target_comm)) | 1205 | context->target_sid, context->target_comm)) |
1199 | call_panic = 1; | 1206 | call_panic = 1; |
1200 | 1207 | ||
@@ -1787,6 +1794,9 @@ void auditsc_get_stamp(struct audit_context *ctx, | |||
1787 | ctx->auditable = 1; | 1794 | ctx->auditable = 1; |
1788 | } | 1795 | } |
1789 | 1796 | ||
1797 | /* global counter which is incremented every time something logs in */ | ||
1798 | static atomic_t session_id = ATOMIC_INIT(0); | ||
1799 | |||
1790 | /** | 1800 | /** |
1791 | * audit_set_loginuid - set a task's audit_context loginuid | 1801 | * audit_set_loginuid - set a task's audit_context loginuid |
1792 | * @task: task whose audit context is being modified | 1802 | * @task: task whose audit context is being modified |
@@ -1798,6 +1808,7 @@ void auditsc_get_stamp(struct audit_context *ctx, | |||
1798 | */ | 1808 | */ |
1799 | int audit_set_loginuid(struct task_struct *task, uid_t loginuid) | 1809 | int audit_set_loginuid(struct task_struct *task, uid_t loginuid) |
1800 | { | 1810 | { |
1811 | unsigned int sessionid = atomic_inc_return(&session_id); | ||
1801 | struct audit_context *context = task->audit_context; | 1812 | struct audit_context *context = task->audit_context; |
1802 | 1813 | ||
1803 | if (context && context->in_syscall) { | 1814 | if (context && context->in_syscall) { |
@@ -1806,12 +1817,15 @@ int audit_set_loginuid(struct task_struct *task, uid_t loginuid) | |||
1806 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); | 1817 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_LOGIN); |
1807 | if (ab) { | 1818 | if (ab) { |
1808 | audit_log_format(ab, "login pid=%d uid=%u " | 1819 | audit_log_format(ab, "login pid=%d uid=%u " |
1809 | "old auid=%u new auid=%u", | 1820 | "old auid=%u new auid=%u" |
1821 | " old ses=%u new ses=%u", | ||
1810 | task->pid, task->uid, | 1822 | task->pid, task->uid, |
1811 | task->loginuid, loginuid); | 1823 | task->loginuid, loginuid, |
1824 | task->sessionid, sessionid); | ||
1812 | audit_log_end(ab); | 1825 | audit_log_end(ab); |
1813 | } | 1826 | } |
1814 | } | 1827 | } |
1828 | task->sessionid = sessionid; | ||
1815 | task->loginuid = loginuid; | 1829 | task->loginuid = loginuid; |
1816 | return 0; | 1830 | return 0; |
1817 | } | 1831 | } |
@@ -2200,6 +2214,7 @@ void __audit_ptrace(struct task_struct *t) | |||
2200 | context->target_pid = t->pid; | 2214 | context->target_pid = t->pid; |
2201 | context->target_auid = audit_get_loginuid(t); | 2215 | context->target_auid = audit_get_loginuid(t); |
2202 | context->target_uid = t->uid; | 2216 | context->target_uid = t->uid; |
2217 | context->target_sessionid = audit_get_sessionid(t); | ||
2203 | selinux_get_task_sid(t, &context->target_sid); | 2218 | selinux_get_task_sid(t, &context->target_sid); |
2204 | memcpy(context->target_comm, t->comm, TASK_COMM_LEN); | 2219 | memcpy(context->target_comm, t->comm, TASK_COMM_LEN); |
2205 | } | 2220 | } |
@@ -2240,6 +2255,7 @@ int __audit_signal_info(int sig, struct task_struct *t) | |||
2240 | ctx->target_pid = t->tgid; | 2255 | ctx->target_pid = t->tgid; |
2241 | ctx->target_auid = audit_get_loginuid(t); | 2256 | ctx->target_auid = audit_get_loginuid(t); |
2242 | ctx->target_uid = t->uid; | 2257 | ctx->target_uid = t->uid; |
2258 | ctx->target_sessionid = audit_get_sessionid(t); | ||
2243 | selinux_get_task_sid(t, &ctx->target_sid); | 2259 | selinux_get_task_sid(t, &ctx->target_sid); |
2244 | memcpy(ctx->target_comm, t->comm, TASK_COMM_LEN); | 2260 | memcpy(ctx->target_comm, t->comm, TASK_COMM_LEN); |
2245 | return 0; | 2261 | return 0; |
@@ -2260,6 +2276,7 @@ int __audit_signal_info(int sig, struct task_struct *t) | |||
2260 | axp->target_pid[axp->pid_count] = t->tgid; | 2276 | axp->target_pid[axp->pid_count] = t->tgid; |
2261 | axp->target_auid[axp->pid_count] = audit_get_loginuid(t); | 2277 | axp->target_auid[axp->pid_count] = audit_get_loginuid(t); |
2262 | axp->target_uid[axp->pid_count] = t->uid; | 2278 | axp->target_uid[axp->pid_count] = t->uid; |
2279 | axp->target_sessionid[axp->pid_count] = audit_get_sessionid(t); | ||
2263 | selinux_get_task_sid(t, &axp->target_sid[axp->pid_count]); | 2280 | selinux_get_task_sid(t, &axp->target_sid[axp->pid_count]); |
2264 | memcpy(axp->target_comm[axp->pid_count], t->comm, TASK_COMM_LEN); | 2281 | memcpy(axp->target_comm[axp->pid_count], t->comm, TASK_COMM_LEN); |
2265 | axp->pid_count++; | 2282 | axp->pid_count++; |
@@ -2278,6 +2295,8 @@ void audit_core_dumps(long signr) | |||
2278 | { | 2295 | { |
2279 | struct audit_buffer *ab; | 2296 | struct audit_buffer *ab; |
2280 | u32 sid; | 2297 | u32 sid; |
2298 | uid_t auid = audit_get_loginuid(current); | ||
2299 | unsigned int sessionid = audit_get_sessionid(current); | ||
2281 | 2300 | ||
2282 | if (!audit_enabled) | 2301 | if (!audit_enabled) |
2283 | return; | 2302 | return; |
@@ -2286,9 +2305,8 @@ void audit_core_dumps(long signr) | |||
2286 | return; | 2305 | return; |
2287 | 2306 | ||
2288 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_ANOM_ABEND); | 2307 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_ANOM_ABEND); |
2289 | audit_log_format(ab, "auid=%u uid=%u gid=%u", | 2308 | audit_log_format(ab, "auid=%u uid=%u gid=%u ses=%u", |
2290 | audit_get_loginuid(current), | 2309 | auid, current->uid, current->gid, sessionid); |
2291 | current->uid, current->gid); | ||
2292 | selinux_get_task_sid(current, &sid); | 2310 | selinux_get_task_sid(current, &sid); |
2293 | if (sid) { | 2311 | if (sid) { |
2294 | char *ctx = NULL; | 2312 | char *ctx = NULL; |