Skip to contentSkip to conversation

fix faulty inode data collection for open() with O_CREAT

PATCH New Amy Griffis 1 participant 1 message Jul 13, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix faulty inode data collection for open() with O_CREAT

When the specified path is an existing file or when it is a symlink, audit collects the wrong inode number, which causes it to miss the open() event. Adding a second hook to the open() path fixes this.

Also add audit_copy_inode() to consolidate some code.

---
 fs/namei.c            |    2 ++
 include/linux/audit.h |    7 +++++
 kernel/auditsc.c      |   63 ++++++++++++++++++++++++++++++++-----------------
 3 files changed, 50 insertions(+), 22 deletions(-)
fs/namei.c +2 -0
index 184fe4a..8904b4f 100644
@@ -1659,6 +1659,7 @@ do_last:
 	 * It already exists.
 	 */
 	mutex_unlock(&dir->d_inode->i_mutex);
+	audit_inode_update(path.dentry->d_inode);
 
 	error = -EEXIST;
 	if (flag & O_EXCL)
@@ -1669,6 +1670,7 @@ do_last:
 		if (flag & O_NOFOLLOW)
 			goto exit_dput;
 	}
+
 	error = -ENOENT;
 	if (!path.dentry->d_inode)
 		goto exit_dput;
include/linux/audit.h +7 -0
index 9fcafaf..c63f204 100644
@@ -328,6 +328,7 @@ extern void audit_putname(const char *na
 extern void __audit_inode(const char *name, const struct inode *inode);
 extern void __audit_inode_child(const char *dname, const struct inode *inode,
 				unsigned long pino);
+extern void __audit_inode_update(const struct inode *inode);
 static inline void audit_getname(const char *name)
 {
 	if (unlikely(current->audit_context))
@@ -343,6 +344,10 @@ static inline void audit_inode_child(con
 	if (unlikely(current->audit_context))
 		__audit_inode_child(dname, inode, pino);
 }
+static inline void audit_inode_update(const struct inode *inode) {
+	if (unlikely(current->audit_context))
+		__audit_inode_update(inode);
+}
 
 				/* Private API (for audit.c only) */
 extern unsigned int audit_serial(void);
@@ -414,8 +419,10 @@ #define audit_getname(n) do { ; } while 
 #define audit_putname(n) do { ; } while (0)
 #define __audit_inode(n,i) do { ; } while (0)
 #define __audit_inode_child(d,i,p) do { ; } while (0)
+#define __audit_inode_update(i) do { ; } while (0)
 #define audit_inode(n,i) do { ; } while (0)
 #define audit_inode_child(d,i,p) do { ; } while (0)
+#define audit_inode_update(i) do { ; } while (0)
 #define auditsc_get_stamp(c,t,s) do { BUG(); } while (0)
 #define audit_get_loginuid(c) ({ -1; })
 #define audit_ipc_obj(i) ({ 0; })
kernel/auditsc.c +41 -22

84 lines not on this page · raw message

Signature · 1 line
1.4.0