aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/debugfs/inode.c2
-rw-r--r--fs/namei.c8
-rw-r--r--fs/notify/inotify/inotify_user.c59
-rw-r--r--include/linux/audit.h11
-rw-r--r--include/linux/fsnotify.h11
-rw-r--r--include/linux/magic.h1
-rw-r--r--kernel/auditsc.c7
7 files changed, 23 insertions, 76 deletions
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index 274ac865bae8..049d6c36da09 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -496,7 +496,7 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,
496 } 496 }
497 d_move(old_dentry, dentry); 497 d_move(old_dentry, dentry);
498 fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name, 498 fsnotify_move(old_dir->d_inode, new_dir->d_inode, old_name,
499 old_dentry->d_name.name, S_ISDIR(old_dentry->d_inode->i_mode), 499 S_ISDIR(old_dentry->d_inode->i_mode),
500 NULL, old_dentry); 500 NULL, old_dentry);
501 fsnotify_oldname_free(old_name); 501 fsnotify_oldname_free(old_name);
502 unlock_rename(new_dir, old_dir); 502 unlock_rename(new_dir, old_dir);
diff --git a/fs/namei.c b/fs/namei.c
index 54d33df06be0..0741c69b3319 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1334,7 +1334,7 @@ static int may_delete(struct inode *dir,struct dentry *victim,int isdir)
1334 return -ENOENT; 1334 return -ENOENT;
1335 1335
1336 BUG_ON(victim->d_parent->d_inode != dir); 1336 BUG_ON(victim->d_parent->d_inode != dir);
1337 audit_inode_child(victim->d_name.name, victim, dir); 1337 audit_inode_child(victim, dir);
1338 1338
1339 error = inode_permission(dir, MAY_WRITE | MAY_EXEC); 1339 error = inode_permission(dir, MAY_WRITE | MAY_EXEC);
1340 if (error) 1340 if (error)
@@ -2663,11 +2663,9 @@ int vfs_rename(struct inode *old_dir, struct dentry *old_dentry,
2663 error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry); 2663 error = vfs_rename_dir(old_dir,old_dentry,new_dir,new_dentry);
2664 else 2664 else
2665 error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry); 2665 error = vfs_rename_other(old_dir,old_dentry,new_dir,new_dentry);
2666 if (!error) { 2666 if (!error)
2667 const char *new_name = old_dentry->d_name.name; 2667 fsnotify_move(old_dir, new_dir, old_name, is_dir,
2668 fsnotify_move(old_dir, new_dir, old_name, new_name, is_dir,
2669 new_dentry->d_inode, old_dentry); 2668 new_dentry->d_inode, old_dentry);
2670 }
2671 fsnotify_oldname_free(old_name); 2669 fsnotify_oldname_free(old_name);
2672 2670
2673 return error; 2671 return error;
diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c
index a94e8bd8eb1f..472cdf29ef82 100644
--- a/fs/notify/inotify/inotify_user.c
+++ b/fs/notify/inotify/inotify_user.c
@@ -29,14 +29,12 @@
29#include <linux/init.h> /* module_init */ 29#include <linux/init.h> /* module_init */
30#include <linux/inotify.h> 30#include <linux/inotify.h>
31#include <linux/kernel.h> /* roundup() */ 31#include <linux/kernel.h> /* roundup() */
32#include <linux/magic.h> /* superblock magic number */
33#include <linux/mount.h> /* mntget */
34#include <linux/namei.h> /* LOOKUP_FOLLOW */ 32#include <linux/namei.h> /* LOOKUP_FOLLOW */
35#include <linux/path.h> /* struct path */
36#include <linux/sched.h> /* struct user */ 33#include <linux/sched.h> /* struct user */
37#include <linux/slab.h> /* struct kmem_cache */ 34#include <linux/slab.h> /* struct kmem_cache */
38#include <linux/syscalls.h> 35#include <linux/syscalls.h>
39#include <linux/types.h> 36#include <linux/types.h>
37#include <linux/anon_inodes.h>
40#include <linux/uaccess.h> 38#include <linux/uaccess.h>
41#include <linux/poll.h> 39#include <linux/poll.h>
42#include <linux/wait.h> 40#include <linux/wait.h>
@@ -45,8 +43,6 @@
45 43
46#include <asm/ioctls.h> 44#include <asm/ioctls.h>
47 45
48static struct vfsmount *inotify_mnt __read_mostly;
49
50/* these are configurable via /proc/sys/fs/inotify/ */ 46/* these are configurable via /proc/sys/fs/inotify/ */
51static int inotify_max_user_instances __read_mostly; 47static int inotify_max_user_instances __read_mostly;
52static int inotify_max_queued_events __read_mostly; 48static int inotify_max_queued_events __read_mostly;
@@ -645,9 +641,7 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
645{ 641{
646 struct fsnotify_group *group; 642 struct fsnotify_group *group;
647 struct user_struct *user; 643 struct user_struct *user;
648 struct file *filp; 644 int ret;
649 struct path path;
650 int fd, ret;
651 645
652 /* Check the IN_* constants for consistency. */ 646 /* Check the IN_* constants for consistency. */
653 BUILD_BUG_ON(IN_CLOEXEC != O_CLOEXEC); 647 BUILD_BUG_ON(IN_CLOEXEC != O_CLOEXEC);
@@ -656,10 +650,6 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
656 if (flags & ~(IN_CLOEXEC | IN_NONBLOCK)) 650 if (flags & ~(IN_CLOEXEC | IN_NONBLOCK))
657 return -EINVAL; 651 return -EINVAL;
658 652
659 fd = get_unused_fd_flags(flags & O_CLOEXEC);
660 if (fd < 0)
661 return fd;
662
663 user = get_current_user(); 653 user = get_current_user();
664 if (unlikely(atomic_read(&user->inotify_devs) >= 654 if (unlikely(atomic_read(&user->inotify_devs) >=
665 inotify_max_user_instances)) { 655 inotify_max_user_instances)) {
@@ -676,27 +666,14 @@ SYSCALL_DEFINE1(inotify_init1, int, flags)
676 666
677 atomic_inc(&user->inotify_devs); 667 atomic_inc(&user->inotify_devs);
678 668
679 path.mnt = inotify_mnt; 669 ret = anon_inode_getfd("inotify", &inotify_fops, group,
680 path.dentry = inotify_mnt->mnt_root; 670 O_RDONLY | flags);
681 path_get(&path); 671 if (ret >= 0)
682 filp = alloc_file(&path, FMODE_READ, &inotify_fops); 672 return ret;
683 if (!filp)
684 goto Enfile;
685 673
686 filp->f_flags = O_RDONLY | (flags & O_NONBLOCK);
687 filp->private_data = group;
688
689 fd_install(fd, filp);
690
691 return fd;
692
693Enfile:
694 ret = -ENFILE;
695 path_put(&path);
696 atomic_dec(&user->inotify_devs); 674 atomic_dec(&user->inotify_devs);
697out_free_uid: 675out_free_uid:
698 free_uid(user); 676 free_uid(user);
699 put_unused_fd(fd);
700 return ret; 677 return ret;
701} 678}
702 679
@@ -783,20 +760,6 @@ out:
783 return ret; 760 return ret;
784} 761}
785 762
786static int
787inotify_get_sb(struct file_system_type *fs_type, int flags,
788 const char *dev_name, void *data, struct vfsmount *mnt)
789{
790 return get_sb_pseudo(fs_type, "inotify", NULL,
791 INOTIFYFS_SUPER_MAGIC, mnt);
792}
793
794static struct file_system_type inotify_fs_type = {
795 .name = "inotifyfs",
796 .get_sb = inotify_get_sb,
797 .kill_sb = kill_anon_super,
798};
799
800/* 763/*
801 * inotify_user_setup - Our initialization function. Note that we cannnot return 764 * inotify_user_setup - Our initialization function. Note that we cannnot return
802 * error because we have compiled-in VFS hooks. So an (unlikely) failure here 765 * error because we have compiled-in VFS hooks. So an (unlikely) failure here
@@ -804,16 +767,6 @@ static struct file_system_type inotify_fs_type = {
804 */ 767 */
805static int __init inotify_user_setup(void) 768static int __init inotify_user_setup(void)
806{ 769{
807 int ret;
808
809 ret = register_filesystem(&inotify_fs_type);
810 if (unlikely(ret))
811 panic("inotify: register_filesystem returned %d!\n", ret);
812
813 inotify_mnt = kern_mount(&inotify_fs_type);
814 if (IS_ERR(inotify_mnt))
815 panic("inotify: kern_mount ret %ld!\n", PTR_ERR(inotify_mnt));
816
817 inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark_entry, SLAB_PANIC); 770 inotify_inode_mark_cachep = KMEM_CACHE(inotify_inode_mark_entry, SLAB_PANIC);
818 event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC); 771 event_priv_cachep = KMEM_CACHE(inotify_event_private_data, SLAB_PANIC);
819 772
diff --git a/include/linux/audit.h b/include/linux/audit.h
index 3c7a358241a7..f391d45c8aea 100644
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -424,7 +424,7 @@ extern void audit_syscall_exit(int failed, long return_code);
424extern void __audit_getname(const char *name); 424extern void __audit_getname(const char *name);
425extern void audit_putname(const char *name); 425extern void audit_putname(const char *name);
426extern void __audit_inode(const char *name, const struct dentry *dentry); 426extern void __audit_inode(const char *name, const struct dentry *dentry);
427extern void __audit_inode_child(const char *dname, const struct dentry *dentry, 427extern void __audit_inode_child(const struct dentry *dentry,
428 const struct inode *parent); 428 const struct inode *parent);
429extern void __audit_ptrace(struct task_struct *t); 429extern void __audit_ptrace(struct task_struct *t);
430 430
@@ -442,11 +442,10 @@ static inline void audit_inode(const char *name, const struct dentry *dentry) {
442 if (unlikely(!audit_dummy_context())) 442 if (unlikely(!audit_dummy_context()))
443 __audit_inode(name, dentry); 443 __audit_inode(name, dentry);
444} 444}
445static inline void audit_inode_child(const char *dname, 445static inline void audit_inode_child(const struct dentry *dentry,
446 const struct dentry *dentry,
447 const struct inode *parent) { 446 const struct inode *parent) {
448 if (unlikely(!audit_dummy_context())) 447 if (unlikely(!audit_dummy_context()))
449 __audit_inode_child(dname, dentry, parent); 448 __audit_inode_child(dentry, parent);
450} 449}
451void audit_core_dumps(long signr); 450void audit_core_dumps(long signr);
452 451
@@ -544,9 +543,9 @@ extern int audit_signals;
544#define audit_getname(n) do { ; } while (0) 543#define audit_getname(n) do { ; } while (0)
545#define audit_putname(n) do { ; } while (0) 544#define audit_putname(n) do { ; } while (0)
546#define __audit_inode(n,d) do { ; } while (0) 545#define __audit_inode(n,d) do { ; } while (0)
547#define __audit_inode_child(d,i,p) do { ; } while (0) 546#define __audit_inode_child(i,p) do { ; } while (0)
548#define audit_inode(n,d) do { ; } while (0) 547#define audit_inode(n,d) do { ; } while (0)
549#define audit_inode_child(d,i,p) do { ; } while (0) 548#define audit_inode_child(i,p) do { ; } while (0)
550#define audit_core_dumps(i) do { ; } while (0) 549#define audit_core_dumps(i) do { ; } while (0)
551#define auditsc_get_stamp(c,t,s) (0) 550#define auditsc_get_stamp(c,t,s) (0)
552#define audit_get_loginuid(t) (-1) 551#define audit_get_loginuid(t) (-1)
diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
index 936f9aa8bb97..df8fd9a3b214 100644
--- a/include/linux/fsnotify.h
+++ b/include/linux/fsnotify.h
@@ -65,7 +65,7 @@ static inline void fsnotify_link_count(struct inode *inode)
65 * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir 65 * fsnotify_move - file old_name at old_dir was moved to new_name at new_dir
66 */ 66 */
67static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir, 67static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
68 const char *old_name, const char *new_name, 68 const char *old_name,
69 int isdir, struct inode *target, struct dentry *moved) 69 int isdir, struct inode *target, struct dentry *moved)
70{ 70{
71 struct inode *source = moved->d_inode; 71 struct inode *source = moved->d_inode;
@@ -73,6 +73,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
73 u32 fs_cookie = fsnotify_get_cookie(); 73 u32 fs_cookie = fsnotify_get_cookie();
74 __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM); 74 __u32 old_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_FROM);
75 __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO); 75 __u32 new_dir_mask = (FS_EVENT_ON_CHILD | FS_MOVED_TO);
76 const char *new_name = moved->d_name.name;
76 77
77 if (old_dir == new_dir) 78 if (old_dir == new_dir)
78 old_dir_mask |= FS_DN_RENAME; 79 old_dir_mask |= FS_DN_RENAME;
@@ -103,7 +104,7 @@ static inline void fsnotify_move(struct inode *old_dir, struct inode *new_dir,
103 inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL); 104 inotify_inode_queue_event(source, IN_MOVE_SELF, 0, NULL, NULL);
104 fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0); 105 fsnotify(source, FS_MOVE_SELF, moved->d_inode, FSNOTIFY_EVENT_INODE, NULL, 0);
105 } 106 }
106 audit_inode_child(new_name, moved, new_dir); 107 audit_inode_child(moved, new_dir);
107} 108}
108 109
109/* 110/*
@@ -146,7 +147,7 @@ static inline void fsnotify_create(struct inode *inode, struct dentry *dentry)
146{ 147{
147 inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name, 148 inotify_inode_queue_event(inode, IN_CREATE, 0, dentry->d_name.name,
148 dentry->d_inode); 149 dentry->d_inode);
149 audit_inode_child(dentry->d_name.name, dentry, inode); 150 audit_inode_child(dentry, inode);
150 151
151 fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); 152 fsnotify(inode, FS_CREATE, dentry->d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0);
152} 153}
@@ -161,7 +162,7 @@ static inline void fsnotify_link(struct inode *dir, struct inode *inode, struct
161 inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name, 162 inotify_inode_queue_event(dir, IN_CREATE, 0, new_dentry->d_name.name,
162 inode); 163 inode);
163 fsnotify_link_count(inode); 164 fsnotify_link_count(inode);
164 audit_inode_child(new_dentry->d_name.name, new_dentry, dir); 165 audit_inode_child(new_dentry, dir);
165 166
166 fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0); 167 fsnotify(dir, FS_CREATE, inode, FSNOTIFY_EVENT_INODE, new_dentry->d_name.name, 0);
167} 168}
@@ -175,7 +176,7 @@ static inline void fsnotify_mkdir(struct inode *inode, struct dentry *dentry)
175 struct inode *d_inode = dentry->d_inode; 176 struct inode *d_inode = dentry->d_inode;
176 177
177 inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode); 178 inotify_inode_queue_event(inode, mask, 0, dentry->d_name.name, d_inode);
178 audit_inode_child(dentry->d_name.name, dentry, inode); 179 audit_inode_child(dentry, inode);
179 180
180 fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0); 181 fsnotify(inode, mask, d_inode, FSNOTIFY_EVENT_INODE, dentry->d_name.name, 0);
181} 182}
diff --git a/include/linux/magic.h b/include/linux/magic.h
index 76285e01b39e..eb9800f05782 100644
--- a/include/linux/magic.h
+++ b/include/linux/magic.h
@@ -52,7 +52,6 @@
52#define CGROUP_SUPER_MAGIC 0x27e0eb 52#define CGROUP_SUPER_MAGIC 0x27e0eb
53 53
54#define FUTEXFS_SUPER_MAGIC 0xBAD1DEA 54#define FUTEXFS_SUPER_MAGIC 0xBAD1DEA
55#define INOTIFYFS_SUPER_MAGIC 0x2BAD1DEA
56 55
57#define STACK_END_MAGIC 0x57AC6E9D 56#define STACK_END_MAGIC 0x57AC6E9D
58 57
diff --git a/kernel/auditsc.c b/kernel/auditsc.c
index fc0f928167e7..f3a461c0970a 100644
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1988,7 +1988,6 @@ void __audit_inode(const char *name, const struct dentry *dentry)
1988 1988
1989/** 1989/**
1990 * audit_inode_child - collect inode info for created/removed objects 1990 * audit_inode_child - collect inode info for created/removed objects
1991 * @dname: inode's dentry name
1992 * @dentry: dentry being audited 1991 * @dentry: dentry being audited
1993 * @parent: inode of dentry parent 1992 * @parent: inode of dentry parent
1994 * 1993 *
@@ -2000,13 +1999,14 @@ void __audit_inode(const char *name, const struct dentry *dentry)
2000 * must be hooked prior, in order to capture the target inode during 1999 * must be hooked prior, in order to capture the target inode during
2001 * unsuccessful attempts. 2000 * unsuccessful attempts.
2002 */ 2001 */
2003void __audit_inode_child(const char *dname, const struct dentry *dentry, 2002void __audit_inode_child(const struct dentry *dentry,
2004 const struct inode *parent) 2003 const struct inode *parent)
2005{ 2004{
2006 int idx; 2005 int idx;
2007 struct audit_context *context = current->audit_context; 2006 struct audit_context *context = current->audit_context;
2008 const char *found_parent = NULL, *found_child = NULL; 2007 const char *found_parent = NULL, *found_child = NULL;
2009 const struct inode *inode = dentry->d_inode; 2008 const struct inode *inode = dentry->d_inode;
2009 const char *dname = dentry->d_name.name;
2010 int dirlen = 0; 2010 int dirlen = 0;
2011 2011
2012 if (!context->in_syscall) 2012 if (!context->in_syscall)
@@ -2014,9 +2014,6 @@ void __audit_inode_child(const char *dname, const struct dentry *dentry,
2014 2014
2015 if (inode) 2015 if (inode)
2016 handle_one(inode); 2016 handle_one(inode);
2017 /* determine matching parent */
2018 if (!dname)
2019 goto add_names;
2020 2017
2021 /* parent is more likely, look for it first */ 2018 /* parent is more likely, look for it first */
2022 for (idx = 0; idx < context->name_count; idx++) { 2019 for (idx = 0; idx < context->name_count; idx++) {