Skip to contentSkip to conversation

detangle audit.h from fs.h

PATCH New Chris Wright 1 participant 1 message Feb 25, 2005

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

PATCH 1/1 detangle audit.h from fs.h

Currently touching audit.h triggers a large rebuild because it's sucked in via fs.h. It's there because of the getname()/putname() requirements that come with CONFIG_AUDITSYSCALL. Remove header dependency by pushing relevant putname() implementation into fs/namei.c. It adds function call overhead for putname() callers when CONFIG_AUDITSYSCALL is set, quite minor cost for detangled source. Any objections?

===== include/linux/fs.h 1.378 vs edited =====

include/linux/fs.h +1 -8
@@ -210,7 +210,6 @@ extern int dir_notify_enable;
 #include <linux/list.h>
 #include <linux/radix-tree.h>
 #include <linux/prio_tree.h>
-#include <linux/audit.h>
 #include <linux/init.h>
 
 #include <asm/atomic.h>
@@ -1268,13 +1267,7 @@ extern void __init vfs_caches_init(unsig
 #ifndef CONFIG_AUDITSYSCALL
 #define putname(name)   __putname(name)
 #else
-#define putname(name)							\
-	do {								\
-		if (unlikely(current->audit_context))			\
-			audit_putname(name);				\
-		else							\
-			__putname(name);				\
-	} while (0)
+extern void putname(const char *name);
 #endif
 
 extern int register_blkdev(unsigned int, const char *);

===== fs/namei.c 1.118 vs edited =====

fs/namei.c +13 -2
@@ -148,10 +148,21 @@ char * getname(const char __user * filen
 			result = ERR_PTR(retval);
 		}
 	}
-	if (unlikely(current->audit_context) && !IS_ERR(result) && result)
-		audit_getname(result);
+	audit_getname(result);
 	return result;
 }
+
+#ifdef CONFIG_AUDITSYSCALL
+void putname(const char *name)
+{
+	if (unlikely(current->audit_context))
+		audit_putname(name);
+	else
+		__putname(name);
+}
+EXPORT_SYMBOL(putname);
+#endif
+
 
 /**
  * generic_permission  -  check for access rights on a Posix-like filesystem

===== kernel/auditsc.c 1.6 vs edited =====

kernel/auditsc.c +3 -2
@@ -800,7 +800,9 @@ void audit_getname(const char *name)
 {
 	struct audit_context *context = current->audit_context;
 
-	BUG_ON(!context);
+	if (!context || IS_ERR(name) || !name)
+		return;
+
 	if (!context->in_syscall) {
 #if AUDIT_DEBUG == 2
 		printk(KERN_ERR "%s:%d(:%d): ignoring getname(%p)\n",
@@ -855,7 +857,6 @@ void audit_putname(const char *name)
 	}
 #endif
 }
-EXPORT_SYMBOL(audit_putname);
 
 /* Store the inode and device from a lookup.  Called from
  * fs/namei.c:path_lookup(). */

===== fs/proc/base.c 1.88 vs edited =====

fs/proc/base.c +1 -0
@@ -32,6 +32,7 @@
 #include <linux/mount.h>
 #include <linux/security.h>
 #include <linux/ptrace.h>
+#include <linux/audit.h>
 #include "internal.h"
 
 /*