aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
authorPaul Moore <pmoore@redhat.com>2015-01-22 00:00:23 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-01-23 00:23:58 -0500
commit55422d0bd292f5ad143cc32cb8bb8505257274c4 (patch)
treefd1d6fae56c5e01d9d8fd6fb2fd913f5e24c7b56 /include/linux/fs.h
parent57c59f5837bdfd0b4fee3b02a44857e263a09bfa (diff)
audit: replace getname()/putname() hacks with reference counters
In order to ensure that filenames are not released before the audit subsystem is done with the strings there are a number of hacks built into the fs and audit subsystems around getname() and putname(). To say these hacks are "ugly" would be kind. This patch removes the filename hackery in favor of a more conventional reference count based approach. The diffstat below tells most of the story; lots of audit/fs specific code is replaced with a traditional reference count based approach that is easily understood, even by those not familiar with the audit and/or fs subsystems. CC: viro@zeniv.linux.org.uk CC: linux-fsdevel@vger.kernel.org Signed-off-by: Paul Moore <pmoore@redhat.com> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h9
1 files changed, 2 insertions, 7 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f90c0282c114..b49842fe203f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2080,6 +2080,7 @@ struct filename {
2080 const char *name; /* pointer to actual string */ 2080 const char *name; /* pointer to actual string */
2081 const __user char *uptr; /* original userland pointer */ 2081 const __user char *uptr; /* original userland pointer */
2082 struct audit_names *aname; 2082 struct audit_names *aname;
2083 int refcnt;
2083 bool separate; /* should "name" be freed? */ 2084 bool separate; /* should "name" be freed? */
2084}; 2085};
2085 2086
@@ -2101,6 +2102,7 @@ extern int filp_close(struct file *, fl_owner_t id);
2101extern struct filename *getname_flags(const char __user *, int, int *); 2102extern struct filename *getname_flags(const char __user *, int, int *);
2102extern struct filename *getname(const char __user *); 2103extern struct filename *getname(const char __user *);
2103extern struct filename *getname_kernel(const char *); 2104extern struct filename *getname_kernel(const char *);
2105extern void putname(struct filename *name);
2104 2106
2105enum { 2107enum {
2106 FILE_CREATED = 1, 2108 FILE_CREATED = 1,
@@ -2121,15 +2123,8 @@ extern void __init vfs_caches_init(unsigned long);
2121 2123
2122extern struct kmem_cache *names_cachep; 2124extern struct kmem_cache *names_cachep;
2123 2125
2124extern void final_putname(struct filename *name);
2125
2126#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) 2126#define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL)
2127#define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 2127#define __putname(name) kmem_cache_free(names_cachep, (void *)(name))
2128#ifndef CONFIG_AUDITSYSCALL
2129#define putname(name) final_putname(name)
2130#else
2131extern void putname(struct filename *name);
2132#endif
2133 2128
2134#ifdef CONFIG_BLOCK 2129#ifdef CONFIG_BLOCK
2135extern int register_blkdev(unsigned int, const char *); 2130extern int register_blkdev(unsigned int, const char *);