aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/auditsc.c
diff options
context:
space:
mode:
authorRichard Guy Briggs <rgb@redhat.com>2013-12-11 13:52:26 -0500
committerEric Paris <eparis@redhat.com>2014-03-20 10:11:55 -0400
commitf1dc4867ff41b7bcca57fa19449d1fe7ad517ac1 (patch)
tree873f8e7625dc54ae20a0cc2513fb6a33027f36d7 /kernel/auditsc.c
parentc92cdeb45eea38515e82187f48c2e4f435fb4e25 (diff)
audit: anchor all pid references in the initial pid namespace
Store and log all PIDs with reference to the initial PID namespace and use the access functions task_pid_nr() and task_tgid_nr() for task->pid and task->tgid. Cc: "Eric W. Biederman" <ebiederm@xmission.com> (informed by ebiederman's c776b5d2) Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r--kernel/auditsc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index a6cf7ab56e61..6381f25ac3d4 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -457,10 +457,12 @@ static int audit_filter_rules(struct task_struct *tsk,
457 struct audit_field *f = &rule->fields[i]; 457 struct audit_field *f = &rule->fields[i];
458 struct audit_names *n; 458 struct audit_names *n;
459 int result = 0; 459 int result = 0;
460 pid_t pid;
460 461
461 switch (f->type) { 462 switch (f->type) {
462 case AUDIT_PID: 463 case AUDIT_PID:
463 result = audit_comparator(tsk->pid, f->op, f->val); 464 pid = task_pid_nr(tsk);
465 result = audit_comparator(pid, f->op, f->val);
464 break; 466 break;
465 case AUDIT_PPID: 467 case AUDIT_PPID:
466 if (ctx) { 468 if (ctx) {
@@ -2051,7 +2053,7 @@ static void audit_log_set_loginuid(kuid_t koldloginuid, kuid_t kloginuid,
2051 audit_log_format(ab, "pid=%d uid=%u" 2053 audit_log_format(ab, "pid=%d uid=%u"
2052 " old-auid=%u new-auid=%u old-ses=%u new-ses=%u" 2054 " old-auid=%u new-auid=%u old-ses=%u new-ses=%u"
2053 " res=%d", 2055 " res=%d",
2054 current->pid, uid, 2056 task_pid_nr(current), uid,
2055 oldloginuid, loginuid, oldsessionid, sessionid, 2057 oldloginuid, loginuid, oldsessionid, sessionid,
2056 !rc); 2058 !rc);
2057 audit_log_end(ab); 2059 audit_log_end(ab);
@@ -2275,7 +2277,7 @@ void __audit_ptrace(struct task_struct *t)
2275{ 2277{
2276 struct audit_context *context = current->audit_context; 2278 struct audit_context *context = current->audit_context;
2277 2279
2278 context->target_pid = t->pid; 2280 context->target_pid = task_pid_nr(t);
2279 context->target_auid = audit_get_loginuid(t); 2281 context->target_auid = audit_get_loginuid(t);
2280 context->target_uid = task_uid(t); 2282 context->target_uid = task_uid(t);
2281 context->target_sessionid = audit_get_sessionid(t); 2283 context->target_sessionid = audit_get_sessionid(t);
@@ -2300,7 +2302,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
2300 2302
2301 if (audit_pid && t->tgid == audit_pid) { 2303 if (audit_pid && t->tgid == audit_pid) {
2302 if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) { 2304 if (sig == SIGTERM || sig == SIGHUP || sig == SIGUSR1 || sig == SIGUSR2) {
2303 audit_sig_pid = tsk->pid; 2305 audit_sig_pid = task_pid_nr(tsk);
2304 if (uid_valid(tsk->loginuid)) 2306 if (uid_valid(tsk->loginuid))
2305 audit_sig_uid = tsk->loginuid; 2307 audit_sig_uid = tsk->loginuid;
2306 else 2308 else
@@ -2314,7 +2316,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
2314 /* optimize the common case by putting first signal recipient directly 2316 /* optimize the common case by putting first signal recipient directly
2315 * in audit_context */ 2317 * in audit_context */
2316 if (!ctx->target_pid) { 2318 if (!ctx->target_pid) {
2317 ctx->target_pid = t->tgid; 2319 ctx->target_pid = task_tgid_nr(t);
2318 ctx->target_auid = audit_get_loginuid(t); 2320 ctx->target_auid = audit_get_loginuid(t);
2319 ctx->target_uid = t_uid; 2321 ctx->target_uid = t_uid;
2320 ctx->target_sessionid = audit_get_sessionid(t); 2322 ctx->target_sessionid = audit_get_sessionid(t);
@@ -2335,7 +2337,7 @@ int __audit_signal_info(int sig, struct task_struct *t)
2335 } 2337 }
2336 BUG_ON(axp->pid_count >= AUDIT_AUX_PIDS); 2338 BUG_ON(axp->pid_count >= AUDIT_AUX_PIDS);
2337 2339
2338 axp->target_pid[axp->pid_count] = t->tgid; 2340 axp->target_pid[axp->pid_count] = task_tgid_nr(t);
2339 axp->target_auid[axp->pid_count] = audit_get_loginuid(t); 2341 axp->target_auid[axp->pid_count] = audit_get_loginuid(t);
2340 axp->target_uid[axp->pid_count] = t_uid; 2342 axp->target_uid[axp->pid_count] = t_uid;
2341 axp->target_sessionid[axp->pid_count] = audit_get_sessionid(t); 2343 axp->target_sessionid[axp->pid_count] = audit_get_sessionid(t);
@@ -2435,7 +2437,7 @@ static void audit_log_task(struct audit_buffer *ab)
2435 from_kgid(&init_user_ns, gid), 2437 from_kgid(&init_user_ns, gid),
2436 sessionid); 2438 sessionid);
2437 audit_log_task_context(ab); 2439 audit_log_task_context(ab);
2438 audit_log_format(ab, " pid=%d comm=", current->pid); 2440 audit_log_format(ab, " pid=%d comm=", task_pid_nr(current));
2439 audit_log_untrustedstring(ab, current->comm); 2441 audit_log_untrustedstring(ab, current->comm);
2440 if (mm) { 2442 if (mm) {
2441 down_read(&mm->mmap_sem); 2443 down_read(&mm->mmap_sem);