Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 23980
b: refs/heads/master
c: c8edc80
h: refs/heads/master
v: v3
  • Loading branch information
Dustin Kirkland authored and Al Viro committed Mar 20, 2006
1 parent 11accf1 commit a3902a0
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 73241ccca0f7786933f1d31b3d86f2456549953a
refs/heads/master: c8edc80c8b8c397c53f4f659a05b9ea6208029bf
5 changes: 4 additions & 1 deletion trunk/include/linux/audit.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@
#define AUDIT_FILTER_ENTRY 0x02 /* Apply rule at syscall entry */
#define AUDIT_FILTER_WATCH 0x03 /* Apply rule to file system watches */
#define AUDIT_FILTER_EXIT 0x04 /* Apply rule at syscall exit */
#define AUDIT_FILTER_TYPE 0x05 /* Apply rule at audit_log_start */

#define AUDIT_NR_FILTERS 5
#define AUDIT_NR_FILTERS 6

#define AUDIT_FILTER_PREPEND 0x10 /* Prepend to front of list */

Expand Down Expand Up @@ -132,6 +133,7 @@
#define AUDIT_LOGINUID 9
#define AUDIT_PERS 10
#define AUDIT_ARCH 11
#define AUDIT_MSGTYPE 12

/* These are ONLY useful when checking
* at syscall exit time (AUDIT_AT_EXIT). */
Expand Down Expand Up @@ -289,6 +291,7 @@ extern int audit_sockaddr(int len, void *addr);
extern int audit_avc_path(struct dentry *dentry, struct vfsmount *mnt);
extern void audit_signal_info(int sig, struct task_struct *t);
extern int audit_filter_user(struct netlink_skb_parms *cb, int type);
extern int audit_filter_type(int type);
#else
#define audit_alloc(t) ({ 0; })
#define audit_free(t) do { ; } while (0)
Expand Down
3 changes: 3 additions & 0 deletions trunk/kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,9 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask,
if (!audit_initialized)
return NULL;

if (unlikely(audit_filter_type(type)))
return NULL;

if (gfp_mask & __GFP_WAIT)
reserve = 0;
else
Expand Down
35 changes: 34 additions & 1 deletion trunk/kernel/auditsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ static struct list_head audit_filter_list[AUDIT_NR_FILTERS] = {
LIST_HEAD_INIT(audit_filter_list[2]),
LIST_HEAD_INIT(audit_filter_list[3]),
LIST_HEAD_INIT(audit_filter_list[4]),
#if AUDIT_NR_FILTERS != 5
LIST_HEAD_INIT(audit_filter_list[5]),
#if AUDIT_NR_FILTERS != 6
#error Fix audit_filter_list initialiser
#endif
};
Expand Down Expand Up @@ -663,6 +664,38 @@ int audit_filter_user(struct netlink_skb_parms *cb, int type)
return ret; /* Audit by default */
}

int audit_filter_type(int type)
{
struct audit_entry *e;
int result = 0;

rcu_read_lock();
if (list_empty(&audit_filter_list[AUDIT_FILTER_TYPE]))
goto unlock_and_return;

list_for_each_entry_rcu(e, &audit_filter_list[AUDIT_FILTER_TYPE],
list) {
struct audit_rule *rule = &e->rule;
int i;
for (i = 0; i < rule->field_count; i++) {
u32 field = rule->fields[i] & ~AUDIT_OPERATORS;
u32 op = rule->fields[i] & AUDIT_OPERATORS;
u32 value = rule->values[i];
if ( field == AUDIT_MSGTYPE ) {
result = audit_comparator(type, op, value);
if (!result)
break;
}
}
if (result)
goto unlock_and_return;
}
unlock_and_return:
rcu_read_unlock();
return result;
}


/* This should be called with task_lock() held. */
static inline struct audit_context *audit_get_context(struct task_struct *tsk,
int return_valid,
Expand Down

0 comments on commit a3902a0

Please sign in to comment.