diff options
author | Eric Paris <eparis@redhat.com> | 2008-11-11 05:48:22 -0500 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2008-11-11 05:48:22 -0500 |
commit | e68b75a027bb94066576139ee33676264f867b87 (patch) | |
tree | 2c31f59a4abe9d7bb3cb75fdf3b57772feeeb6f6 /kernel/auditsc.c | |
parent | 3fc689e96c0c90b6fede5946d6c31075e9464f69 (diff) |
When the capset syscall is used it is not possible for audit to record the
actual capbilities being added/removed. This patch adds a new record type
which emits the target pid and the eff, inh, and perm cap sets.
example output if you audit capset syscalls would be:
type=SYSCALL msg=audit(1225743140.465:76): arch=c000003e syscall=126 success=yes exit=0 a0=17f2014 a1=17f201c a2=80000000 a3=7fff2ab7f060 items=0 ppid=2160 pid=2223 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=1 comm="setcap" exe="/usr/sbin/setcap" subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 key=(null)
type=UNKNOWN[1322] msg=audit(1225743140.465:76): pid=0 cap_pi=ffffffffffffffff cap_pp=ffffffffffffffff cap_pe=ffffffffffffffff
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'kernel/auditsc.c')
-rw-r--r-- | kernel/auditsc.c | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 3229cd4206f5..cef34235b362 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c | |||
@@ -204,6 +204,12 @@ struct audit_aux_data_bprm_fcaps { | |||
204 | struct audit_cap_data new_pcap; | 204 | struct audit_cap_data new_pcap; |
205 | }; | 205 | }; |
206 | 206 | ||
207 | struct audit_aux_data_capset { | ||
208 | struct audit_aux_data d; | ||
209 | pid_t pid; | ||
210 | struct audit_cap_data cap; | ||
211 | }; | ||
212 | |||
207 | struct audit_tree_refs { | 213 | struct audit_tree_refs { |
208 | struct audit_tree_refs *next; | 214 | struct audit_tree_refs *next; |
209 | struct audit_chunk *c[31]; | 215 | struct audit_chunk *c[31]; |
@@ -1397,6 +1403,14 @@ static void audit_log_exit(struct audit_context *context, struct task_struct *ts | |||
1397 | audit_log_cap(ab, "new_pe", &axs->new_pcap.effective); | 1403 | audit_log_cap(ab, "new_pe", &axs->new_pcap.effective); |
1398 | break; } | 1404 | break; } |
1399 | 1405 | ||
1406 | case AUDIT_CAPSET: { | ||
1407 | struct audit_aux_data_capset *axs = (void *)aux; | ||
1408 | audit_log_format(ab, "pid=%d", axs->pid); | ||
1409 | audit_log_cap(ab, "cap_pi", &axs->cap.inheritable); | ||
1410 | audit_log_cap(ab, "cap_pp", &axs->cap.permitted); | ||
1411 | audit_log_cap(ab, "cap_pe", &axs->cap.effective); | ||
1412 | break; } | ||
1413 | |||
1400 | } | 1414 | } |
1401 | audit_log_end(ab); | 1415 | audit_log_end(ab); |
1402 | } | 1416 | } |
@@ -2570,6 +2584,40 @@ void __audit_log_bprm_fcaps(struct linux_binprm *bprm, kernel_cap_t *pP, kernel_ | |||
2570 | } | 2584 | } |
2571 | 2585 | ||
2572 | /** | 2586 | /** |
2587 | * __audit_log_capset - store information about the arguments to the capset syscall | ||
2588 | * @pid target pid of the capset call | ||
2589 | * @eff effective cap set | ||
2590 | * @inh inheritible cap set | ||
2591 | * @perm permited cap set | ||
2592 | * | ||
2593 | * Record the aguments userspace sent to sys_capset for later printing by the | ||
2594 | * audit system if applicable | ||
2595 | */ | ||
2596 | int __audit_log_capset(pid_t pid, kernel_cap_t *eff, kernel_cap_t *inh, kernel_cap_t *perm) | ||
2597 | { | ||
2598 | struct audit_aux_data_capset *ax; | ||
2599 | struct audit_context *context = current->audit_context; | ||
2600 | |||
2601 | if (likely(!audit_enabled || !context || context->dummy)) | ||
2602 | return 0; | ||
2603 | |||
2604 | ax = kmalloc(sizeof(*ax), GFP_KERNEL); | ||
2605 | if (!ax) | ||
2606 | return -ENOMEM; | ||
2607 | |||
2608 | ax->d.type = AUDIT_CAPSET; | ||
2609 | ax->d.next = context->aux; | ||
2610 | context->aux = (void *)ax; | ||
2611 | |||
2612 | ax->pid = pid; | ||
2613 | ax->cap.effective = *eff; | ||
2614 | ax->cap.inheritable = *eff; | ||
2615 | ax->cap.permitted = *perm; | ||
2616 | |||
2617 | return 0; | ||
2618 | } | ||
2619 | |||
2620 | /** | ||
2573 | * audit_core_dumps - record information about processes that end abnormally | 2621 | * audit_core_dumps - record information about processes that end abnormally |
2574 | * @signr: signal value | 2622 | * @signr: signal value |
2575 | * | 2623 | * |