Skip to content

Commit cfcad62

Browse files
eparisAl Viro
authored and
Al Viro
committed
audit: seperate audit inode watches into a subfile
In preparation for converting audit to use fsnotify instead of inotify we seperate the inode watching code into it's own file. This is similar to how the audit tree watching code is already seperated into audit_tree.c Signed-off-by: Eric Paris <eparis@redhat.com>
1 parent ea7ae60 commit cfcad62

File tree

6 files changed

+572
-506
lines changed

6 files changed

+572
-506
lines changed

kernel/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ obj-$(CONFIG_RESOURCE_COUNTERS) += res_counter.o
7070
obj-$(CONFIG_STOP_MACHINE) += stop_machine.o
7171
obj-$(CONFIG_KPROBES_SANITY_TEST) += test_kprobes.o
7272
obj-$(CONFIG_AUDIT) += audit.o auditfilter.o
73-
obj-$(CONFIG_AUDITSYSCALL) += auditsc.o
73+
obj-$(CONFIG_AUDITSYSCALL) += auditsc.o audit_watch.o
7474
obj-$(CONFIG_GCOV_KERNEL) += gcov/
7575
obj-$(CONFIG_AUDIT_TREE) += audit_tree.o
7676
obj-$(CONFIG_KPROBES) += kprobes.o

kernel/audit.c

-16
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,6 @@ static atomic_t audit_lost = ATOMIC_INIT(0);
115115
/* The netlink socket. */
116116
static struct sock *audit_sock;
117117

118-
/* Inotify handle. */
119-
struct inotify_handle *audit_ih;
120-
121118
/* Hash for inode-based rules */
122119
struct list_head audit_inode_hash[AUDIT_INODE_BUCKETS];
123120

@@ -971,13 +968,6 @@ static void audit_receive(struct sk_buff *skb)
971968
mutex_unlock(&audit_cmd_mutex);
972969
}
973970

974-
#ifdef CONFIG_AUDITSYSCALL
975-
static const struct inotify_operations audit_inotify_ops = {
976-
.handle_event = audit_handle_ievent,
977-
.destroy_watch = audit_free_parent,
978-
};
979-
#endif
980-
981971
/* Initialize audit support at boot time. */
982972
static int __init audit_init(void)
983973
{
@@ -1003,12 +993,6 @@ static int __init audit_init(void)
1003993

1004994
audit_log(NULL, GFP_KERNEL, AUDIT_KERNEL, "initialized");
1005995

1006-
#ifdef CONFIG_AUDITSYSCALL
1007-
audit_ih = inotify_init(&audit_inotify_ops);
1008-
if (IS_ERR(audit_ih))
1009-
audit_panic("cannot initialize inotify handle");
1010-
#endif
1011-
1012996
for (i = 0; i < AUDIT_INODE_BUCKETS; i++)
1013997
INIT_LIST_HEAD(&audit_inode_hash[i]);
1014998

kernel/audit.h

+20-19
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,7 @@ enum audit_state {
5353
};
5454

5555
/* Rule lists */
56-
struct audit_parent;
57-
58-
struct audit_watch {
59-
atomic_t count; /* reference count */
60-
char *path; /* insertion path */
61-
dev_t dev; /* associated superblock device */
62-
unsigned long ino; /* associated inode number */
63-
struct audit_parent *parent; /* associated parent */
64-
struct list_head wlist; /* entry in parent->watches list */
65-
struct list_head rules; /* associated rules */
66-
};
67-
56+
struct audit_watch;
6857
struct audit_tree;
6958
struct audit_chunk;
7059

@@ -108,19 +97,31 @@ struct audit_netlink_list {
10897

10998
int audit_send_list(void *);
11099

111-
struct inotify_watch;
112-
/* Inotify handle */
113-
extern struct inotify_handle *audit_ih;
114-
115-
extern void audit_free_parent(struct inotify_watch *);
116-
extern void audit_handle_ievent(struct inotify_watch *, u32, u32, u32,
117-
const char *, struct inode *);
118100
extern int selinux_audit_rule_update(void);
119101

120102
extern struct mutex audit_filter_mutex;
121103
extern void audit_free_rule_rcu(struct rcu_head *);
122104
extern struct list_head audit_filter_list[];
123105

106+
/* audit watch functions */
107+
extern unsigned long audit_watch_inode(struct audit_watch *watch);
108+
extern dev_t audit_watch_dev(struct audit_watch *watch);
109+
extern void audit_put_watch(struct audit_watch *watch);
110+
extern void audit_get_watch(struct audit_watch *watch);
111+
extern int audit_to_watch(struct audit_krule *krule, char *path, int len, u32 op);
112+
extern int audit_get_nd(char *path, struct nameidata **ndp, struct nameidata **ndw);
113+
extern void audit_put_nd(struct nameidata *ndp, struct nameidata *ndw);
114+
extern int audit_add_watch(struct audit_krule *krule, struct nameidata *ndp,
115+
struct nameidata *ndw);
116+
extern void audit_remove_watch(struct audit_watch *watch);
117+
extern void audit_remove_watch_rule(struct audit_krule *krule, struct list_head *list);
118+
extern void audit_inotify_unregister(struct list_head *in_list);
119+
extern char *audit_watch_path(struct audit_watch *watch);
120+
extern struct list_head *audit_watch_rules(struct audit_watch *watch);
121+
122+
extern struct audit_entry *audit_dupe_rule(struct audit_krule *old,
123+
struct audit_watch *watch);
124+
124125
#ifdef CONFIG_AUDIT_TREE
125126
extern struct audit_chunk *audit_tree_lookup(const struct inode *);
126127
extern void audit_put_chunk(struct audit_chunk *);

0 commit comments

Comments
 (0)