diff options
author | Eric Paris <eparis@redhat.com> | 2007-06-04 17:00:14 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2007-07-22 09:57:02 -0400 |
commit | 74f2345b6be1410f824cb7dd638d2c10a9709379 (patch) | |
tree | a9cbdb517eb01b04de3e641d87ef42ad186e91e3 | |
parent | c926e4f432af0f61ac2b9b637fb51a4871a3fc91 (diff) |
[PATCH] allow audit filtering on bit & operations
Right now the audit filter can match on = != > < >= blah blah blah.
This allow the filter to also look at bitwise AND operations, &
Signed-off-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | include/linux/audit.h | 30 | ||||
-rw-r--r-- | kernel/auditfilter.c | 11 |
2 files changed, 28 insertions, 13 deletions
diff --git a/include/linux/audit.h b/include/linux/audit.h index 8ca7ca0b47f0..a35859ab2fdb 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h | |||
@@ -161,7 +161,7 @@ | |||
161 | * are currently used in an audit field constant understood by the kernel. | 161 | * are currently used in an audit field constant understood by the kernel. |
162 | * If you are adding a new #define AUDIT_<whatever>, please ensure that | 162 | * If you are adding a new #define AUDIT_<whatever>, please ensure that |
163 | * AUDIT_UNUSED_BITS is updated if need be. */ | 163 | * AUDIT_UNUSED_BITS is updated if need be. */ |
164 | #define AUDIT_UNUSED_BITS 0x0FFFFC00 | 164 | #define AUDIT_UNUSED_BITS 0x07FFFC00 |
165 | 165 | ||
166 | 166 | ||
167 | /* Rule fields */ | 167 | /* Rule fields */ |
@@ -213,25 +213,29 @@ | |||
213 | #define AUDIT_NEGATE 0x80000000 | 213 | #define AUDIT_NEGATE 0x80000000 |
214 | 214 | ||
215 | /* These are the supported operators. | 215 | /* These are the supported operators. |
216 | * 4 2 1 | 216 | * 4 2 1 8 |
217 | * = > < | 217 | * = > < ? |
218 | * ------- | 218 | * ---------- |
219 | * 0 0 0 0 nonsense | 219 | * 0 0 0 0 00 nonsense |
220 | * 0 0 1 1 < | 220 | * 0 0 0 1 08 & bit mask |
221 | * 0 1 0 2 > | 221 | * 0 0 1 0 10 < |
222 | * 0 1 1 3 != | 222 | * 0 1 0 0 20 > |
223 | * 1 0 0 4 = | 223 | * 0 1 1 0 30 != |
224 | * 1 0 1 5 <= | 224 | * 1 0 0 0 40 = |
225 | * 1 1 0 6 >= | 225 | * 1 0 0 1 48 &= bit test |
226 | * 1 1 1 7 all operators | 226 | * 1 0 1 0 50 <= |
227 | * 1 1 0 0 60 >= | ||
228 | * 1 1 1 1 78 all operators | ||
227 | */ | 229 | */ |
230 | #define AUDIT_BIT_MASK 0x08000000 | ||
228 | #define AUDIT_LESS_THAN 0x10000000 | 231 | #define AUDIT_LESS_THAN 0x10000000 |
229 | #define AUDIT_GREATER_THAN 0x20000000 | 232 | #define AUDIT_GREATER_THAN 0x20000000 |
230 | #define AUDIT_NOT_EQUAL 0x30000000 | 233 | #define AUDIT_NOT_EQUAL 0x30000000 |
231 | #define AUDIT_EQUAL 0x40000000 | 234 | #define AUDIT_EQUAL 0x40000000 |
235 | #define AUDIT_BIT_TEST (AUDIT_BIT_MASK|AUDIT_EQUAL) | ||
232 | #define AUDIT_LESS_THAN_OR_EQUAL (AUDIT_LESS_THAN|AUDIT_EQUAL) | 236 | #define AUDIT_LESS_THAN_OR_EQUAL (AUDIT_LESS_THAN|AUDIT_EQUAL) |
233 | #define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL) | 237 | #define AUDIT_GREATER_THAN_OR_EQUAL (AUDIT_GREATER_THAN|AUDIT_EQUAL) |
234 | #define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL) | 238 | #define AUDIT_OPERATORS (AUDIT_EQUAL|AUDIT_NOT_EQUAL|AUDIT_BIT_MASK) |
235 | 239 | ||
236 | /* Status symbols */ | 240 | /* Status symbols */ |
237 | /* Mask values */ | 241 | /* Mask values */ |
diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c index 0ea96bab91cc..359645cff5b2 100644 --- a/kernel/auditfilter.c +++ b/kernel/auditfilter.c | |||
@@ -456,6 +456,13 @@ static struct audit_entry *audit_rule_to_entry(struct audit_rule *rule) | |||
456 | case AUDIT_DEVMINOR: | 456 | case AUDIT_DEVMINOR: |
457 | case AUDIT_EXIT: | 457 | case AUDIT_EXIT: |
458 | case AUDIT_SUCCESS: | 458 | case AUDIT_SUCCESS: |
459 | /* bit ops are only useful on syscall args */ | ||
460 | if (f->op == AUDIT_BIT_MASK || | ||
461 | f->op == AUDIT_BIT_TEST) { | ||
462 | err = -EINVAL; | ||
463 | goto exit_free; | ||
464 | } | ||
465 | break; | ||
459 | case AUDIT_ARG0: | 466 | case AUDIT_ARG0: |
460 | case AUDIT_ARG1: | 467 | case AUDIT_ARG1: |
461 | case AUDIT_ARG2: | 468 | case AUDIT_ARG2: |
@@ -1566,6 +1573,10 @@ int audit_comparator(const u32 left, const u32 op, const u32 right) | |||
1566 | return (left > right); | 1573 | return (left > right); |
1567 | case AUDIT_GREATER_THAN_OR_EQUAL: | 1574 | case AUDIT_GREATER_THAN_OR_EQUAL: |
1568 | return (left >= right); | 1575 | return (left >= right); |
1576 | case AUDIT_BIT_MASK: | ||
1577 | return (left & right); | ||
1578 | case AUDIT_BIT_TEST: | ||
1579 | return ((left & right) == right); | ||
1569 | } | 1580 | } |
1570 | BUG(); | 1581 | BUG(); |
1571 | return 0; | 1582 | return 0; |