aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2008-11-11 05:48:22 -0500
committerJames Morris <jmorris@namei.org>2008-11-11 05:48:22 -0500
commite68b75a027bb94066576139ee33676264f867b87 (patch)
tree2c31f59a4abe9d7bb3cb75fdf3b57772feeeb6f6
parent3fc689e96c0c90b6fede5946d6c31075e9464f69 (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>
-rw-r--r--include/linux/audit.h10
-rw-r--r--kernel/auditsc.c48
-rw-r--r--kernel/capability.c5
3 files changed, 63 insertions, 0 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 8cfb9feb2a05..6fbebac7b1bf 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -100,6 +100,7 @@
100#define AUDIT_TTY 1319 /* Input on an administrative TTY */ 100#define AUDIT_TTY 1319 /* Input on an administrative TTY */
101#define AUDIT_EOE 1320 /* End of multi-record event */ 101#define AUDIT_EOE 1320 /* End of multi-record event */
102#define AUDIT_BPRM_FCAPS 1321 /* Information about fcaps increasing perms */ 102#define AUDIT_BPRM_FCAPS 1321 /* Information about fcaps increasing perms */
103#define AUDIT_CAPSET 1322 /* Record showing argument to sys_capset */
103 104
104#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */ 105#define AUDIT_AVC 1400 /* SE Linux avc denial or grant */
105#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */ 106#define AUDIT_SELINUX_ERR 1401 /* Internal SE Linux Errors */
@@ -454,6 +455,7 @@ extern int __audit_mq_timedreceive(mqd_t mqdes, size_t msg_len, unsigned int __u
454extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification); 455extern int __audit_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification);
455extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat); 456extern int __audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat);
456extern void __audit_log_bprm_fcaps(struct linux_binprm *bprm, kernel_cap_t *pP, kernel_cap_t *pE); 457extern void __audit_log_bprm_fcaps(struct linux_binprm *bprm, kernel_cap_t *pP, kernel_cap_t *pE);
458extern int __audit_log_capset(pid_t pid, kernel_cap_t *eff, kernel_cap_t *inh, kernel_cap_t *perm);
457 459
458static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp) 460static inline int audit_ipc_obj(struct kern_ipc_perm *ipcp)
459{ 461{
@@ -526,6 +528,13 @@ static inline void audit_log_bprm_fcaps(struct linux_binprm *bprm, kernel_cap_t
526 __audit_log_bprm_fcaps(bprm, pP, pE); 528 __audit_log_bprm_fcaps(bprm, pP, pE);
527} 529}
528 530
531static inline int audit_log_capset(pid_t pid, kernel_cap_t *eff, kernel_cap_t *inh, kernel_cap_t *perm)
532{
533 if (unlikely(!audit_dummy_context()))
534 return __audit_log_capset(pid, eff, inh, perm);
535 return 0;
536}
537
529extern int audit_n_rules; 538extern int audit_n_rules;
530extern int audit_signals; 539extern int audit_signals;
531#else 540#else
@@ -558,6 +567,7 @@ extern int audit_signals;
558#define audit_mq_notify(d,n) ({ 0; }) 567#define audit_mq_notify(d,n) ({ 0; })
559#define audit_mq_getsetattr(d,s) ({ 0; }) 568#define audit_mq_getsetattr(d,s) ({ 0; })
560#define audit_log_bprm_fcaps(b, p, e) do { ; } while (0) 569#define audit_log_bprm_fcaps(b, p, e) do { ; } while (0)
570#define audit_log_capset(pid, e, i, p) ({ 0; })
561#define audit_ptrace(t) ((void)0) 571#define audit_ptrace(t) ((void)0)
562#define audit_n_rules 0 572#define audit_n_rules 0
563#define audit_signals 0 573#define audit_signals 0
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
207struct audit_aux_data_capset {
208 struct audit_aux_data d;
209 pid_t pid;
210 struct audit_cap_data cap;
211};
212
207struct audit_tree_refs { 213struct 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 */
2596int __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 *
diff --git a/kernel/capability.c b/kernel/capability.c
index e13a68535ad5..19f9eda89975 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -7,6 +7,7 @@
7 * 30 May 2002: Cleanup, Robert M. Love <rml@tech9.net> 7 * 30 May 2002: Cleanup, Robert M. Love <rml@tech9.net>
8 */ 8 */
9 9
10#include <linux/audit.h>
10#include <linux/capability.h> 11#include <linux/capability.h>
11#include <linux/mm.h> 12#include <linux/mm.h>
12#include <linux/module.h> 13#include <linux/module.h>
@@ -468,6 +469,10 @@ asmlinkage long sys_capset(cap_user_header_t header, const cap_user_data_t data)
468 i++; 469 i++;
469 } 470 }
470 471
472 ret = audit_log_capset(pid, &effective, &inheritable, &permitted);
473 if (ret)
474 return ret;
475
471 if (pid && (pid != task_pid_vnr(current))) 476 if (pid && (pid != task_pid_vnr(current)))
472 ret = do_sys_capset_other_tasks(pid, &effective, &inheritable, 477 ret = do_sys_capset_other_tasks(pid, &effective, &inheritable,
473 &permitted); 478 &permitted);