diff options
| author | Amy Griffis <amy.griffis@hp.com> | 2007-03-29 18:01:04 -0400 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2007-05-11 05:38:25 -0400 |
| commit | e54dc2431d740a79a6bd013babade99d71b1714f (patch) | |
| tree | 16b0990d5c16946239a17b332f54b5918fb03305 | |
| parent | 7f13da40e36c84d0d046b7adbd060af7d3717250 (diff) | |
[PATCH] audit signal recipients
When auditing syscalls that send signals, log the pid and security
context for each target process. Optimize the data collection by
adding a counter for signal-related rules, and avoiding allocating an
aux struct unless we have more than one target process. For process
groups, collect pid/context data in blocks of 16. Move the
audit_signal_info() hook up in check_kill_permission() so we audit
attempts where permission is denied.
Signed-off-by: Amy Griffis <amy.griffis@hp.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
| -rw-r--r-- | arch/ia64/kernel/audit.c | 9 | ||||
| -rw-r--r-- | arch/powerpc/kernel/audit.c | 9 | ||||
| -rw-r--r-- | arch/s390/kernel/audit.c | 9 | ||||
| -rw-r--r-- | arch/sparc64/kernel/audit.c | 9 | ||||
| -rw-r--r-- | arch/x86_64/kernel/audit.c | 9 | ||||
| -rw-r--r-- | include/linux/audit.h | 3 | ||||
| -rw-r--r-- | kernel/audit.h | 13 | ||||
| -rw-r--r-- | kernel/auditfilter.c | 48 | ||||
| -rw-r--r-- | kernel/auditsc.c | 111 | ||||
| -rw-r--r-- | kernel/signal.c | 10 | ||||
| -rw-r--r-- | lib/audit.c | 5 |
11 files changed, 206 insertions, 29 deletions
diff --git a/arch/ia64/kernel/audit.c b/arch/ia64/kernel/audit.c index 538312adc53b..f3802ae89b10 100644 --- a/arch/ia64/kernel/audit.c +++ b/arch/ia64/kernel/audit.c | |||
| @@ -28,6 +28,15 @@ static unsigned signal_class[] = { | |||
| 28 | ~0U | 28 | ~0U |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | int audit_classify_arch(int arch) | ||
| 32 | { | ||
| 33 | #ifdef CONFIG_IA32_SUPPORT | ||
| 34 | if (arch == AUDIT_ARCH_I386) | ||
| 35 | return 1; | ||
| 36 | #endif | ||
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 31 | int audit_classify_syscall(int abi, unsigned syscall) | 40 | int audit_classify_syscall(int abi, unsigned syscall) |
| 32 | { | 41 | { |
| 33 | #ifdef CONFIG_IA32_SUPPORT | 42 | #ifdef CONFIG_IA32_SUPPORT |
diff --git a/arch/powerpc/kernel/audit.c b/arch/powerpc/kernel/audit.c index 66d54bada0bf..a4dab7cab348 100644 --- a/arch/powerpc/kernel/audit.c +++ b/arch/powerpc/kernel/audit.c | |||
| @@ -28,6 +28,15 @@ static unsigned signal_class[] = { | |||
| 28 | ~0U | 28 | ~0U |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | int audit_classify_arch(int arch) | ||
| 32 | { | ||
| 33 | #ifdef CONFIG_PPC64 | ||
| 34 | if (arch == AUDIT_ARCH_PPC) | ||
| 35 | return 1; | ||
| 36 | #endif | ||
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 31 | int audit_classify_syscall(int abi, unsigned syscall) | 40 | int audit_classify_syscall(int abi, unsigned syscall) |
| 32 | { | 41 | { |
| 33 | #ifdef CONFIG_PPC64 | 42 | #ifdef CONFIG_PPC64 |
diff --git a/arch/s390/kernel/audit.c b/arch/s390/kernel/audit.c index 7affafe626d2..d1c76fe10f29 100644 --- a/arch/s390/kernel/audit.c +++ b/arch/s390/kernel/audit.c | |||
| @@ -28,6 +28,15 @@ static unsigned signal_class[] = { | |||
| 28 | ~0U | 28 | ~0U |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | int audit_classify_arch(int arch) | ||
| 32 | { | ||
| 33 | #ifdef CONFIG_COMPAT | ||
| 34 | if (arch == AUDIT_ARCH_S390) | ||
| 35 | return 1; | ||
| 36 | #endif | ||
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 31 | int audit_classify_syscall(int abi, unsigned syscall) | 40 | int audit_classify_syscall(int abi, unsigned syscall) |
| 32 | { | 41 | { |
| 33 | #ifdef CONFIG_COMPAT | 42 | #ifdef CONFIG_COMPAT |
diff --git a/arch/sparc64/kernel/audit.c b/arch/sparc64/kernel/audit.c index d57a9dad0ab7..24d7f4b4178a 100644 --- a/arch/sparc64/kernel/audit.c +++ b/arch/sparc64/kernel/audit.c | |||
| @@ -28,6 +28,15 @@ static unsigned signal_class[] = { | |||
| 28 | ~0U | 28 | ~0U |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | int audit_classify_arch(int arch) | ||
| 32 | { | ||
| 33 | #ifdef CONFIG_SPARC32_COMPAT | ||
| 34 | if (arch == AUDIT_ARCH_SPARC) | ||
| 35 | return 1; | ||
| 36 | #endif | ||
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 31 | int audit_classify_syscall(int abi, unsigned syscall) | 40 | int audit_classify_syscall(int abi, unsigned syscall) |
| 32 | { | 41 | { |
| 33 | #ifdef CONFIG_SPARC32_COMPAT | 42 | #ifdef CONFIG_SPARC32_COMPAT |
diff --git a/arch/x86_64/kernel/audit.c b/arch/x86_64/kernel/audit.c index b970de66ee59..06d3e5a14d9d 100644 --- a/arch/x86_64/kernel/audit.c +++ b/arch/x86_64/kernel/audit.c | |||
| @@ -28,6 +28,15 @@ static unsigned signal_class[] = { | |||
| 28 | ~0U | 28 | ~0U |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | int audit_classify_arch(int arch) | ||
| 32 | { | ||
| 33 | #ifdef CONFIG_IA32_EMULATION | ||
| 34 | if (arch == AUDIT_ARCH_I386) | ||
| 35 | return 1; | ||
| 36 | #endif | ||
| 37 | return 0; | ||
| 38 | } | ||
| 39 | |||
| 31 | int audit_classify_syscall(int abi, unsigned syscall) | 40 | int audit_classify_syscall(int abi, unsigned syscall) |
| 32 | { | 41 | { |
| 33 | #ifdef CONFIG_IA32_EMULATION | 42 | #ifdef CONFIG_IA32_EMULATION |
diff --git a/include/linux/audit.h b/include/linux/audit.h index f165308254dc..fde0f1420cd2 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
| @@ -340,6 +340,7 @@ struct mqstat; | |||
| 340 | #define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS ) | 340 | #define AUDITSC_RESULT(x) ( ((long)(x))<0?AUDITSC_FAILURE:AUDITSC_SUCCESS ) |
| 341 | extern int __init audit_register_class(int class, unsigned *list); | 341 | extern int __init audit_register_class(int class, unsigned *list); |
| 342 | extern int audit_classify_syscall(int abi, unsigned syscall); | 342 | extern int audit_classify_syscall(int abi, unsigned syscall); |
| 343 | extern int audit_classify_arch(int arch); | ||
| 343 | #ifdef CONFIG_AUDITSYSCALL | 344 | #ifdef CONFIG_AUDITSYSCALL |
| 344 | /* These are defined in auditsc.c */ | 345 | /* These are defined in auditsc.c */ |
| 345 | /* Public API */ | 346 | /* Public API */ |
| @@ -458,6 +459,7 @@ static inline int audit_mq_getsetattr(mqd_t mqdes, struct mq_attr *mqstat) | |||
| 458 | return 0; | 459 | return 0; |
| 459 | } | 460 | } |
| 460 | extern int audit_n_rules; | 461 | extern int audit_n_rules; |
| 462 | extern int audit_signals; | ||
| 461 | #else | 463 | #else |
| 462 | #define audit_alloc(t) ({ 0; }) | 464 | #define audit_alloc(t) ({ 0; }) |
| 463 | #define audit_free(t) do { ; } while (0) | 465 | #define audit_free(t) do { ; } while (0) |
| @@ -490,6 +492,7 @@ extern int audit_n_rules; | |||
| 490 | #define audit_mq_getsetattr(d,s) ({ 0; }) | 492 | #define audit_mq_getsetattr(d,s) ({ 0; }) |
| 491 | #define audit_ptrace(t) ((void)0) | 493 | #define audit_ptrace(t) ((void)0) |
| 492 | #define audit_n_rules 0 | 494 | #define audit_n_rules 0 |
| 495 | #define audit_signals 0 | ||
| 493 | #endif | 496 | #endif |
| 494 | 497 | ||
| 495 | #ifdef CONFIG_AUDIT | 498 | #ifdef CONFIG_AUDIT |
diff --git a/kernel/audit.h b/kernel/audit.h index a3370232a390..815d6f5c04ee 100644 --- a/kernel/audit.h +++ b/kernel/audit.h | |||
| @@ -83,6 +83,7 @@ struct audit_krule { | |||
| 83 | u32 field_count; | 83 | u32 field_count; |
| 84 | char *filterkey; /* ties events to rules */ | 84 | char *filterkey; /* ties events to rules */ |
| 85 | struct audit_field *fields; | 85 | struct audit_field *fields; |
| 86 | struct audit_field *arch_f; /* quick access to arch field */ | ||
| 86 | struct audit_field *inode_f; /* quick access to an inode field */ | 87 | struct audit_field *inode_f; /* quick access to an inode field */ |
| 87 | struct audit_watch *watch; /* associated watch */ | 88 | struct audit_watch *watch; /* associated watch */ |
| 88 | struct list_head rlist; /* entry in audit_watch.rules list */ | 89 | struct list_head rlist; /* entry in audit_watch.rules list */ |
| @@ -131,17 +132,19 @@ extern void audit_handle_ievent(struct inotify_watch *, u32, u32, u32, | |||
| 131 | extern int selinux_audit_rule_update(void); | 132 | extern int selinux_audit_rule_update(void); |
| 132 | 133 | ||
| 133 | #ifdef CONFIG_AUDITSYSCALL | 134 | #ifdef CONFIG_AUDITSYSCALL |
| 134 | extern void __audit_signal_info(int sig, struct task_struct *t); | 135 | extern int __audit_signal_info(int sig, struct task_struct *t); |
| 135 | static inline void audit_signal_info(int sig, struct task_struct *t) | 136 | static inline int audit_signal_info(int sig, struct task_struct *t) |
| 136 | { | 137 | { |
| 137 | if (unlikely(audit_pid && t->tgid == audit_pid)) | 138 | if (unlikely((audit_pid && t->tgid == audit_pid) || |
| 138 | __audit_signal_info(sig, t); | 139 | (audit_signals && !audit_dummy_context()))) |
| 140 | return __audit_signal_info(sig, t); | ||
| 141 | return 0; | ||
| 139 | } | 142 | } |
| 140 | extern enum audit_state audit_filter_inodes(struct task_struct *, | 143 | extern enum audit_state audit_filter_inodes(struct task_struct *, |
| 141 | struct audit_context *); | 144 | struct audit_context *); |
| 142 | extern void audit_set_auditable(struct audit_context *); | 145 | extern void audit_set_auditable(struct audit_context *); |
| 143 | #else | 146 | #else |
| 144 | #define audit_signal_info(s,t) | 147 | #define audit_signal_info(s,t) AUDIT_DISABLED |
| 145 | #define audit_filter_inodes(t,c) AUDIT_DISABLED | 148 | #define audit_filter_inodes(t,c) AUDIT_DISABLED |
| 146 | #define audit_set_auditable(c) | 149 | #define audit_set_auditable(c) |
| 147 | #endif | 150 | #endif |
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index 3749193aed8c..6c61263ff96d 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
| @@ -311,6 +311,43 @@ int audit_match_class(int class, unsigned syscall) | |||
| 311 | return classes[class][AUDIT_WORD(syscall)] & AUDIT_BIT(syscall); | 311 | return classes[class][AUDIT_WORD(syscall)] & AUDIT_BIT(syscall); |
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | static inline int audit_match_class_bits(int class, u32 *mask) | ||
| 315 | { | ||
