Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (34 commits)
nfsd race fixes: jfs
nfsd race fixes: reiserfs
nfsd race fixes: ext4
nfsd race fixes: ext3
nfsd race fixes: ext2
nfsd/create race fixes, infrastructure
filesystem notification: create fs/notify to contain all fs notification
fs/block_dev.c: __read_mostly improvement and sb_is_blkdev_sb utilization
kill ->dir_notify()
filp_cachep can be static in fs/file_table.c
fix f_count description in Documentation/filesystems/files.txt
make INIT_FS use the __RW_LOCK_UNLOCKED initialization
take init_fs to saner place
kill vfs_permission
pass a struct path * to may_open
kill walk_init_root
remove incorrect comment in inode_permission
expand some comments (d_path / seq_path)
correct wrong function name of d_put in kernel document and source comment
fix switch_names() breakage in short-to-short case
...

+696 -351
-2
Documentation/filesystems/Locking
··· 394 unsigned long (*get_unmapped_area)(struct file *, unsigned long, 395 unsigned long, unsigned long, unsigned long); 396 int (*check_flags)(int); 397 - int (*dir_notify)(struct file *, unsigned long); 398 }; 399 400 locking rules: ··· 423 sendpage: no 424 get_unmapped_area: no 425 check_flags: no 426 - dir_notify: no 427 428 ->llseek() locking has moved from llseek to the individual llseek 429 implementations. If your fs is not using generic_file_llseek, you
··· 394 unsigned long (*get_unmapped_area)(struct file *, unsigned long, 395 unsigned long, unsigned long, unsigned long); 396 int (*check_flags)(int); 397 }; 398 399 locking rules: ··· 424 sendpage: no 425 get_unmapped_area: no 426 check_flags: no 427 428 ->llseek() locking has moved from llseek to the individual llseek 429 implementations. If your fs is not using generic_file_llseek, you
+3 -3
Documentation/filesystems/files.txt
··· 76 5. Handling of the file structures is special. Since the look-up 77 of the fd (fget()/fget_light()) are lock-free, it is possible 78 that look-up may race with the last put() operation on the 79 - file structure. This is avoided using atomic_inc_not_zero() 80 on ->f_count : 81 82 rcu_read_lock(); 83 file = fcheck_files(files, fd); 84 if (file) { 85 - if (atomic_inc_not_zero(&file->f_count)) 86 *fput_needed = 1; 87 else 88 /* Didn't get the reference, someone's freed */ ··· 92 .... 93 return file; 94 95 - atomic_inc_not_zero() detects if refcounts is already zero or 96 goes to zero during increment. If it does, we fail 97 fget()/fget_light(). 98
··· 76 5. Handling of the file structures is special. Since the look-up 77 of the fd (fget()/fget_light()) are lock-free, it is possible 78 that look-up may race with the last put() operation on the 79 + file structure. This is avoided using atomic_long_inc_not_zero() 80 on ->f_count : 81 82 rcu_read_lock(); 83 file = fcheck_files(files, fd); 84 if (file) { 85 + if (atomic_long_inc_not_zero(&file->f_count)) 86 *fput_needed = 1; 87 else 88 /* Didn't get the reference, someone's freed */ ··· 92 .... 93 return file; 94 95 + atomic_long_inc_not_zero() detects if refcounts is already zero or 96 goes to zero during increment. If it does, we fail 97 fget()/fget_light(). 98
+1 -4
Documentation/filesystems/vfs.txt
··· 733 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 734 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 735 int (*check_flags)(int); 736 - int (*dir_notify)(struct file *filp, unsigned long arg); 737 int (*flock) (struct file *, int, struct file_lock *); 738 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int); 739 ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int); ··· 798 get_unmapped_area: called by the mmap(2) system call 799 800 check_flags: called by the fcntl(2) system call for F_SETFL command 801 - 802 - dir_notify: called by the fcntl(2) system call for F_NOTIFY command 803 804 flock: called by the flock(2) system call 805 ··· 928 d_lookup: look up a dentry given its parent and path name component 929 It looks up the child of that given name from the dcache 930 hash table. If it is found, the reference count is incremented 931 - and the dentry is returned. The caller must use d_put() 932 to free the dentry when it finishes using it. 933 934 For further information on dentry locking, please refer to the document
··· 733 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 734 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 735 int (*check_flags)(int); 736 int (*flock) (struct file *, int, struct file_lock *); 737 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, size_t, unsigned int); 738 ssize_t (*splice_read)(struct file *, struct pipe_inode_info *, size_t, unsigned int); ··· 799 get_unmapped_area: called by the mmap(2) system call 800 801 check_flags: called by the fcntl(2) system call for F_SETFL command 802 803 flock: called by the flock(2) system call 804 ··· 931 d_lookup: look up a dentry given its parent and path name component 932 It looks up the child of that given name from the dcache 933 hash table. If it is found, the reference count is incremented 934 + and the dentry is returned. The caller must use dput() 935 to free the dentry when it finishes using it. 936 937 For further information on dentry locking, please refer to the document
-1
arch/alpha/kernel/init_task.c
··· 8 #include <asm/uaccess.h> 9 10 11 - static struct fs_struct init_fs = INIT_FS; 12 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 13 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 14 struct mm_struct init_mm = INIT_MM(init_mm);
··· 8 #include <asm/uaccess.h> 9 10 11 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 12 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 13 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/arm/kernel/init_task.c
··· 12 13 #include <asm/pgtable.h> 14 15 - static struct fs_struct init_fs = INIT_FS; 16 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 17 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 18 struct mm_struct init_mm = INIT_MM(init_mm);
··· 12 13 #include <asm/pgtable.h> 14 15 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 16 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 17 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/avr32/kernel/init_task.c
··· 13 14 #include <asm/pgtable.h> 15 16 - static struct fs_struct init_fs = INIT_FS; 17 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 18 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 19 struct mm_struct init_mm = INIT_MM(init_mm);
··· 13 14 #include <asm/pgtable.h> 15 16 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 17 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 18 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/blackfin/kernel/init_task.c
··· 33 #include <linux/mqueue.h> 34 #include <linux/fs.h> 35 36 - static struct fs_struct init_fs = INIT_FS; 37 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 38 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 39
··· 33 #include <linux/mqueue.h> 34 #include <linux/fs.h> 35 36 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 37 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 38
-1
arch/cris/kernel/process.c
··· 37 * setup. 38 */ 39 40 - static struct fs_struct init_fs = INIT_FS; 41 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 42 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 43 struct mm_struct init_mm = INIT_MM(init_mm);
··· 37 * setup. 38 */ 39 40 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 41 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 42 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/frv/kernel/init_task.c
··· 10 #include <asm/pgtable.h> 11 12 13 - static struct fs_struct init_fs = INIT_FS; 14 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 15 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 16 struct mm_struct init_mm = INIT_MM(init_mm);
··· 10 #include <asm/pgtable.h> 11 12 13 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 14 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 15 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/h8300/kernel/init_task.c
··· 12 #include <asm/uaccess.h> 13 #include <asm/pgtable.h> 14 15 - static struct fs_struct init_fs = INIT_FS; 16 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 17 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 18 struct mm_struct init_mm = INIT_MM(init_mm);
··· 12 #include <asm/uaccess.h> 13 #include <asm/pgtable.h> 14 15 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 16 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 17 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/ia64/kernel/init_task.c
··· 17 #include <asm/uaccess.h> 18 #include <asm/pgtable.h> 19 20 - static struct fs_struct init_fs = INIT_FS; 21 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 22 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 23 struct mm_struct init_mm = INIT_MM(init_mm);
··· 17 #include <asm/uaccess.h> 18 #include <asm/pgtable.h> 19 20 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 21 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 22 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/m32r/kernel/init_task.c
··· 11 #include <asm/uaccess.h> 12 #include <asm/pgtable.h> 13 14 - static struct fs_struct init_fs = INIT_FS; 15 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 16 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 17 struct mm_struct init_mm = INIT_MM(init_mm);
··· 11 #include <asm/uaccess.h> 12 #include <asm/pgtable.h> 13 14 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 15 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 16 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/m68k/kernel/process.c
··· 40 * alignment requirements and potentially different initial 41 * setup. 42 */ 43 - static struct fs_struct init_fs = INIT_FS; 44 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 45 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 46 struct mm_struct init_mm = INIT_MM(init_mm);
··· 40 * alignment requirements and potentially different initial 41 * setup. 42 */ 43 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 44 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 45 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/m68knommu/kernel/init_task.c
··· 12 #include <asm/uaccess.h> 13 #include <asm/pgtable.h> 14 15 - static struct fs_struct init_fs = INIT_FS; 16 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 17 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 18 struct mm_struct init_mm = INIT_MM(init_mm);
··· 12 #include <asm/uaccess.h> 13 #include <asm/pgtable.h> 14 15 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 16 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 17 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/mips/kernel/init_task.c
··· 9 #include <asm/uaccess.h> 10 #include <asm/pgtable.h> 11 12 - static struct fs_struct init_fs = INIT_FS; 13 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 14 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 15 struct mm_struct init_mm = INIT_MM(init_mm);
··· 9 #include <asm/uaccess.h> 10 #include <asm/pgtable.h> 11 12 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 13 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 14 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/mn10300/kernel/init_task.c
··· 18 #include <asm/uaccess.h> 19 #include <asm/pgtable.h> 20 21 - static struct fs_struct init_fs = INIT_FS; 22 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 23 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 24 struct mm_struct init_mm = INIT_MM(init_mm);
··· 18 #include <asm/uaccess.h> 19 #include <asm/pgtable.h> 20 21 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 22 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 23 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/parisc/kernel/init_task.c
··· 34 #include <asm/pgtable.h> 35 #include <asm/pgalloc.h> 36 37 - static struct fs_struct init_fs = INIT_FS; 38 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 39 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 40 struct mm_struct init_mm = INIT_MM(init_mm);
··· 34 #include <asm/pgtable.h> 35 #include <asm/pgalloc.h> 36 37 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 38 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 39 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/powerpc/kernel/init_task.c
··· 7 #include <linux/mqueue.h> 8 #include <asm/uaccess.h> 9 10 - static struct fs_struct init_fs = INIT_FS; 11 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 12 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 13 struct mm_struct init_mm = INIT_MM(init_mm);
··· 7 #include <linux/mqueue.h> 8 #include <asm/uaccess.h> 9 10 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 11 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 12 struct mm_struct init_mm = INIT_MM(init_mm);
+1 -1
arch/powerpc/oprofile/cell/spu_task_sync.c
··· 297 { 298 unsigned long cookie; 299 300 - if (path->dentry->d_cookie) 301 return (unsigned long)path->dentry; 302 get_dcookie(path, &cookie); 303 return cookie;
··· 297 { 298 unsigned long cookie; 299 300 + if (path->dentry->d_flags & DCACHE_COOKIE) 301 return (unsigned long)path->dentry; 302 get_dcookie(path, &cookie); 303 return cookie;
-1
arch/s390/kernel/init_task.c
··· 16 #include <asm/uaccess.h> 17 #include <asm/pgtable.h> 18 19 - static struct fs_struct init_fs = INIT_FS; 20 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 21 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 22 struct mm_struct init_mm = INIT_MM(init_mm);
··· 16 #include <asm/uaccess.h> 17 #include <asm/pgtable.h> 18 19 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 20 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 21 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/sh/kernel/init_task.c
··· 7 #include <asm/uaccess.h> 8 #include <asm/pgtable.h> 9 10 - static struct fs_struct init_fs = INIT_FS; 11 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 12 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 13 struct pt_regs fake_swapper_regs;
··· 7 #include <asm/uaccess.h> 8 #include <asm/pgtable.h> 9 10 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 11 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 12 struct pt_regs fake_swapper_regs;
-1
arch/sparc/kernel/init_task.c
··· 8 #include <asm/pgtable.h> 9 #include <asm/uaccess.h> 10 11 - static struct fs_struct init_fs = INIT_FS; 12 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 13 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 14 struct mm_struct init_mm = INIT_MM(init_mm);
··· 8 #include <asm/pgtable.h> 9 #include <asm/uaccess.h> 10 11 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 12 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 13 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/um/kernel/init_task.c
··· 10 #include "linux/mqueue.h" 11 #include "asm/uaccess.h" 12 13 - static struct fs_struct init_fs = INIT_FS; 14 struct mm_struct init_mm = INIT_MM(init_mm); 15 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 16 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
··· 10 #include "linux/mqueue.h" 11 #include "asm/uaccess.h" 12 13 struct mm_struct init_mm = INIT_MM(init_mm); 14 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 15 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
-1
arch/x86/kernel/init_task.c
··· 10 #include <asm/pgtable.h> 11 #include <asm/desc.h> 12 13 - static struct fs_struct init_fs = INIT_FS; 14 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 15 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 16 struct mm_struct init_mm = INIT_MM(init_mm);
··· 10 #include <asm/pgtable.h> 11 #include <asm/desc.h> 12 13 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 14 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 15 struct mm_struct init_mm = INIT_MM(init_mm);
-1
arch/xtensa/kernel/init_task.c
··· 21 22 #include <asm/uaccess.h> 23 24 - static struct fs_struct init_fs = INIT_FS; 25 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 26 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 27 struct mm_struct init_mm = INIT_MM(init_mm);
··· 21 22 #include <asm/uaccess.h> 23 24 static struct signal_struct init_signals = INIT_SIGNALS(init_signals); 25 static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand); 26 struct mm_struct init_mm = INIT_MM(init_mm);
+1 -1
drivers/oprofile/buffer_sync.c
··· 200 { 201 unsigned long cookie; 202 203 - if (path->dentry->d_cookie) 204 return (unsigned long)path->dentry; 205 get_dcookie(path, &cookie); 206 return cookie;
··· 200 { 201 unsigned long cookie; 202 203 + if (path->dentry->d_flags & DCACHE_COOKIE) 204 return (unsigned long)path->dentry; 205 get_dcookie(path, &cookie); 206 return cookie;
+1 -38
fs/Kconfig
··· 270 271 endif # BLOCK 272 273 - config DNOTIFY 274 - bool "Dnotify support" 275 - default y 276 - help 277 - Dnotify is a directory-based per-fd file change notification system 278 - that uses signals to communicate events to user-space. There exist 279 - superior alternatives, but some applications may still rely on 280 - dnotify. 281 - 282 - If unsure, say Y. 283 - 284 - config INOTIFY 285 - bool "Inotify file change notification support" 286 - default y 287 - ---help--- 288 - Say Y here to enable inotify support. Inotify is a file change 289 - notification system and a replacement for dnotify. Inotify fixes 290 - numerous shortcomings in dnotify and introduces several new features 291 - including multiple file events, one-shot support, and unmount 292 - notification. 293 - 294 - For more information, see <file:Documentation/filesystems/inotify.txt> 295 - 296 - If unsure, say Y. 297 - 298 - config INOTIFY_USER 299 - bool "Inotify support for userspace" 300 - depends on INOTIFY 301 - default y 302 - ---help--- 303 - Say Y here to enable inotify support for userspace, including the 304 - associated system calls. Inotify allows monitoring of both files and 305 - directories via a single open fd. Events are read from the file 306 - descriptor, which is also select()- and poll()-able. 307 - 308 - For more information, see <file:Documentation/filesystems/inotify.txt> 309 - 310 - If unsure, say Y. 311 312 config QUOTA 313 bool "Quota support"
··· 270 271 endif # BLOCK 272 273 + source "fs/notify/Kconfig" 274 275 config QUOTA 276 bool "Quota support"
+1 -4
fs/Makefile
··· 20 endif 21 22 obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o 23 - obj-$(CONFIG_INOTIFY) += inotify.o 24 - obj-$(CONFIG_INOTIFY_USER) += inotify_user.o 25 obj-$(CONFIG_EPOLL) += eventpoll.o 26 obj-$(CONFIG_ANON_INODES) += anon_inodes.o 27 obj-$(CONFIG_SIGNALFD) += signalfd.o ··· 55 obj-$(CONFIG_QFMT_V1) += quota_v1.o 56 obj-$(CONFIG_QFMT_V2) += quota_v2.o 57 obj-$(CONFIG_QUOTACTL) += quota.o 58 - 59 - obj-$(CONFIG_DNOTIFY) += dnotify.o 60 61 obj-$(CONFIG_PROC_FS) += proc/ 62 obj-y += partitions/
··· 20 endif 21 22 obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o 23 + obj-y += notify/ 24 obj-$(CONFIG_EPOLL) += eventpoll.o 25 obj-$(CONFIG_ANON_INODES) += anon_inodes.o 26 obj-$(CONFIG_SIGNALFD) += signalfd.o ··· 56 obj-$(CONFIG_QFMT_V1) += quota_v1.o 57 obj-$(CONFIG_QFMT_V2) += quota_v2.o 58 obj-$(CONFIG_QUOTACTL) += quota.o 59 60 obj-$(CONFIG_PROC_FS) += proc/ 61 obj-y += partitions/
-6
fs/bad_inode.c
··· 132 return -EIO; 133 } 134 135 - static int bad_file_dir_notify(struct file *file, unsigned long arg) 136 - { 137 - return -EIO; 138 - } 139 - 140 static int bad_file_flock(struct file *filp, int cmd, struct file_lock *fl) 141 { 142 return -EIO; ··· 174 .sendpage = bad_file_sendpage, 175 .get_unmapped_area = bad_file_get_unmapped_area, 176 .check_flags = bad_file_check_flags, 177 - .dir_notify = bad_file_dir_notify, 178 .flock = bad_file_flock, 179 .splice_write = bad_file_splice_write, 180 .splice_read = bad_file_splice_read,
··· 132 return -EIO; 133 } 134 135 static int bad_file_flock(struct file *filp, int cmd, struct file_lock *fl) 136 { 137 return -EIO; ··· 179 .sendpage = bad_file_sendpage, 180 .get_unmapped_area = bad_file_get_unmapped_area, 181 .check_flags = bad_file_check_flags, 182 .flock = bad_file_flock, 183 .splice_write = bad_file_splice_write, 184 .splice_read = bad_file_splice_read,
+4 -1
fs/befs/linuxvfs.c
··· 378 inode->i_size = 0; 379 inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE; 380 strncpy(befs_ino->i_data.symlink, raw_inode->data.symlink, 381 - BEFS_SYMLINK_LEN); 382 } else { 383 int num_blks; 384 ··· 478 kfree(link); 479 befs_error(sb, "Failed to read entire long symlink"); 480 link = ERR_PTR(-EIO); 481 } 482 } else { 483 link = befs_ino->i_data.symlink;
··· 378 inode->i_size = 0; 379 inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE; 380 strncpy(befs_ino->i_data.symlink, raw_inode->data.symlink, 381 + BEFS_SYMLINK_LEN - 1); 382 + befs_ino->i_data.symlink[BEFS_SYMLINK_LEN - 1] = '\0'; 383 } else { 384 int num_blks; 385 ··· 477 kfree(link); 478 befs_error(sb, "Failed to read entire long symlink"); 479 link = ERR_PTR(-EIO); 480 + } else { 481 + link[len - 1] = '\0'; 482 } 483 } else { 484 link = befs_ino->i_data.symlink;
+5 -4
fs/block_dev.c
··· 326 .kill_sb = kill_anon_super, 327 }; 328 329 - static struct vfsmount *bd_mnt __read_mostly; 330 - struct super_block *blockdev_superblock; 331 332 void __init bdev_cache_init(void) 333 { 334 int err; 335 bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode), 336 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| 337 SLAB_MEM_SPREAD|SLAB_PANIC), ··· 374 struct block_device *bdev; 375 struct inode *inode; 376 377 - inode = iget5_locked(bd_mnt->mnt_sb, hash(dev), 378 bdev_test, bdev_set, &dev); 379 380 if (!inode) ··· 464 465 spin_lock(&bdev_lock); 466 if (inode->i_bdev) { 467 - if (inode->i_sb != blockdev_superblock) 468 bdev = inode->i_bdev; 469 __bd_forget(inode); 470 }
··· 326 .kill_sb = kill_anon_super, 327 }; 328 329 + struct super_block *blockdev_superblock __read_mostly; 330 331 void __init bdev_cache_init(void) 332 { 333 int err; 334 + struct vfsmount *bd_mnt; 335 + 336 bdev_cachep = kmem_cache_create("bdev_cache", sizeof(struct bdev_inode), 337 0, (SLAB_HWCACHE_ALIGN|SLAB_RECLAIM_ACCOUNT| 338 SLAB_MEM_SPREAD|SLAB_PANIC), ··· 373 struct block_device *bdev; 374 struct inode *inode; 375 376 + inode = iget5_locked(blockdev_superblock, hash(dev), 377 bdev_test, bdev_set, &dev); 378 379 if (!inode) ··· 463 464 spin_lock(&bdev_lock); 465 if (inode->i_bdev) { 466 + if (!sb_is_blkdev_sb(inode->i_sb)) 467 bdev = inode->i_bdev; 468 __bd_forget(inode); 469 }
+1 -1
fs/cifs/Makefile
··· 5 6 cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ 7 link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o \ 8 - md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o fcntl.o \ 9 readdir.o ioctl.o sess.o export.o cifsacl.o 10 11 cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
··· 5 6 cifs-y := cifsfs.o cifssmb.o cifs_debug.o connect.o dir.o file.o inode.o \ 7 link.o misc.o netmisc.o smbdes.o smbencrypt.o transport.o asn1.o \ 8 + md4.o md5.o cifs_unicode.o nterr.o xattr.o cifsencrypt.o \ 9 readdir.o ioctl.o sess.o export.o cifsacl.o 10 11 cifs-$(CONFIG_CIFS_UPCALL) += cifs_spnego.o
-7
fs/cifs/cifsfs.c
··· 747 #endif /* CONFIG_CIFS_POSIX */ 748 749 #ifdef CONFIG_CIFS_EXPERIMENTAL 750 - .dir_notify = cifs_dir_notify, 751 .setlease = cifs_setlease, 752 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 753 }; ··· 767 #endif /* CONFIG_CIFS_POSIX */ 768 .llseek = cifs_llseek, 769 #ifdef CONFIG_CIFS_EXPERIMENTAL 770 - .dir_notify = cifs_dir_notify, 771 .setlease = cifs_setlease, 772 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 773 }; ··· 787 #endif /* CONFIG_CIFS_POSIX */ 788 789 #ifdef CONFIG_CIFS_EXPERIMENTAL 790 - .dir_notify = cifs_dir_notify, 791 .setlease = cifs_setlease, 792 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 793 }; ··· 806 #endif /* CONFIG_CIFS_POSIX */ 807 .llseek = cifs_llseek, 808 #ifdef CONFIG_CIFS_EXPERIMENTAL 809 - .dir_notify = cifs_dir_notify, 810 .setlease = cifs_setlease, 811 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 812 }; ··· 814 .readdir = cifs_readdir, 815 .release = cifs_closedir, 816 .read = generic_read_dir, 817 - #ifdef CONFIG_CIFS_EXPERIMENTAL 818 - .dir_notify = cifs_dir_notify, 819 - #endif /* CONFIG_CIFS_EXPERIMENTAL */ 820 .unlocked_ioctl = cifs_ioctl, 821 .llseek = generic_file_llseek, 822 };
··· 747 #endif /* CONFIG_CIFS_POSIX */ 748 749 #ifdef CONFIG_CIFS_EXPERIMENTAL 750 .setlease = cifs_setlease, 751 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 752 }; ··· 768 #endif /* CONFIG_CIFS_POSIX */ 769 .llseek = cifs_llseek, 770 #ifdef CONFIG_CIFS_EXPERIMENTAL 771 .setlease = cifs_setlease, 772 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 773 }; ··· 789 #endif /* CONFIG_CIFS_POSIX */ 790 791 #ifdef CONFIG_CIFS_EXPERIMENTAL 792 .setlease = cifs_setlease, 793 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 794 }; ··· 809 #endif /* CONFIG_CIFS_POSIX */ 810 .llseek = cifs_llseek, 811 #ifdef CONFIG_CIFS_EXPERIMENTAL 812 .setlease = cifs_setlease, 813 #endif /* CONFIG_CIFS_EXPERIMENTAL */ 814 }; ··· 818 .readdir = cifs_readdir, 819 .release = cifs_closedir, 820 .read = generic_read_dir, 821 .unlocked_ioctl = cifs_ioctl, 822 .llseek = generic_file_llseek, 823 };
-1
fs/cifs/cifsfs.h
··· 76 extern const struct file_operations cifs_dir_ops; 77 extern int cifs_dir_open(struct inode *inode, struct file *file); 78 extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir); 79 - extern int cifs_dir_notify(struct file *, unsigned long arg); 80 81 /* Functions related to dir entries */ 82 extern struct dentry_operations cifs_dentry_ops;
··· 76 extern const struct file_operations cifs_dir_ops; 77 extern int cifs_dir_open(struct inode *inode, struct file *file); 78 extern int cifs_readdir(struct file *file, void *direntry, filldir_t filldir); 79 80 /* Functions related to dir entries */ 81 extern struct dentry_operations cifs_dentry_ops;
-118
fs/cifs/fcntl.c
··· 1 - /* 2 - * fs/cifs/fcntl.c 3 - * 4 - * vfs operations that deal with the file control API 5 - * 6 - * Copyright (C) International Business Machines Corp., 2003,2004 7 - * Author(s): Steve French (sfrench@us.ibm.com) 8 - * 9 - * This library is free software; you can redistribute it and/or modify 10 - * it under the terms of the GNU Lesser General Public License as published 11 - * by the Free Software Foundation; either version 2.1 of the License, or 12 - * (at your option) any later version. 13 - * 14 - * This library is distributed in the hope that it will be useful, 15 - * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 17 - * the GNU Lesser General Public License for more details. 18 - * 19 - * You should have received a copy of the GNU Lesser General Public License 20 - * along with this library; if not, write to the Free Software 21 - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 - */ 23 - #include <linux/fs.h> 24 - #include <linux/stat.h> 25 - #include <linux/fcntl.h> 26 - #include "cifsglob.h" 27 - #include "cifsproto.h" 28 - #include "cifs_unicode.h" 29 - #include "cifs_debug.h" 30 - #include "cifsfs.h" 31 - 32 - static __u32 convert_to_cifs_notify_flags(unsigned long fcntl_notify_flags) 33 - { 34 - __u32 cifs_ntfy_flags = 0; 35 - 36 - /* No way on Linux VFS to ask to monitor xattr 37 - changes (and no stream support either */ 38 - if (fcntl_notify_flags & DN_ACCESS) 39 - cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_ACCESS; 40 - if (fcntl_notify_flags & DN_MODIFY) { 41 - /* What does this mean on directories? */ 42 - cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE | 43 - FILE_NOTIFY_CHANGE_SIZE; 44 - } 45 - if (fcntl_notify_flags & DN_CREATE) { 46 - cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_CREATION | 47 - FILE_NOTIFY_CHANGE_LAST_WRITE; 48 - } 49 - if (fcntl_notify_flags & DN_DELETE) 50 - cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_LAST_WRITE; 51 - if (fcntl_notify_flags & DN_RENAME) { 52 - /* BB review this - checking various server behaviors */ 53 - cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_DIR_NAME | 54 - FILE_NOTIFY_CHANGE_FILE_NAME; 55 - } 56 - if (fcntl_notify_flags & DN_ATTRIB) { 57 - cifs_ntfy_flags |= FILE_NOTIFY_CHANGE_SECURITY | 58 - FILE_NOTIFY_CHANGE_ATTRIBUTES; 59 - } 60 - /* if (fcntl_notify_flags & DN_MULTISHOT) { 61 - cifs_ntfy_flags |= ; 62 - } */ /* BB fixme - not sure how to handle this with CIFS yet */ 63 - 64 - return cifs_ntfy_flags; 65 - } 66 - 67 - int cifs_dir_notify(struct file *file, unsigned long arg) 68 - { 69 - int xid; 70 - int rc = -EINVAL; 71 - int oplock = 0; 72 - struct cifs_sb_info *cifs_sb; 73 - struct cifsTconInfo *pTcon; 74 - char *full_path = NULL; 75 - __u32 filter = FILE_NOTIFY_CHANGE_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES; 76 - __u16 netfid; 77 - 78 - if (experimEnabled == 0) 79 - return 0; 80 - 81 - xid = GetXid(); 82 - cifs_sb = CIFS_SB(file->f_path.dentry->d_sb); 83 - pTcon = cifs_sb->tcon; 84 - 85 - full_path = build_path_from_dentry(file->f_path.dentry); 86 - 87 - if (full_path == NULL) { 88 - rc = -ENOMEM; 89 - } else { 90 - cFYI(1, ("dir notify on file %s Arg 0x%lx", full_path, arg)); 91 - rc = CIFSSMBOpen(xid, pTcon, full_path, FILE_OPEN, 92 - GENERIC_READ | SYNCHRONIZE, 0 /* create options */, 93 - &netfid, &oplock, NULL, cifs_sb->local_nls, 94 - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR); 95 - /* BB fixme - add this handle to a notify handle list */ 96 - if (rc) { 97 - cFYI(1, ("Could not open directory for notify")); 98 - } else { 99 - filter = convert_to_cifs_notify_flags(arg); 100 - if (filter != 0) { 101 - rc = CIFSSMBNotify(xid, pTcon, 102 - 0 /* no subdirs */, netfid, 103 - filter, file, arg & DN_MULTISHOT, 104 - cifs_sb->local_nls); 105 - } else { 106 - rc = -EINVAL; 107 - } 108 - /* BB add code to close file eventually (at unmount 109 - it would close automatically but may be a way 110 - to do it easily when inode freed or when 111 - notify info is cleared/changed */ 112 - cFYI(1, ("notify rc %d", rc)); 113 - } 114 - } 115 - 116 - FreeXid(xid); 117 - return rc; 118 - }
···
+10 -15
fs/dcache.c
··· 34 #include <linux/bootmem.h> 35 #include "internal.h" 36 37 - 38 int sysctl_vfs_cache_pressure __read_mostly = 100; 39 EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure); 40 ··· 947 dentry->d_op = NULL; 948 dentry->d_fsdata = NULL; 949 dentry->d_mounted = 0; 950 - #ifdef CONFIG_PROFILING 951 - dentry->d_cookie = NULL; 952 - #endif 953 INIT_HLIST_NODE(&dentry->d_hash); 954 INIT_LIST_HEAD(&dentry->d_lru); 955 INIT_LIST_HEAD(&dentry->d_subdirs); ··· 1332 * 1333 * Searches the children of the parent dentry for the name in question. If 1334 * the dentry is found its reference count is incremented and the dentry 1335 - * is returned. The caller must use d_put to free the entry when it has 1336 * finished using it. %NULL is returned on failure. 1337 * 1338 * __d_lookup is dcache_lock free. The hash list is protected using RCU. ··· 1616 */ 1617 memcpy(dentry->d_iname, target->d_name.name, 1618 target->d_name.len + 1); 1619 } 1620 } 1621 } 1622 1623 /* ··· 1680 1681 /* Switch the names.. */ 1682 switch_names(dentry, target); 1683 - do_switch(dentry->d_name.len, target->d_name.len); 1684 do_switch(dentry->d_name.hash, target->d_name.hash); 1685 1686 /* ... and switch the parents */ ··· 1789 struct dentry *dparent, *aparent; 1790 1791 switch_names(dentry, anon); 1792 - do_switch(dentry->d_name.len, anon->d_name.len); 1793 do_switch(dentry->d_name.hash, anon->d_name.hash); 1794 1795 dparent = dentry->d_parent; ··· 1908 * Convert a dentry into an ASCII path name. If the entry has been deleted 1909 * the string " (deleted)" is appended. Note that this is ambiguous. 1910 * 1911 - * Returns the buffer or an error code if the path was too long. 1912 * 1913 * "buflen" should be positive. Caller holds the dcache_lock. 1914 * ··· 1985 * Convert a dentry into an ASCII path name. If the entry has been deleted 1986 * the string " (deleted)" is appended. Note that this is ambiguous. 1987 * 1988 - * Returns the buffer or an error code if the path was too long. 1989 * 1990 * "buflen" should be positive. 1991 */ ··· 2314 /* SLAB cache for __getname() consumers */ 2315 struct kmem_cache *names_cachep __read_mostly; 2316 2317 - /* SLAB cache for file structures */ 2318 - struct kmem_cache *filp_cachep __read_mostly; 2319 - 2320 EXPORT_SYMBOL(d_genocide); 2321 2322 void __init vfs_caches_init_early(void) ··· 2333 mempages -= reserve; 2334 2335 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0, 2336 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 2337 - 2338 - filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, 2339 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 2340 2341 dcache_init();
··· 34 #include <linux/bootmem.h> 35 #include "internal.h" 36 37 int sysctl_vfs_cache_pressure __read_mostly = 100; 38 EXPORT_SYMBOL_GPL(sysctl_vfs_cache_pressure); 39 ··· 948 dentry->d_op = NULL; 949 dentry->d_fsdata = NULL; 950 dentry->d_mounted = 0; 951 INIT_HLIST_NODE(&dentry->d_hash); 952 INIT_LIST_HEAD(&dentry->d_lru); 953 INIT_LIST_HEAD(&dentry->d_subdirs); ··· 1336 * 1337 * Searches the children of the parent dentry for the name in question. If 1338 * the dentry is found its reference count is incremented and the dentry 1339 + * is returned. The caller must use dput to free the entry when it has 1340 * finished using it. %NULL is returned on failure. 1341 * 1342 * __d_lookup is dcache_lock free. The hash list is protected using RCU. ··· 1620 */ 1621 memcpy(dentry->d_iname, target->d_name.name, 1622 target->d_name.len + 1); 1623 + dentry->d_name.len = target->d_name.len; 1624 + return; 1625 } 1626 } 1627 + do_switch(dentry->d_name.len, target->d_name.len); 1628 } 1629 1630 /* ··· 1681 1682 /* Switch the names.. */ 1683 switch_names(dentry, target); 1684 do_switch(dentry->d_name.hash, target->d_name.hash); 1685 1686 /* ... and switch the parents */ ··· 1791 struct dentry *dparent, *aparent; 1792 1793 switch_names(dentry, anon); 1794 do_switch(dentry->d_name.hash, anon->d_name.hash); 1795 1796 dparent = dentry->d_parent; ··· 1911 * Convert a dentry into an ASCII path name. If the entry has been deleted 1912 * the string " (deleted)" is appended. Note that this is ambiguous. 1913 * 1914 + * Returns a pointer into the buffer or an error code if the 1915 + * path was too long. 1916 * 1917 * "buflen" should be positive. Caller holds the dcache_lock. 1918 * ··· 1987 * Convert a dentry into an ASCII path name. If the entry has been deleted 1988 * the string " (deleted)" is appended. Note that this is ambiguous. 1989 * 1990 + * Returns a pointer into the buffer or an error code if the path was 1991 + * too long. Note: Callers should use the returned pointer, not the passed 1992 + * in buffer, to use the name! The implementation often starts at an offset 1993 + * into the buffer, and may leave 0 bytes at the start. 1994 * 1995 * "buflen" should be positive. 1996 */ ··· 2313 /* SLAB cache for __getname() consumers */ 2314 struct kmem_cache *names_cachep __read_mostly; 2315 2316 EXPORT_SYMBOL(d_genocide); 2317 2318 void __init vfs_caches_init_early(void) ··· 2335 mempages -= reserve; 2336 2337 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0, 2338 SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL); 2339 2340 dcache_init();
+19 -9
fs/dcookies.c
··· 93 { 94 struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache, 95 GFP_KERNEL); 96 if (!dcs) 97 return NULL; 98 99 - path->dentry->d_cookie = dcs; 100 dcs->path = *path; 101 path_get(path); 102 hash_dcookie(dcs); ··· 124 goto out; 125 } 126 127 - dcs = path->dentry->d_cookie; 128 - 129 - if (!dcs) 130 dcs = alloc_dcookie(path); 131 - 132 - if (!dcs) { 133 - err = -ENOMEM; 134 - goto out; 135 } 136 137 *cookie = dcookie_value(dcs); ··· 256 257 static void free_dcookie(struct dcookie_struct * dcs) 258 { 259 - dcs->path.dentry->d_cookie = NULL; 260 path_put(&dcs->path); 261 kmem_cache_free(dcookie_cache, dcs); 262 }
··· 93 { 94 struct dcookie_struct *dcs = kmem_cache_alloc(dcookie_cache, 95 GFP_KERNEL); 96 + struct dentry *d; 97 if (!dcs) 98 return NULL; 99 100 + d = path->dentry; 101 + spin_lock(&d->d_lock); 102 + d->d_flags |= DCACHE_COOKIE; 103 + spin_unlock(&d->d_lock); 104 + 105 dcs->path = *path; 106 path_get(path); 107 hash_dcookie(dcs); ··· 119 goto out; 120 } 121 122 + if (path->dentry->d_flags & DCACHE_COOKIE) { 123 + dcs = find_dcookie((unsigned long)path->dentry); 124 + } else { 125 dcs = alloc_dcookie(path); 126 + if (!dcs) { 127 + err = -ENOMEM; 128 + goto out; 129 + } 130 } 131 132 *cookie = dcookie_value(dcs); ··· 251 252 static void free_dcookie(struct dcookie_struct * dcs) 253 { 254 + struct dentry *d = dcs->path.dentry; 255 + 256 + spin_lock(&d->d_lock); 257 + d->d_flags &= ~DCACHE_COOKIE; 258 + spin_unlock(&d->d_lock); 259 + 260 path_put(&dcs->path); 261 kmem_cache_free(dcookie_cache, dcs); 262 }
-3
fs/dnotify.c fs/notify/dnotify/dnotify.c
··· 115 dn->dn_next = inode->i_dnotify; 116 inode->i_dnotify = dn; 117 spin_unlock(&inode->i_lock); 118 - 119 - if (filp->f_op && filp->f_op->dir_notify) 120 - return filp->f_op->dir_notify(filp, arg); 121 return 0; 122 123 out_free:
··· 115 dn->dn_next = inode->i_dnotify; 116 inode->i_dnotify = dn; 117 spin_unlock(&inode->i_lock); 118 return 0; 119 120 out_free:
+2 -1
fs/ecryptfs/inode.c
··· 673 ecryptfs_printk(KERN_DEBUG, "Calling readlink w/ " 674 "dentry->d_name.name = [%s]\n", dentry->d_name.name); 675 rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len); 676 - buf[rc] = '\0'; 677 set_fs(old_fs); 678 if (rc < 0) 679 goto out_free; 680 rc = 0; 681 nd_set_link(nd, buf); 682 goto out;
··· 673 ecryptfs_printk(KERN_DEBUG, "Calling readlink w/ " 674 "dentry->d_name.name = [%s]\n", dentry->d_name.name); 675 rc = dentry->d_inode->i_op->readlink(dentry, (char __user *)buf, len); 676 set_fs(old_fs); 677 if (rc < 0) 678 goto out_free; 679 + else 680 + buf[rc] = '\0'; 681 rc = 0; 682 nd_set_link(nd, buf); 683 goto out;
+3 -2
fs/exec.c
··· 127 if (nd.path.mnt->mnt_flags & MNT_NOEXEC) 128 goto exit; 129 130 - error = vfs_permission(&nd, MAY_READ | MAY_EXEC | MAY_OPEN); 131 if (error) 132 goto exit; 133 ··· 681 if (nd.path.mnt->mnt_flags & MNT_NOEXEC) 682 goto out_path_put; 683 684 - err = vfs_permission(&nd, MAY_EXEC | MAY_OPEN); 685 if (err) 686 goto out_path_put; 687
··· 127 if (nd.path.mnt->mnt_flags & MNT_NOEXEC) 128 goto exit; 129 130 + error = inode_permission(nd.path.dentry->d_inode, 131 + MAY_READ | MAY_EXEC | MAY_OPEN); 132 if (error) 133 goto exit; 134 ··· 680 if (nd.path.mnt->mnt_flags & MNT_NOEXEC) 681 goto out_path_put; 682 683 + err = inode_permission(nd.path.dentry->d_inode, MAY_EXEC | MAY_OPEN); 684 if (err) 685 goto out_path_put; 686
+5 -1
fs/ext2/ialloc.c
··· 585 spin_lock(&sbi->s_next_gen_lock); 586 inode->i_generation = sbi->s_next_generation++; 587 spin_unlock(&sbi->s_next_gen_lock); 588 - insert_inode_hash(inode); 589 590 if (DQUOT_ALLOC_INODE(inode)) { 591 err = -EDQUOT; ··· 615 DQUOT_DROP(inode); 616 inode->i_flags |= S_NOQUOTA; 617 inode->i_nlink = 0; 618 iput(inode); 619 return ERR_PTR(err); 620
··· 585 spin_lock(&sbi->s_next_gen_lock); 586 inode->i_generation = sbi->s_next_generation++; 587 spin_unlock(&sbi->s_next_gen_lock); 588 + if (insert_inode_locked(inode) < 0) { 589 + err = -EINVAL; 590 + goto fail_drop; 591 + } 592 593 if (DQUOT_ALLOC_INODE(inode)) { 594 err = -EDQUOT; ··· 612 DQUOT_DROP(inode); 613 inode->i_flags |= S_NOQUOTA; 614 inode->i_nlink = 0; 615 + unlock_new_inode(inode); 616 iput(inode); 617 return ERR_PTR(err); 618
+5 -2
fs/ext2/inode.c
··· 32 #include <linux/buffer_head.h> 33 #include <linux/mpage.h> 34 #include <linux/fiemap.h> 35 #include "ext2.h" 36 #include "acl.h" 37 #include "xip.h" ··· 1287 else 1288 inode->i_mapping->a_ops = &ext2_aops; 1289 } else if (S_ISLNK(inode->i_mode)) { 1290 - if (ext2_inode_is_fast_symlink(inode)) 1291 inode->i_op = &ext2_fast_symlink_inode_operations; 1292 - else { 1293 inode->i_op = &ext2_symlink_inode_operations; 1294 if (test_opt(inode->i_sb, NOBH)) 1295 inode->i_mapping->a_ops = &ext2_nobh_aops;
··· 32 #include <linux/buffer_head.h> 33 #include <linux/mpage.h> 34 #include <linux/fiemap.h> 35 + #include <linux/namei.h> 36 #include "ext2.h" 37 #include "acl.h" 38 #include "xip.h" ··· 1286 else 1287 inode->i_mapping->a_ops = &ext2_aops; 1288 } else if (S_ISLNK(inode->i_mode)) { 1289 + if (ext2_inode_is_fast_symlink(inode)) { 1290 inode->i_op = &ext2_fast_symlink_inode_operations; 1291 + nd_terminate_link(ei->i_data, inode->i_size, 1292 + sizeof(ei->i_data) - 1); 1293 + } else { 1294 inode->i_op = &ext2_symlink_inode_operations; 1295 if (test_opt(inode->i_sb, NOBH)) 1296 inode->i_mapping->a_ops = &ext2_nobh_aops;
+14 -1
fs/ext2/namei.c
··· 41 int err = ext2_add_link(dentry, inode); 42 if (!err) { 43 d_instantiate(dentry, inode); 44 return 0; 45 } 46 inode_dec_link_count(inode); 47 iput(inode); 48 return err; 49 } ··· 172 173 out_fail: 174 inode_dec_link_count(inode); 175 iput (inode); 176 goto out; 177 } ··· 181 struct dentry *dentry) 182 { 183 struct inode *inode = old_dentry->d_inode; 184 185 if (inode->i_nlink >= EXT2_LINK_MAX) 186 return -EMLINK; ··· 190 inode_inc_link_count(inode); 191 atomic_inc(&inode->i_count); 192 193 - return ext2_add_nondir(dentry, inode); 194 } 195 196 static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) ··· 233 goto out_fail; 234 235 d_instantiate(dentry, inode); 236 out: 237 return err; 238 239 out_fail: 240 inode_dec_link_count(inode); 241 inode_dec_link_count(inode); 242 iput(inode); 243 out_dir: 244 inode_dec_link_count(dir);
··· 41 int err = ext2_add_link(dentry, inode); 42 if (!err) { 43 d_instantiate(dentry, inode); 44 + unlock_new_inode(inode); 45 return 0; 46 } 47 inode_dec_link_count(inode); 48 + unlock_new_inode(inode); 49 iput(inode); 50 return err; 51 } ··· 170 171 out_fail: 172 inode_dec_link_count(inode); 173 + unlock_new_inode(inode); 174 iput (inode); 175 goto out; 176 } ··· 178 struct dentry *dentry) 179 { 180 struct inode *inode = old_dentry->d_inode; 181 + int err; 182 183 if (inode->i_nlink >= EXT2_LINK_MAX) 184 return -EMLINK; ··· 186 inode_inc_link_count(inode); 187 atomic_inc(&inode->i_count); 188 189 + err = ext2_add_link(dentry, inode); 190 + if (!err) { 191 + d_instantiate(dentry, inode); 192 + return 0; 193 + } 194 + inode_dec_link_count(inode); 195 + iput(inode); 196 + return err; 197 } 198 199 static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode) ··· 222 goto out_fail; 223 224 d_instantiate(dentry, inode); 225 + unlock_new_inode(inode); 226 out: 227 return err; 228 229 out_fail: 230 inode_dec_link_count(inode); 231 inode_dec_link_count(inode); 232 + unlock_new_inode(inode); 233 iput(inode); 234 out_dir: 235 inode_dec_link_count(dir);
+5 -1
fs/ext3/ialloc.c
··· 579 ext3_set_inode_flags(inode); 580 if (IS_DIRSYNC(inode)) 581 handle->h_sync = 1; 582 - insert_inode_hash(inode); 583 spin_lock(&sbi->s_next_gen_lock); 584 inode->i_generation = sbi->s_next_generation++; 585 spin_unlock(&sbi->s_next_gen_lock); ··· 630 DQUOT_DROP(inode); 631 inode->i_flags |= S_NOQUOTA; 632 inode->i_nlink = 0; 633 iput(inode); 634 brelse(bitmap_bh); 635 return ERR_PTR(err);
··· 579 ext3_set_inode_flags(inode); 580 if (IS_DIRSYNC(inode)) 581 handle->h_sync = 1; 582 + if (insert_inode_locked(inode) < 0) { 583 + err = -EINVAL; 584 + goto fail_drop; 585 + } 586 spin_lock(&sbi->s_next_gen_lock); 587 inode->i_generation = sbi->s_next_generation++; 588 spin_unlock(&sbi->s_next_gen_lock); ··· 627 DQUOT_DROP(inode); 628 inode->i_flags |= S_NOQUOTA; 629 inode->i_nlink = 0; 630 + unlock_new_inode(inode); 631 iput(inode); 632 brelse(bitmap_bh); 633 return ERR_PTR(err);
+5 -2
fs/ext3/inode.c
··· 37 #include <linux/uio.h> 38 #include <linux/bio.h> 39 #include <linux/fiemap.h> 40 #include "xattr.h" 41 #include "acl.h" 42 ··· 2818 inode->i_op = &ext3_dir_inode_operations; 2819 inode->i_fop = &ext3_dir_operations; 2820 } else if (S_ISLNK(inode->i_mode)) { 2821 - if (ext3_inode_is_fast_symlink(inode)) 2822 inode->i_op = &ext3_fast_symlink_inode_operations; 2823 - else { 2824 inode->i_op = &ext3_symlink_inode_operations; 2825 ext3_set_aops(inode); 2826 }
··· 37 #include <linux/uio.h> 38 #include <linux/bio.h> 39 #include <linux/fiemap.h> 40 + #include <linux/namei.h> 41 #include "xattr.h" 42 #include "acl.h" 43 ··· 2817 inode->i_op = &ext3_dir_inode_operations; 2818 inode->i_fop = &ext3_dir_operations; 2819 } else if (S_ISLNK(inode->i_mode)) { 2820 + if (ext3_inode_is_fast_symlink(inode)) { 2821 inode->i_op = &ext3_fast_symlink_inode_operations; 2822 + nd_terminate_link(ei->i_data, inode->i_size, 2823 + sizeof(ei->i_data) - 1); 2824 + } else { 2825 inode->i_op = &ext3_symlink_inode_operations; 2826 ext3_set_aops(inode); 2827 }
+14 -1
fs/ext3/namei.c
··· 1652 if (!err) { 1653 ext3_mark_inode_dirty(handle, inode); 1654 d_instantiate(dentry, inode); 1655 return 0; 1656 } 1657 drop_nlink(inode); 1658 iput(inode); 1659 return err; 1660 } ··· 1767 dir_block = ext3_bread (handle, inode, 0, 1, &err); 1768 if (!dir_block) { 1769 drop_nlink(inode); /* is this nlink == 0? */ 1770 ext3_mark_inode_dirty(handle, inode); 1771 iput (inode); 1772 goto out_stop; ··· 1795 err = ext3_add_entry (handle, dentry, inode); 1796 if (err) { 1797 inode->i_nlink = 0; 1798 ext3_mark_inode_dirty(handle, inode); 1799 iput (inode); 1800 goto out_stop; ··· 1804 ext3_update_dx_flag(dir); 1805 ext3_mark_inode_dirty(handle, dir); 1806 d_instantiate(dentry, inode); 1807 out_stop: 1808 ext3_journal_stop(handle); 1809 if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) ··· 2179 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2180 if (err) { 2181 drop_nlink(inode); 2182 ext3_mark_inode_dirty(handle, inode); 2183 iput (inode); 2184 goto out_stop; ··· 2227 inc_nlink(inode); 2228 atomic_inc(&inode->i_count); 2229 2230 - err = ext3_add_nondir(handle, dentry, inode); 2231 ext3_journal_stop(handle); 2232 if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) 2233 goto retry;
··· 1652 if (!err) { 1653 ext3_mark_inode_dirty(handle, inode); 1654 d_instantiate(dentry, inode); 1655 + unlock_new_inode(inode); 1656 return 0; 1657 } 1658 drop_nlink(inode); 1659 + unlock_new_inode(inode); 1660 iput(inode); 1661 return err; 1662 } ··· 1765 dir_block = ext3_bread (handle, inode, 0, 1, &err); 1766 if (!dir_block) { 1767 drop_nlink(inode); /* is this nlink == 0? */ 1768 + unlock_new_inode(inode); 1769 ext3_mark_inode_dirty(handle, inode); 1770 iput (inode); 1771 goto out_stop; ··· 1792 err = ext3_add_entry (handle, dentry, inode); 1793 if (err) { 1794 inode->i_nlink = 0; 1795 + unlock_new_inode(inode); 1796 ext3_mark_inode_dirty(handle, inode); 1797 iput (inode); 1798 goto out_stop; ··· 1800 ext3_update_dx_flag(dir); 1801 ext3_mark_inode_dirty(handle, dir); 1802 d_instantiate(dentry, inode); 1803 + unlock_new_inode(inode); 1804 out_stop: 1805 ext3_journal_stop(handle); 1806 if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) ··· 2174 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2175 if (err) { 2176 drop_nlink(inode); 2177 + unlock_new_inode(inode); 2178 ext3_mark_inode_dirty(handle, inode); 2179 iput (inode); 2180 goto out_stop; ··· 2221 inc_nlink(inode); 2222 atomic_inc(&inode->i_count); 2223 2224 + err = ext3_add_entry(handle, dentry, inode); 2225 + if (!err) { 2226 + ext3_mark_inode_dirty(handle, inode); 2227 + d_instantiate(dentry, inode); 2228 + } else { 2229 + drop_nlink(inode); 2230 + iput(inode); 2231 + } 2232 ext3_journal_stop(handle); 2233 if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) 2234 goto retry;
+5 -1
fs/ext4/ialloc.c
··· 826 ext4_set_inode_flags(inode); 827 if (IS_DIRSYNC(inode)) 828 handle->h_sync = 1; 829 - insert_inode_hash(inode); 830 spin_lock(&sbi->s_next_gen_lock); 831 inode->i_generation = sbi->s_next_generation++; 832 spin_unlock(&sbi->s_next_gen_lock); ··· 884 DQUOT_DROP(inode); 885 inode->i_flags |= S_NOQUOTA; 886 inode->i_nlink = 0; 887 iput(inode); 888 brelse(bitmap_bh); 889 return ERR_PTR(err);
··· 826 ext4_set_inode_flags(inode); 827 if (IS_DIRSYNC(inode)) 828 handle->h_sync = 1; 829 + if (insert_inode_locked(inode) < 0) { 830 + err = -EINVAL; 831 + goto fail_drop; 832 + } 833 spin_lock(&sbi->s_next_gen_lock); 834 inode->i_generation = sbi->s_next_generation++; 835 spin_unlock(&sbi->s_next_gen_lock); ··· 881 DQUOT_DROP(inode); 882 inode->i_flags |= S_NOQUOTA; 883 inode->i_nlink = 0; 884 + unlock_new_inode(inode); 885 iput(inode); 886 brelse(bitmap_bh); 887 return ERR_PTR(err);
+5 -2
fs/ext4/inode.c
··· 34 #include <linux/writeback.h> 35 #include <linux/pagevec.h> 36 #include <linux/mpage.h> 37 #include <linux/uio.h> 38 #include <linux/bio.h> 39 #include "ext4_jbd2.h" ··· 4165 inode->i_op = &ext4_dir_inode_operations; 4166 inode->i_fop = &ext4_dir_operations; 4167 } else if (S_ISLNK(inode->i_mode)) { 4168 - if (ext4_inode_is_fast_symlink(inode)) 4169 inode->i_op = &ext4_fast_symlink_inode_operations; 4170 - else { 4171 inode->i_op = &ext4_symlink_inode_operations; 4172 ext4_set_aops(inode); 4173 }
··· 34 #include <linux/writeback.h> 35 #include <linux/pagevec.h> 36 #include <linux/mpage.h> 37 + #include <linux/namei.h> 38 #include <linux/uio.h> 39 #include <linux/bio.h> 40 #include "ext4_jbd2.h" ··· 4164 inode->i_op = &ext4_dir_inode_operations; 4165 inode->i_fop = &ext4_dir_operations; 4166 } else if (S_ISLNK(inode->i_mode)) { 4167 + if (ext4_inode_is_fast_symlink(inode)) { 4168 inode->i_op = &ext4_fast_symlink_inode_operations; 4169 + nd_terminate_link(ei->i_data, inode->i_size, 4170 + sizeof(ei->i_data) - 1); 4171 + } else { 4172 inode->i_op = &ext4_symlink_inode_operations; 4173 ext4_set_aops(inode); 4174 }
+13 -1
fs/ext4/namei.c
··· 1693 if (!err) { 1694 ext4_mark_inode_dirty(handle, inode); 1695 d_instantiate(dentry, inode); 1696 return 0; 1697 } 1698 drop_nlink(inode); 1699 iput(inode); 1700 return err; 1701 } ··· 1832 if (err) { 1833 out_clear_inode: 1834 clear_nlink(inode); 1835 ext4_mark_inode_dirty(handle, inode); 1836 iput(inode); 1837 goto out_stop; ··· 1841 ext4_update_dx_flag(dir); 1842 ext4_mark_inode_dirty(handle, dir); 1843 d_instantiate(dentry, inode); 1844 out_stop: 1845 ext4_journal_stop(handle); 1846 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) ··· 2216 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2217 if (err) { 2218 clear_nlink(inode); 2219 ext4_mark_inode_dirty(handle, inode); 2220 iput(inode); 2221 goto out_stop; ··· 2267 ext4_inc_count(handle, inode); 2268 atomic_inc(&inode->i_count); 2269 2270 - err = ext4_add_nondir(handle, dentry, inode); 2271 ext4_journal_stop(handle); 2272 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) 2273 goto retry;
··· 1693 if (!err) { 1694 ext4_mark_inode_dirty(handle, inode); 1695 d_instantiate(dentry, inode); 1696 + unlock_new_inode(inode); 1697 return 0; 1698 } 1699 drop_nlink(inode); 1700 + unlock_new_inode(inode); 1701 iput(inode); 1702 return err; 1703 } ··· 1830 if (err) { 1831 out_clear_inode: 1832 clear_nlink(inode); 1833 + unlock_new_inode(inode); 1834 ext4_mark_inode_dirty(handle, inode); 1835 iput(inode); 1836 goto out_stop; ··· 1838 ext4_update_dx_flag(dir); 1839 ext4_mark_inode_dirty(handle, dir); 1840 d_instantiate(dentry, inode); 1841 + unlock_new_inode(inode); 1842 out_stop: 1843 ext4_journal_stop(handle); 1844 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) ··· 2212 mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS); 2213 if (err) { 2214 clear_nlink(inode); 2215 + unlock_new_inode(inode); 2216 ext4_mark_inode_dirty(handle, inode); 2217 iput(inode); 2218 goto out_stop; ··· 2262 ext4_inc_count(handle, inode); 2263 atomic_inc(&inode->i_count); 2264 2265 + err = ext4_add_entry(handle, dentry, inode); 2266 + if (!err) { 2267 + ext4_mark_inode_dirty(handle, inode); 2268 + d_instantiate(dentry, inode); 2269 + } else { 2270 + drop_nlink(inode); 2271 + iput(inode); 2272 + } 2273 ext4_journal_stop(handle); 2274 if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) 2275 goto retry;
+9 -1
fs/file_table.c
··· 32 /* public. Not pretty! */ 33 __cacheline_aligned_in_smp DEFINE_SPINLOCK(files_lock); 34 35 static struct percpu_counter nr_files __cacheline_aligned_in_smp; 36 37 static inline void file_free_rcu(struct rcu_head *head) ··· 400 void __init files_init(unsigned long mempages) 401 { 402 int n; 403 - /* One file with associated inode and dcache is very roughly 1K. 404 * Per default don't use more than 10% of our memory for files. 405 */ 406
··· 32 /* public. Not pretty! */ 33 __cacheline_aligned_in_smp DEFINE_SPINLOCK(files_lock); 34 35 + /* SLAB cache for file structures */ 36 + static struct kmem_cache *filp_cachep __read_mostly; 37 + 38 static struct percpu_counter nr_files __cacheline_aligned_in_smp; 39 40 static inline void file_free_rcu(struct rcu_head *head) ··· 397 void __init files_init(unsigned long mempages) 398 { 399 int n; 400 + 401 + filp_cachep = kmem_cache_create("filp", sizeof(struct file), 0, 402 + SLAB_HWCACHE_ALIGN | SLAB_PANIC, NULL); 403 + 404 + /* 405 + * One file with associated inode and dcache is very roughly 1K. 406 * Per default don't use more than 10% of our memory for files. 407 */ 408
+3 -1
fs/freevxfs/vxfs_inode.c
··· 325 if (!VXFS_ISIMMED(vip)) { 326 ip->i_op = &page_symlink_inode_operations; 327 ip->i_mapping->a_ops = &vxfs_aops; 328 - } else 329 ip->i_op = &vxfs_immed_symlink_iops; 330 } else 331 init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev)); 332
··· 325 if (!VXFS_ISIMMED(vip)) { 326 ip->i_op = &page_symlink_inode_operations; 327 ip->i_mapping->a_ops = &vxfs_aops; 328 + } else { 329 ip->i_op = &vxfs_immed_symlink_iops; 330 + vip->vii_immed.vi_immed[ip->i_size] = '\0'; 331 + } 332 } else 333 init_special_inode(ip, ip->i_mode, old_decode_dev(vip->vii_rdev)); 334
+59
fs/inode.c
··· 1032 1033 EXPORT_SYMBOL(iget_locked); 1034 1035 /** 1036 * __insert_inode_hash - hash an inode 1037 * @inode: unhashed inode
··· 1032 1033 EXPORT_SYMBOL(iget_locked); 1034 1035 + int insert_inode_locked(struct inode *inode) 1036 + { 1037 + struct super_block *sb = inode->i_sb; 1038 + ino_t ino = inode->i_ino; 1039 + struct hlist_head *head = inode_hashtable + hash(sb, ino); 1040 + struct inode *old; 1041 + 1042 + inode->i_state |= I_LOCK|I_NEW; 1043 + while (1) { 1044 + spin_lock(&inode_lock); 1045 + old = find_inode_fast(sb, head, ino); 1046 + if (likely(!old)) { 1047 + hlist_add_head(&inode->i_hash, head); 1048 + spin_unlock(&inode_lock); 1049 + return 0; 1050 + } 1051 + __iget(old); 1052 + spin_unlock(&inode_lock); 1053 + wait_on_inode(old); 1054 + if (unlikely(!hlist_unhashed(&old->i_hash))) { 1055 + iput(old); 1056 + return -EBUSY; 1057 + } 1058 + iput(old); 1059 + } 1060 + } 1061 + 1062 + EXPORT_SYMBOL(insert_inode_locked); 1063 + 1064 + int insert_inode_locked4(struct inode *inode, unsigned long hashval, 1065 + int (*test)(struct inode *, void *), void *data) 1066 + { 1067 + struct super_block *sb = inode->i_sb; 1068 + struct hlist_head *head = inode_hashtable + hash(sb, hashval); 1069 + struct inode *old; 1070 + 1071 + inode->i_state |= I_LOCK|I_NEW; 1072 + 1073 + while (1) { 1074 + spin_lock(&inode_lock); 1075 + old = find_inode(sb, head, test, data); 1076 + if (likely(!old)) { 1077 + hlist_add_head(&inode->i_hash, head); 1078 + spin_unlock(&inode_lock); 1079 + return 0; 1080 + } 1081 + __iget(old); 1082 + spin_unlock(&inode_lock); 1083 + wait_on_inode(old); 1084 + if (unlikely(!hlist_unhashed(&old->i_hash))) { 1085 + iput(old); 1086 + return -EBUSY; 1087 + } 1088 + iput(old); 1089 + } 1090 + } 1091 + 1092 + EXPORT_SYMBOL(insert_inode_locked4); 1093 + 1094 /** 1095 * __insert_inode_hash - hash an inode 1096 * @inode: unhashed inode
fs/inotify.c fs/notify/inotify/inotify.c
+1 -1
fs/inotify_user.c fs/notify/inotify/inotify_user.c
··· 76 struct mutex ev_mutex; /* protects event queue */ 77 struct mutex up_mutex; /* synchronizes watch updates */ 78 struct list_head events; /* list of queued events */ 79 - atomic_t count; /* reference count */ 80 struct user_struct *user; /* user who opened this dev */ 81 struct inotify_handle *ih; /* inotify handle */ 82 struct fasync_struct *fa; /* async notification */ 83 unsigned int queue_size; /* size of the queue (bytes) */ 84 unsigned int event_count; /* number of pending events */ 85 unsigned int max_events; /* maximum number of events */
··· 76 struct mutex ev_mutex; /* protects event queue */ 77 struct mutex up_mutex; /* synchronizes watch updates */ 78 struct list_head events; /* list of queued events */ 79 struct user_struct *user; /* user who opened this dev */ 80 struct inotify_handle *ih; /* inotify handle */ 81 struct fasync_struct *fa; /* async notification */ 82 + atomic_t count; /* reference count */ 83 unsigned int queue_size; /* size of the queue (bytes) */ 84 unsigned int event_count; /* number of pending events */ 85 unsigned int max_events; /* maximum number of events */
+21 -8
fs/jfs/jfs_inode.c
··· 79 inode = new_inode(sb); 80 if (!inode) { 81 jfs_warn("ialloc: new_inode returned NULL!"); 82 - return ERR_PTR(-ENOMEM); 83 } 84 85 jfs_inode = JFS_IP(inode); ··· 90 jfs_warn("ialloc: diAlloc returned %d!", rc); 91 if (rc == -EIO) 92 make_bad_inode(inode); 93 - iput(inode); 94 - return ERR_PTR(rc); 95 } 96 97 inode->i_uid = current_fsuid(); ··· 117 * Allocate inode to quota. 118 */ 119 if (DQUOT_ALLOC_INODE(inode)) { 120 - DQUOT_DROP(inode); 121 - inode->i_flags |= S_NOQUOTA; 122 - inode->i_nlink = 0; 123 - iput(inode); 124 - return ERR_PTR(-EDQUOT); 125 } 126 127 inode->i_mode = mode; ··· 160 jfs_info("ialloc returns inode = 0x%p\n", inode); 161 162 return inode; 163 }
··· 79 inode = new_inode(sb); 80 if (!inode) { 81 jfs_warn("ialloc: new_inode returned NULL!"); 82 + rc = -ENOMEM; 83 + goto fail; 84 } 85 86 jfs_inode = JFS_IP(inode); ··· 89 jfs_warn("ialloc: diAlloc returned %d!", rc); 90 if (rc == -EIO) 91 make_bad_inode(inode); 92 + goto fail_put; 93 + } 94 + 95 + if (insert_inode_locked(inode) < 0) { 96 + rc = -EINVAL; 97 + goto fail_unlock; 98 } 99 100 inode->i_uid = current_fsuid(); ··· 112 * Allocate inode to quota. 113 */ 114 if (DQUOT_ALLOC_INODE(inode)) { 115 + rc = -EDQUOT; 116 + goto fail_drop; 117 } 118 119 inode->i_mode = mode; ··· 158 jfs_info("ialloc returns inode = 0x%p\n", inode); 159 160 return inode; 161 + 162 + fail_drop: 163 + DQUOT_DROP(inode); 164 + inode->i_flags |= S_NOQUOTA; 165 + fail_unlock: 166 + inode->i_nlink = 0; 167 + unlock_new_inode(inode); 168 + fail_put: 169 + iput(inode); 170 + fail: 171 + return ERR_PTR(rc); 172 }
+16 -8
fs/jfs/namei.c
··· 155 ip->i_fop = &jfs_file_operations; 156 ip->i_mapping->a_ops = &jfs_aops; 157 158 - insert_inode_hash(ip); 159 mark_inode_dirty(ip); 160 161 dip->i_ctime = dip->i_mtime = CURRENT_TIME; ··· 170 if (rc) { 171 free_ea_wmap(ip); 172 ip->i_nlink = 0; 173 iput(ip); 174 - } else 175 d_instantiate(dentry, ip); 176 177 out2: 178 free_UCSname(&dname); ··· 291 ip->i_op = &jfs_dir_inode_operations; 292 ip->i_fop = &jfs_dir_operations; 293 294 - insert_inode_hash(ip); 295 mark_inode_dirty(ip); 296 297 /* update parent directory inode */ ··· 307 if (rc) { 308 free_ea_wmap(ip); 309 ip->i_nlink = 0; 310 iput(ip); 311 - } else 312 d_instantiate(dentry, ip); 313 314 out2: 315 free_UCSname(&dname); ··· 1023 goto out3; 1024 } 1025 1026 - insert_inode_hash(ip); 1027 mark_inode_dirty(ip); 1028 1029 dip->i_ctime = dip->i_mtime = CURRENT_TIME; ··· 1042 if (rc) { 1043 free_ea_wmap(ip); 1044 ip->i_nlink = 0; 1045 iput(ip); 1046 - } else 1047 d_instantiate(dentry, ip); 1048 1049 out2: 1050 free_UCSname(&dname); ··· 1405 jfs_ip->dev = new_encode_dev(rdev); 1406 init_special_inode(ip, ip->i_mode, rdev); 1407 1408 - insert_inode_hash(ip); 1409 mark_inode_dirty(ip); 1410 1411 dir->i_ctime = dir->i_mtime = CURRENT_TIME; ··· 1422 if (rc) { 1423 free_ea_wmap(ip); 1424 ip->i_nlink = 0; 1425 iput(ip); 1426 - } else 1427 d_instantiate(dentry, ip); 1428 1429 out1: 1430 free_UCSname(&dname);
··· 155 ip->i_fop = &jfs_file_operations; 156 ip->i_mapping->a_ops = &jfs_aops; 157 158 mark_inode_dirty(ip); 159 160 dip->i_ctime = dip->i_mtime = CURRENT_TIME; ··· 171 if (rc) { 172 free_ea_wmap(ip); 173 ip->i_nlink = 0; 174 + unlock_new_inode(ip); 175 iput(ip); 176 + } else { 177 d_instantiate(dentry, ip); 178 + unlock_new_inode(ip); 179 + } 180 181 out2: 182 free_UCSname(&dname); ··· 289 ip->i_op = &jfs_dir_inode_operations; 290 ip->i_fop = &jfs_dir_operations; 291 292 mark_inode_dirty(ip); 293 294 /* update parent directory inode */ ··· 306 if (rc) { 307 free_ea_wmap(ip); 308 ip->i_nlink = 0; 309 + unlock_new_inode(ip); 310 iput(ip); 311 + } else { 312 d_instantiate(dentry, ip); 313 + unlock_new_inode(ip); 314 + } 315 316 out2: 317 free_UCSname(&dname); ··· 1019 goto out3; 1020 } 1021 1022 mark_inode_dirty(ip); 1023 1024 dip->i_ctime = dip->i_mtime = CURRENT_TIME; ··· 1039 if (rc) { 1040 free_ea_wmap(ip); 1041 ip->i_nlink = 0; 1042 + unlock_new_inode(ip); 1043 iput(ip); 1044 + } else { 1045 d_instantiate(dentry, ip); 1046 + unlock_new_inode(ip); 1047 + } 1048 1049 out2: 1050 free_UCSname(&dname); ··· 1399 jfs_ip->dev = new_encode_dev(rdev); 1400 init_special_inode(ip, ip->i_mode, rdev); 1401 1402 mark_inode_dirty(ip); 1403 1404 dir->i_ctime = dir->i_mtime = CURRENT_TIME; ··· 1417 if (rc) { 1418 free_ea_wmap(ip); 1419 ip->i_nlink = 0; 1420 + unlock_new_inode(ip); 1421 iput(ip); 1422 + } else { 1423 d_instantiate(dentry, ip); 1424 + unlock_new_inode(ip); 1425 + } 1426 1427 out1: 1428 free_UCSname(&dname);
+75 -40
fs/namei.c
··· 226 return -EACCES; 227 } 228 229 int inode_permission(struct inode *inode, int mask) 230 { 231 int retval; ··· 257 return -EACCES; 258 } 259 260 - /* Ordinary permission routines do not understand MAY_APPEND. */ 261 if (inode->i_op && inode->i_op->permission) 262 retval = inode->i_op->permission(inode, mask); 263 else ··· 274 } 275 276 /** 277 - * vfs_permission - check for access rights to a given path 278 - * @nd: lookup result that describes the path 279 - * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) 280 - * 281 - * Used to check for read/write/execute permissions on a path. 282 - * We use "fsuid" for this, letting us set arbitrary permissions 283 - * for filesystem access without changing the "normal" uids which 284 - * are used for other things. 285 - */ 286 - int vfs_permission(struct nameidata *nd, int mask) 287 - { 288 - return inode_permission(nd->path.dentry->d_inode, mask); 289 - } 290 - 291 - /** 292 * file_permission - check for additional access rights to a given file 293 * @file: file to check access rights for 294 * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) ··· 283 * 284 * Note: 285 * Do not use this function in new code. All access checks should 286 - * be done using vfs_permission(). 287 */ 288 int file_permission(struct file *file, int mask) 289 { ··· 521 return result; 522 } 523 524 - /* SMP-safe */ 525 - static __always_inline void 526 - walk_init_root(const char *name, struct nameidata *nd) 527 - { 528 - struct fs_struct *fs = current->fs; 529 - 530 - read_lock(&fs->lock); 531 - nd->path = fs->root; 532 - path_get(&fs->root); 533 - read_unlock(&fs->lock); 534 - } 535 - 536 /* 537 * Wrapper to retry pathname resolution whenever the underlying 538 * file system returns an ESTALE. ··· 558 goto fail; 559 560 if (*link == '/') { 561 path_put(&nd->path); 562 - walk_init_root(link, nd); 563 } 564 res = link_path_walk(link, nd); 565 if (nd->depth || res || nd->last_type!=LAST_NORM) 566 return res; ··· 848 nd->flags |= LOOKUP_CONTINUE; 849 err = exec_permission_lite(inode); 850 if (err == -EAGAIN) 851 - err = vfs_permission(nd, MAY_EXEC); 852 if (err) 853 break; 854 ··· 1483 return error; 1484 } 1485 1486 - int may_open(struct nameidata *nd, int acc_mode, int flag) 1487 { 1488 - struct dentry *dentry = nd->path.dentry; 1489 struct inode *inode = dentry->d_inode; 1490 int error; 1491 ··· 1506 if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { 1507 flag &= ~O_TRUNC; 1508 } else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) { 1509 - if (nd->path.mnt->mnt_flags & MNT_NODEV) 1510 return -EACCES; 1511 1512 flag &= ~O_TRUNC; 1513 } 1514 1515 - error = vfs_permission(nd, acc_mode); 1516 if (error) 1517 return error; 1518 /* ··· 1546 * Refuse to truncate files with mandatory locks held on them. 1547 */ 1548 error = locks_verify_locked(inode); 1549 if (!error) { 1550 DQUOT_INIT(inode); 1551 ··· 1579 1580 if (!IS_POSIXACL(dir->d_inode)) 1581 mode &= ~current->fs->umask; 1582 error = vfs_create(dir->d_inode, path->dentry, mode, nd); 1583 mutex_unlock(&dir->d_inode->i_mutex); 1584 dput(nd->path.dentry); 1585 nd->path.dentry = path->dentry; 1586 if (error) 1587 return error; 1588 /* Don't check for write permission, don't truncate */ 1589 - return may_open(nd, 0, flag & ~O_TRUNC); 1590 } 1591 1592 /* ··· 1776 if (error) 1777 goto exit; 1778 } 1779 - error = may_open(&nd, acc_mode, flag); 1780 if (error) { 1781 if (will_write) 1782 mnt_drop_write(nd.path.mnt); ··· 1996 error = mnt_want_write(nd.path.mnt); 1997 if (error) 1998 goto out_dput; 1999 switch (mode & S_IFMT) { 2000 case 0: case S_IFREG: 2001 error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); ··· 2011 error = vfs_mknod(nd.path.dentry->d_inode,dentry,mode,0); 2012 break; 2013 } 2014 mnt_drop_write(nd.path.mnt); 2015 out_dput: 2016 dput(dentry); ··· 2071 error = mnt_want_write(nd.path.mnt); 2072 if (error) 2073 goto out_dput; 2074 error = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode); 2075 mnt_drop_write(nd.path.mnt); 2076 out_dput: 2077 dput(dentry); ··· 2185 error = mnt_want_write(nd.path.mnt); 2186 if (error) 2187 goto exit3; 2188 error = vfs_rmdir(nd.path.dentry->d_inode, dentry); 2189 mnt_drop_write(nd.path.mnt); 2190 exit3: 2191 dput(dentry); ··· 2274 error = mnt_want_write(nd.path.mnt); 2275 if (error) 2276 goto exit2; 2277 error = vfs_unlink(nd.path.dentry->d_inode, dentry); 2278 mnt_drop_write(nd.path.mnt); 2279 exit2: 2280 dput(dentry); ··· 2359 error = mnt_want_write(nd.path.mnt); 2360 if (error) 2361 goto out_dput; 2362 error = vfs_symlink(nd.path.dentry->d_inode, dentry, from); 2363 mnt_drop_write(nd.path.mnt); 2364 out_dput: 2365 dput(dentry); ··· 2460 error = mnt_want_write(nd.path.mnt); 2461 if (error) 2462 goto out_dput; 2463 error = vfs_link(old_path.dentry, nd.path.dentry->d_inode, new_dentry); 2464 mnt_drop_write(nd.path.mnt); 2465 out_dput: 2466 dput(new_dentry); ··· 2700 error = mnt_want_write(oldnd.path.mnt); 2701 if (error) 2702 goto exit5; 2703 error = vfs_rename(old_dir->d_inode, old_dentry, 2704 new_dir->d_inode, new_dentry); 2705 mnt_drop_write(oldnd.path.mnt); 2706 exit5: 2707 dput(new_dentry); ··· 2776 /* get the link contents into pagecache */ 2777 static char *page_getlink(struct dentry * dentry, struct page **ppage) 2778 { 2779 - struct page * page; 2780 struct address_space *mapping = dentry->d_inode->i_mapping; 2781 page = read_mapping_page(mapping, 0, NULL); 2782 if (IS_ERR(page)) 2783 return (char*)page; 2784 *ppage = page; 2785 - return kmap(page); 2786 } 2787 2788 int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) ··· 2878 EXPORT_SYMBOL(kern_path); 2879 EXPORT_SYMBOL(vfs_path_lookup); 2880 EXPORT_SYMBOL(inode_permission); 2881 - EXPORT_SYMBOL(vfs_permission); 2882 EXPORT_SYMBOL(file_permission); 2883 EXPORT_SYMBOL(unlock_rename); 2884 EXPORT_SYMBOL(vfs_create); ··· 2893 EXPORT_SYMBOL(vfs_unlink); 2894 EXPORT_SYMBOL(dentry_unhash); 2895 EXPORT_SYMBOL(generic_readlink);
··· 226 return -EACCES; 227 } 228 229 + /** 230 + * inode_permission - check for access rights to a given inode 231 + * @inode: inode to check permission on 232 + * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) 233 + * 234 + * Used to check for read/write/execute permissions on an inode. 235 + * We use "fsuid" for this, letting us set arbitrary permissions 236 + * for filesystem access without changing the "normal" uids which 237 + * are used for other things. 238 + */ 239 int inode_permission(struct inode *inode, int mask) 240 { 241 int retval; ··· 247 return -EACCES; 248 } 249 250 if (inode->i_op && inode->i_op->permission) 251 retval = inode->i_op->permission(inode, mask); 252 else ··· 265 } 266 267 /** 268 * file_permission - check for additional access rights to a given file 269 * @file: file to check access rights for 270 * @mask: right to check for (%MAY_READ, %MAY_WRITE, %MAY_EXEC) ··· 289 * 290 * Note: 291 * Do not use this function in new code. All access checks should 292 + * be done using inode_permission(). 293 */ 294 int file_permission(struct file *file, int mask) 295 { ··· 527 return result; 528 } 529 530 /* 531 * Wrapper to retry pathname resolution whenever the underlying 532 * file system returns an ESTALE. ··· 576 goto fail; 577 578 if (*link == '/') { 579 + struct fs_struct *fs = current->fs; 580 + 581 path_put(&nd->path); 582 + 583 + read_lock(&fs->lock); 584 + nd->path = fs->root; 585 + path_get(&fs->root); 586 + read_unlock(&fs->lock); 587 } 588 + 589 res = link_path_walk(link, nd); 590 if (nd->depth || res || nd->last_type!=LAST_NORM) 591 return res; ··· 859 nd->flags |= LOOKUP_CONTINUE; 860 err = exec_permission_lite(inode); 861 if (err == -EAGAIN) 862 + err = inode_permission(nd->path.dentry->d_inode, 863 + MAY_EXEC); 864 if (err) 865 break; 866 ··· 1493 return error; 1494 } 1495 1496 + int may_open(struct path *path, int acc_mode, int flag) 1497 { 1498 + struct dentry *dentry = path->dentry; 1499 struct inode *inode = dentry->d_inode; 1500 int error; 1501 ··· 1516 if (S_ISFIFO(inode->i_mode) || S_ISSOCK(inode->i_mode)) { 1517 flag &= ~O_TRUNC; 1518 } else if (S_ISBLK(inode->i_mode) || S_ISCHR(inode->i_mode)) { 1519 + if (path->mnt->mnt_flags & MNT_NODEV) 1520 return -EACCES; 1521 1522 flag &= ~O_TRUNC; 1523 } 1524 1525 + error = inode_permission(inode, acc_mode); 1526 if (error) 1527 return error; 1528 /* ··· 1556 * Refuse to truncate files with mandatory locks held on them. 1557 */ 1558 error = locks_verify_locked(inode); 1559 + if (!error) 1560 + error = security_path_truncate(path, 0, 1561 + ATTR_MTIME|ATTR_CTIME|ATTR_OPEN); 1562 if (!error) { 1563 DQUOT_INIT(inode); 1564 ··· 1586 1587 if (!IS_POSIXACL(dir->d_inode)) 1588 mode &= ~current->fs->umask; 1589 + error = security_path_mknod(&nd->path, path->dentry, mode, 0); 1590 + if (error) 1591 + goto out_unlock; 1592 error = vfs_create(dir->d_inode, path->dentry, mode, nd); 1593 + out_unlock: 1594 mutex_unlock(&dir->d_inode->i_mutex); 1595 dput(nd->path.dentry); 1596 nd->path.dentry = path->dentry; 1597 if (error) 1598 return error; 1599 /* Don't check for write permission, don't truncate */ 1600 + return may_open(&nd->path, 0, flag & ~O_TRUNC); 1601 } 1602 1603 /* ··· 1779 if (error) 1780 goto exit; 1781 } 1782 + error = may_open(&nd.path, acc_mode, flag); 1783 if (error) { 1784 if (will_write) 1785 mnt_drop_write(nd.path.mnt); ··· 1999 error = mnt_want_write(nd.path.mnt); 2000 if (error) 2001 goto out_dput; 2002 + error = security_path_mknod(&nd.path, dentry, mode, dev); 2003 + if (error) 2004 + goto out_drop_write; 2005 switch (mode & S_IFMT) { 2006 case 0: case S_IFREG: 2007 error = vfs_create(nd.path.dentry->d_inode,dentry,mode,&nd); ··· 2011 error = vfs_mknod(nd.path.dentry->d_inode,dentry,mode,0); 2012 break; 2013 } 2014 + out_drop_write: 2015 mnt_drop_write(nd.path.mnt); 2016 out_dput: 2017 dput(dentry); ··· 2070 error = mnt_want_write(nd.path.mnt); 2071 if (error) 2072 goto out_dput; 2073 + error = security_path_mkdir(&nd.path, dentry, mode); 2074 + if (error) 2075 + goto out_drop_write; 2076 error = vfs_mkdir(nd.path.dentry->d_inode, dentry, mode); 2077 + out_drop_write: 2078 mnt_drop_write(nd.path.mnt); 2079 out_dput: 2080 dput(dentry); ··· 2180 error = mnt_want_write(nd.path.mnt); 2181 if (error) 2182 goto exit3; 2183 + error = security_path_rmdir(&nd.path, dentry); 2184 + if (error) 2185 + goto exit4; 2186 error = vfs_rmdir(nd.path.dentry->d_inode, dentry); 2187 + exit4: 2188 mnt_drop_write(nd.path.mnt); 2189 exit3: 2190 dput(dentry); ··· 2265 error = mnt_want_write(nd.path.mnt); 2266 if (error) 2267 goto exit2; 2268 + error = security_path_unlink(&nd.path, dentry); 2269 + if (error) 2270 + goto exit3; 2271 error = vfs_unlink(nd.path.dentry->d_inode, dentry); 2272 + exit3: 2273 mnt_drop_write(nd.path.mnt); 2274 exit2: 2275 dput(dentry); ··· 2346 error = mnt_want_write(nd.path.mnt); 2347 if (error) 2348 goto out_dput; 2349 + error = security_path_symlink(&nd.path, dentry, from); 2350 + if (error) 2351 + goto out_drop_write; 2352 error = vfs_symlink(nd.path.dentry->d_inode, dentry, from); 2353 + out_drop_write: 2354 mnt_drop_write(nd.path.mnt); 2355 out_dput: 2356 dput(dentry); ··· 2443 error = mnt_want_write(nd.path.mnt); 2444 if (error) 2445 goto out_dput; 2446 + error = security_path_link(old_path.dentry, &nd.path, new_dentry); 2447 + if (error) 2448 + goto out_drop_write; 2449 error = vfs_link(old_path.dentry, nd.path.dentry->d_inode, new_dentry); 2450 + out_drop_write: 2451 mnt_drop_write(nd.path.mnt); 2452 out_dput: 2453 dput(new_dentry); ··· 2679 error = mnt_want_write(oldnd.path.mnt); 2680 if (error) 2681 goto exit5; 2682 + error = security_path_rename(&oldnd.path, old_dentry, 2683 + &newnd.path, new_dentry); 2684 + if (error) 2685 + goto exit6; 2686 error = vfs_rename(old_dir->d_inode, old_dentry, 2687 new_dir->d_inode, new_dentry); 2688 + exit6: 2689 mnt_drop_write(oldnd.path.mnt); 2690 exit5: 2691 dput(new_dentry); ··· 2750 /* get the link contents into pagecache */ 2751 static char *page_getlink(struct dentry * dentry, struct page **ppage) 2752 { 2753 + char *kaddr; 2754 + struct page *page; 2755 struct address_space *mapping = dentry->d_inode->i_mapping; 2756 page = read_mapping_page(mapping, 0, NULL); 2757 if (IS_ERR(page)) 2758 return (char*)page; 2759 *ppage = page; 2760 + kaddr = kmap(page); 2761 + nd_terminate_link(kaddr, dentry->d_inode->i_size, PAGE_SIZE - 1); 2762 + return kaddr; 2763 } 2764 2765 int page_readlink(struct dentry *dentry, char __user *buffer, int buflen) ··· 2849 EXPORT_SYMBOL(kern_path); 2850 EXPORT_SYMBOL(vfs_path_lookup); 2851 EXPORT_SYMBOL(inode_permission); 2852 EXPORT_SYMBOL(file_permission); 2853 EXPORT_SYMBOL(unlock_rename); 2854 EXPORT_SYMBOL(vfs_create); ··· 2865 EXPORT_SYMBOL(vfs_unlink); 2866 EXPORT_SYMBOL(dentry_unhash); 2867 EXPORT_SYMBOL(generic_readlink); 2868 + 2869 + /* to be mentioned only in INIT_TASK */ 2870 + struct fs_struct init_fs = { 2871 + .count = ATOMIC_INIT(1), 2872 + .lock = __RW_LOCK_UNLOCKED(init_fs.lock), 2873 + .umask = 0022, 2874 + };
+1 -1
fs/namespace.c
··· 1990 if (!new_ns->root) { 1991 up_write(&namespace_sem); 1992 kfree(new_ns); 1993 - return ERR_PTR(-ENOMEM);; 1994 } 1995 spin_lock(&vfsmount_lock); 1996 list_add_tail(&new_ns->list, &new_ns->root->mnt_list);
··· 1990 if (!new_ns->root) { 1991 up_write(&namespace_sem); 1992 kfree(new_ns); 1993 + return ERR_PTR(-ENOMEM); 1994 } 1995 spin_lock(&vfsmount_lock); 1996 list_add_tail(&new_ns->list, &new_ns->root->mnt_list);
+3 -2
fs/nfsctl.c
··· 38 return ERR_PTR(error); 39 40 if (flags == O_RDWR) 41 - error = may_open(&nd,MAY_READ|MAY_WRITE,FMODE_READ|FMODE_WRITE); 42 else 43 - error = may_open(&nd, MAY_WRITE, FMODE_WRITE); 44 45 if (!error) 46 return dentry_open(nd.path.dentry, nd.path.mnt, flags,
··· 38 return ERR_PTR(error); 39 40 if (flags == O_RDWR) 41 + error = may_open(&nd.path, MAY_READ|MAY_WRITE, 42 + FMODE_READ|FMODE_WRITE); 43 else 44 + error = may_open(&nd.path, MAY_WRITE, FMODE_WRITE); 45 46 if (!error) 47 return dentry_open(nd.path.dentry, nd.path.mnt, flags,
+2
fs/notify/Kconfig
···
··· 1 + source "fs/notify/dnotify/Kconfig" 2 + source "fs/notify/inotify/Kconfig"
+2
fs/notify/Makefile
···
··· 1 + obj-y += dnotify/ 2 + obj-y += inotify/
+10
fs/notify/dnotify/Kconfig
···
··· 1 + config DNOTIFY 2 + bool "Dnotify support" 3 + default y 4 + help 5 + Dnotify is a directory-based per-fd file change notification system 6 + that uses signals to communicate events to user-space. There exist 7 + superior alternatives, but some applications may still rely on 8 + dnotify. 9 + 10 + If unsure, say Y.
+1
fs/notify/dnotify/Makefile
···
··· 1 + obj-$(CONFIG_DNOTIFY) += dnotify.o
+27
fs/notify/inotify/Kconfig
···
··· 1 + config INOTIFY 2 + bool "Inotify file change notification support" 3 + default y 4 + ---help--- 5 + Say Y here to enable inotify support. Inotify is a file change 6 + notification system and a replacement for dnotify. Inotify fixes 7 + numerous shortcomings in dnotify and introduces several new features 8 + including multiple file events, one-shot support, and unmount 9 + notification. 10 + 11 + For more information, see <file:Documentation/filesystems/inotify.txt> 12 + 13 + If unsure, say Y. 14 + 15 + config INOTIFY_USER 16 + bool "Inotify support for userspace" 17 + depends on INOTIFY 18 + default y 19 + ---help--- 20 + Say Y here to enable inotify support for userspace, including the 21 + associated system calls. Inotify allows monitoring of both files and 22 + directories via a single open fd. Events are read from the file 23 + descriptor, which is also select()- and poll()-able. 24 + 25 + For more information, see <file:Documentation/filesystems/inotify.txt> 26 + 27 + If unsure, say Y.
+2
fs/notify/inotify/Makefile
···
··· 1 + obj-$(CONFIG_INOTIFY) += inotify.o 2 + obj-$(CONFIG_INOTIFY_USER) += inotify_user.o
+5
fs/open.c
··· 272 goto put_write_and_out; 273 274 error = locks_verify_truncate(inode, NULL, length); 275 if (!error) { 276 DQUOT_INIT(inode); 277 error = do_truncate(path.dentry, length, 0, NULL); ··· 330 goto out_putf; 331 332 error = locks_verify_truncate(inode, file, length); 333 if (!error) 334 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); 335 out_putf:
··· 272 goto put_write_and_out; 273 274 error = locks_verify_truncate(inode, NULL, length); 275 + if (!error) 276 + error = security_path_truncate(&path, length, 0); 277 if (!error) { 278 DQUOT_INIT(inode); 279 error = do_truncate(path.dentry, length, 0, NULL); ··· 328 goto out_putf; 329 330 error = locks_verify_truncate(inode, file, length); 331 + if (!error) 332 + error = security_path_truncate(&file->f_path, length, 333 + ATTR_MTIME|ATTR_CTIME); 334 if (!error) 335 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file); 336 out_putf:
+10 -5
fs/reiserfs/inode.c
··· 1753 struct inode *inode) 1754 { 1755 struct super_block *sb; 1756 INITIALIZE_PATH(path_to_key); 1757 struct cpu_key key; 1758 struct item_head ih; ··· 1779 ih.ih_key.k_objectid = cpu_to_le32(reiserfs_get_unused_objectid(th)); 1780 if (!ih.ih_key.k_objectid) { 1781 err = -ENOMEM; 1782 goto out_bad_inode; 1783 } 1784 if (old_format_only(sb)) ··· 1868 } else { 1869 inode2sd(&sd, inode, inode->i_size); 1870 } 1871 - // these do not go to on-disk stat data 1872 - inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid); 1873 - 1874 // store in in-core inode the key of stat data and version all 1875 // object items will have (directory items will have old offset 1876 // format, other new objects will consist of new items) 1877 - memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE); 1878 if (old_format_only(sb) || S_ISDIR(mode) || S_ISLNK(mode)) 1879 set_inode_item_key_version(inode, KEY_FORMAT_3_5); 1880 else ··· 1934 reiserfs_mark_inode_private(inode); 1935 } 1936 1937 - insert_inode_hash(inode); 1938 reiserfs_update_sd(th, inode); 1939 reiserfs_check_path(&path_to_key); 1940 ··· 1960 out_inserted_sd: 1961 inode->i_nlink = 0; 1962 th->t_trans_id = 0; /* so the caller can't use this handle later */ 1963 1964 /* If we were inheriting an ACL, we need to release the lock so that 1965 * iput doesn't deadlock in reiserfs_delete_xattrs. The locking
··· 1753 struct inode *inode) 1754 { 1755 struct super_block *sb; 1756 + struct reiserfs_iget_args args; 1757 INITIALIZE_PATH(path_to_key); 1758 struct cpu_key key; 1759 struct item_head ih; ··· 1778 ih.ih_key.k_objectid = cpu_to_le32(reiserfs_get_unused_objectid(th)); 1779 if (!ih.ih_key.k_objectid) { 1780 err = -ENOMEM; 1781 + goto out_bad_inode; 1782 + } 1783 + args.objectid = inode->i_ino = le32_to_cpu(ih.ih_key.k_objectid); 1784 + memcpy(INODE_PKEY(inode), &(ih.ih_key), KEY_SIZE); 1785 + args.dirid = le32_to_cpu(ih.ih_key.k_dir_id); 1786 + if (insert_inode_locked4(inode, args.objectid, 1787 + reiserfs_find_actor, &args) < 0) { 1788 + err = -EINVAL; 1789 goto out_bad_inode; 1790 } 1791 if (old_format_only(sb)) ··· 1859 } else { 1860 inode2sd(&sd, inode, inode->i_size); 1861 } 1862 // store in in-core inode the key of stat data and version all 1863 // object items will have (directory items will have old offset 1864 // format, other new objects will consist of new items) 1865 if (old_format_only(sb) || S_ISDIR(mode) || S_ISLNK(mode)) 1866 set_inode_item_key_version(inode, KEY_FORMAT_3_5); 1867 else ··· 1929 reiserfs_mark_inode_private(inode); 1930 } 1931 1932 reiserfs_update_sd(th, inode); 1933 reiserfs_check_path(&path_to_key); 1934 ··· 1956 out_inserted_sd: 1957 inode->i_nlink = 0; 1958 th->t_trans_id = 0; /* so the caller can't use this handle later */ 1959 + unlock_new_inode(inode); /* OK to do even if we hadn't locked it */ 1960 1961 /* If we were inheriting an ACL, we need to release the lock so that 1962 * iput doesn't deadlock in reiserfs_delete_xattrs. The locking
+8
fs/reiserfs/namei.c
··· 646 err = journal_end(&th, dir->i_sb, jbegin_count); 647 if (err) 648 retval = err; 649 iput(inode); 650 goto out_failed; 651 } ··· 654 reiserfs_update_inode_transaction(dir); 655 656 d_instantiate(dentry, inode); 657 retval = journal_end(&th, dir->i_sb, jbegin_count); 658 659 out_failed: ··· 729 err = journal_end(&th, dir->i_sb, jbegin_count); 730 if (err) 731 retval = err; 732 iput(inode); 733 goto out_failed; 734 } 735 736 d_instantiate(dentry, inode); 737 retval = journal_end(&th, dir->i_sb, jbegin_count); 738 739 out_failed: ··· 816 err = journal_end(&th, dir->i_sb, jbegin_count); 817 if (err) 818 retval = err; 819 iput(inode); 820 goto out_failed; 821 } ··· 824 reiserfs_update_sd(&th, dir); 825 826 d_instantiate(dentry, inode); 827 retval = journal_end(&th, dir->i_sb, jbegin_count); 828 out_failed: 829 if (locked) ··· 1102 err = journal_end(&th, parent_dir->i_sb, jbegin_count); 1103 if (err) 1104 retval = err; 1105 iput(inode); 1106 goto out_failed; 1107 } 1108 1109 d_instantiate(dentry, inode); 1110 retval = journal_end(&th, parent_dir->i_sb, jbegin_count); 1111 out_failed: 1112 reiserfs_write_unlock(parent_dir->i_sb);
··· 646 err = journal_end(&th, dir->i_sb, jbegin_count); 647 if (err) 648 retval = err; 649 + unlock_new_inode(inode); 650 iput(inode); 651 goto out_failed; 652 } ··· 653 reiserfs_update_inode_transaction(dir); 654 655 d_instantiate(dentry, inode); 656 + unlock_new_inode(inode); 657 retval = journal_end(&th, dir->i_sb, jbegin_count); 658 659 out_failed: ··· 727 err = journal_end(&th, dir->i_sb, jbegin_count); 728 if (err) 729 retval = err; 730 + unlock_new_inode(inode); 731 iput(inode); 732 goto out_failed; 733 } 734 735 d_instantiate(dentry, inode); 736 + unlock_new_inode(inode); 737 retval = journal_end(&th, dir->i_sb, jbegin_count); 738 739 out_failed: ··· 812 err = journal_end(&th, dir->i_sb, jbegin_count); 813 if (err) 814 retval = err; 815 + unlock_new_inode(inode); 816 iput(inode); 817 goto out_failed; 818 } ··· 819 reiserfs_update_sd(&th, dir); 820 821 d_instantiate(dentry, inode); 822 + unlock_new_inode(inode); 823 retval = journal_end(&th, dir->i_sb, jbegin_count); 824 out_failed: 825 if (locked) ··· 1096 err = journal_end(&th, parent_dir->i_sb, jbegin_count); 1097 if (err) 1098 retval = err; 1099 + unlock_new_inode(inode); 1100 iput(inode); 1101 goto out_failed; 1102 } 1103 1104 d_instantiate(dentry, inode); 1105 + unlock_new_inode(inode); 1106 retval = journal_end(&th, parent_dir->i_sb, jbegin_count); 1107 out_failed: 1108 reiserfs_write_unlock(parent_dir->i_sb);
+8 -2
fs/seq_file.c
··· 389 } 390 EXPORT_SYMBOL(mangle_path); 391 392 - /* 393 - * return the absolute path of 'dentry' residing in mount 'mnt'. 394 */ 395 int seq_path(struct seq_file *m, struct path *path, char *esc) 396 {
··· 389 } 390 EXPORT_SYMBOL(mangle_path); 391 392 + /** 393 + * seq_path - seq_file interface to print a pathname 394 + * @m: the seq_file handle 395 + * @path: the struct path to print 396 + * @esc: set of characters to escape in the output 397 + * 398 + * return the absolute path of 'path', as represented by the 399 + * dentry / mnt pair in the path parameter. 400 */ 401 int seq_path(struct seq_file *m, struct path *path, char *esc) 402 {
+5 -1
fs/sysv/inode.c
··· 27 #include <linux/init.h> 28 #include <linux/buffer_head.h> 29 #include <linux/vfs.h> 30 #include <asm/byteorder.h> 31 #include "sysv.h" 32 ··· 164 if (inode->i_blocks) { 165 inode->i_op = &sysv_symlink_inode_operations; 166 inode->i_mapping->a_ops = &sysv_aops; 167 - } else 168 inode->i_op = &sysv_fast_symlink_inode_operations; 169 } else 170 init_special_inode(inode, inode->i_mode, rdev); 171 }
··· 27 #include <linux/init.h> 28 #include <linux/buffer_head.h> 29 #include <linux/vfs.h> 30 + #include <linux/namei.h> 31 #include <asm/byteorder.h> 32 #include "sysv.h" 33 ··· 163 if (inode->i_blocks) { 164 inode->i_op = &sysv_symlink_inode_operations; 165 inode->i_mapping->a_ops = &sysv_aops; 166 + } else { 167 inode->i_op = &sysv_fast_symlink_inode_operations; 168 + nd_terminate_link(SYSV_I(inode)->i_data, inode->i_size, 169 + sizeof(SYSV_I(inode)->i_data) - 1); 170 + } 171 } else 172 init_special_inode(inode, inode->i_mode, rdev); 173 }
+14 -7
include/linux/dcache.h
··· 75 return end_name_hash(hash); 76 } 77 78 - struct dcookie_struct; 79 - 80 - #define DNAME_INLINE_LEN_MIN 36 81 82 struct dentry { 83 atomic_t d_count; 84 unsigned int d_flags; /* protected by d_lock */ 85 spinlock_t d_lock; /* per dentry lock */ 86 struct inode *d_inode; /* Where the name belongs to - NULL is 87 * negative */ 88 /* ··· 115 struct dentry_operations *d_op; 116 struct super_block *d_sb; /* The root of the dentry tree */ 117 void *d_fsdata; /* fs-specific data */ 118 - #ifdef CONFIG_PROFILING 119 - struct dcookie_struct *d_cookie; /* cookie, if any */ 120 - #endif 121 - int d_mounted; 122 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */ 123 }; 124 ··· 181 #define DCACHE_UNHASHED 0x0010 182 183 #define DCACHE_INOTIFY_PARENT_WATCHED 0x0020 /* Parent inode is watched */ 184 185 extern spinlock_t dcache_lock; 186 extern seqlock_t rename_lock;
··· 75 return end_name_hash(hash); 76 } 77 78 + /* 79 + * Try to keep struct dentry aligned on 64 byte cachelines (this will 80 + * give reasonable cacheline footprint with larger lines without the 81 + * large memory footprint increase). 82 + */ 83 + #ifdef CONFIG_64BIT 84 + #define DNAME_INLINE_LEN_MIN 32 /* 192 bytes */ 85 + #else 86 + #define DNAME_INLINE_LEN_MIN 40 /* 128 bytes */ 87 + #endif 88 89 struct dentry { 90 atomic_t d_count; 91 unsigned int d_flags; /* protected by d_lock */ 92 spinlock_t d_lock; /* per dentry lock */ 93 + int d_mounted; 94 struct inode *d_inode; /* Where the name belongs to - NULL is 95 * negative */ 96 /* ··· 107 struct dentry_operations *d_op; 108 struct super_block *d_sb; /* The root of the dentry tree */ 109 void *d_fsdata; /* fs-specific data */ 110 + 111 unsigned char d_iname[DNAME_INLINE_LEN_MIN]; /* small names */ 112 }; 113 ··· 176 #define DCACHE_UNHASHED 0x0010 177 178 #define DCACHE_INOTIFY_PARENT_WATCHED 0x0020 /* Parent inode is watched */ 179 + 180 + #define DCACHE_COOKIE 0x0040 /* For use by dcookie subsystem */ 181 182 extern spinlock_t dcache_lock; 183 extern seqlock_t rename_lock;
-2
include/linux/fdtable.h
··· 57 58 #define files_fdtable(files) (rcu_dereference((files)->fdt)) 59 60 - extern struct kmem_cache *filp_cachep; 61 - 62 struct file_operations; 63 struct vfsmount; 64 struct dentry;
··· 57 58 #define files_fdtable(files) (rcu_dereference((files)->fdt)) 59 60 struct file_operations; 61 struct vfsmount; 62 struct dentry;
+12 -12
include/linux/fs.h
··· 21 22 /* Fixed constants first: */ 23 #undef NR_OPEN 24 - extern int sysctl_nr_open; 25 #define INR_OPEN 1024 /* Initial setting for nfile rlimits */ 26 27 #define BLOCK_SIZE_BITS 10 ··· 37 int nr_free_files; /* read only */ 38 int max_files; /* tunable */ 39 }; 40 - extern struct files_stat_struct files_stat; 41 - extern int get_max_files(void); 42 43 struct inodes_stat_t { 44 int nr_inodes; 45 int nr_unused; 46 int dummy[5]; /* padding for sysctl ABI compatibility */ 47 }; 48 - extern struct inodes_stat_t inodes_stat; 49 50 - extern int leases_enable, lease_break_time; 51 - 52 - #ifdef CONFIG_DNOTIFY 53 - extern int dir_notify_enable; 54 - #endif 55 56 #define NR_FILE 8192 /* this can well be larger on a larger system */ 57 ··· 320 extern void __init inode_init(void); 321 extern void __init inode_init_early(void); 322 extern void __init files_init(unsigned long); 323 324 struct buffer_head; 325 typedef int (get_block_t)(struct inode *inode, sector_t iblock, ··· 1212 /* 1213 * VFS helper functions.. 1214 */ 1215 - extern int vfs_permission(struct nameidata *, int); 1216 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *); 1217 extern int vfs_mkdir(struct inode *, struct dentry *, int); 1218 extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); ··· 1309 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 1310 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1311 int (*check_flags)(int); 1312 - int (*dir_notify)(struct file *filp, unsigned long arg); 1313 int (*flock) (struct file *, int, struct file_lock *); 1314 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1315 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); ··· 1867 1868 extern struct file *do_filp_open(int dfd, const char *pathname, 1869 int open_flag, int mode); 1870 - extern int may_open(struct nameidata *, int, int); 1871 1872 extern int kernel_read(struct file *, unsigned long, char *, unsigned long); 1873 extern struct file * open_exec(const char *); ··· 1902 1903 extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *); 1904 extern struct inode * iget_locked(struct super_block *, unsigned long); 1905 extern void unlock_new_inode(struct inode *); 1906 1907 extern void __iget(struct inode * inode);
··· 21 22 /* Fixed constants first: */ 23 #undef NR_OPEN 24 #define INR_OPEN 1024 /* Initial setting for nfile rlimits */ 25 26 #define BLOCK_SIZE_BITS 10 ··· 38 int nr_free_files; /* read only */ 39 int max_files; /* tunable */ 40 }; 41 42 struct inodes_stat_t { 43 int nr_inodes; 44 int nr_unused; 45 int dummy[5]; /* padding for sysctl ABI compatibility */ 46 }; 47 48 49 #define NR_FILE 8192 /* this can well be larger on a larger system */ 50 ··· 329 extern void __init inode_init(void); 330 extern void __init inode_init_early(void); 331 extern void __init files_init(unsigned long); 332 + 333 + extern struct files_stat_struct files_stat; 334 + extern int get_max_files(void); 335 + extern int sysctl_nr_open; 336 + extern struct inodes_stat_t inodes_stat; 337 + extern int leases_enable, lease_break_time; 338 + #ifdef CONFIG_DNOTIFY 339 + extern int dir_notify_enable; 340 + #endif 341 342 struct buffer_head; 343 typedef int (get_block_t)(struct inode *inode, sector_t iblock, ··· 1212 /* 1213 * VFS helper functions.. 1214 */ 1215 extern int vfs_create(struct inode *, struct dentry *, int, struct nameidata *); 1216 extern int vfs_mkdir(struct inode *, struct dentry *, int); 1217 extern int vfs_mknod(struct inode *, struct dentry *, int, dev_t); ··· 1310 ssize_t (*sendpage) (struct file *, struct page *, int, size_t, loff_t *, int); 1311 unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); 1312 int (*check_flags)(int); 1313 int (*flock) (struct file *, int, struct file_lock *); 1314 ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); 1315 ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); ··· 1869 1870 extern struct file *do_filp_open(int dfd, const char *pathname, 1871 int open_flag, int mode); 1872 + extern int may_open(struct path *, int, int); 1873 1874 extern int kernel_read(struct file *, unsigned long, char *, unsigned long); 1875 extern struct file * open_exec(const char *); ··· 1904 1905 extern struct inode * iget5_locked(struct super_block *, unsigned long, int (*test)(struct inode *, void *), int (*set)(struct inode *, void *), void *); 1906 extern struct inode * iget_locked(struct super_block *, unsigned long); 1907 + extern int insert_inode_locked4(struct inode *, unsigned long, int (*test)(struct inode *, void *), void *); 1908 + extern int insert_inode_locked(struct inode *); 1909 extern void unlock_new_inode(struct inode *); 1910 1911 extern void __iget(struct inode * inode);
-6
include/linux/fs_struct.h
··· 10 struct path root, pwd; 11 }; 12 13 - #define INIT_FS { \ 14 - .count = ATOMIC_INIT(1), \ 15 - .lock = RW_LOCK_UNLOCKED, \ 16 - .umask = 0022, \ 17 - } 18 - 19 extern struct kmem_cache *fs_cachep; 20 21 extern void exit_fs(struct task_struct *);
··· 10 struct path root, pwd; 11 }; 12 13 extern struct kmem_cache *fs_cachep; 14 15 extern void exit_fs(struct task_struct *);
+1
include/linux/init_task.h
··· 12 #include <net/net_namespace.h> 13 14 extern struct files_struct init_files; 15 16 #define INIT_KIOCTX(name, which_mm) \ 17 { \
··· 12 #include <net/net_namespace.h> 13 14 extern struct files_struct init_files; 15 + extern struct fs_struct init_fs; 16 17 #define INIT_KIOCTX(name, which_mm) \ 18 { \
+5
include/linux/namei.h
··· 94 return nd->saved_names[nd->depth]; 95 } 96 97 #endif /* _LINUX_NAMEI_H */
··· 94 return nd->saved_names[nd->depth]; 95 } 96 97 + static inline void nd_terminate_link(void *name, size_t len, size_t maxlen) 98 + { 99 + ((char *) name)[min(len, maxlen)] = '\0'; 100 + } 101 + 102 #endif /* _LINUX_NAMEI_H */
+137
include/linux/security.h
··· 335 * @dir contains the inode structure of the parent directory of the new link. 336 * @new_dentry contains the dentry structure for the new link. 337 * Return 0 if permission is granted. 338 * @inode_unlink: 339 * Check the permission to remove a hard link to a file. 340 * @dir contains the inode structure of parent directory of the file. 341 * @dentry contains the dentry structure for file to be unlinked. 342 * Return 0 if permission is granted. 343 * @inode_symlink: 344 * Check the permission to create a symbolic link to a file. 345 * @dir contains the inode structure of parent directory of the symbolic link. 346 * @dentry contains the dentry structure of the symbolic link. 347 * @old_name contains the pathname of file. 348 * Return 0 if permission is granted. ··· 373 * @dentry contains the dentry structure of new directory. 374 * @mode contains the mode of new directory. 375 * Return 0 if permission is granted. 376 * @inode_rmdir: 377 * Check the permission to remove a directory. 378 * @dir contains the inode structure of parent of the directory to be removed. 379 * @dentry contains the dentry structure of directory to be removed. 380 * Return 0 if permission is granted. 381 * @inode_mknod: ··· 402 * @mode contains the mode of the new file. 403 * @dev contains the device number. 404 * Return 0 if permission is granted. 405 * @inode_rename: 406 * Check for permission to rename a file or directory. 407 * @old_dir contains the inode structure for parent of the old link. 408 * @old_dentry contains the dentry structure of the old link. 409 * @new_dir contains the inode structure for parent of the new link. 410 * @new_dentry contains the dentry structure of the new link. 411 * Return 0 if permission is granted. 412 * @inode_readlink: ··· 452 * operations, transferring disk quotas, etc). 453 * @dentry contains the dentry structure for the file. 454 * @attr is the iattr structure containing the new file attributes. 455 * Return 0 if permission is granted. 456 * @inode_getattr: 457 * Check permission before obtaining file attributes. ··· 1386 void (*sb_clone_mnt_opts) (const struct super_block *oldsb, 1387 struct super_block *newsb); 1388 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts); 1389 1390 int (*inode_alloc_security) (struct inode *inode); 1391 void (*inode_free_security) (struct inode *inode); ··· 2776 } 2777 2778 #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 2779 2780 #ifdef CONFIG_KEYS 2781 #ifdef CONFIG_SECURITY
··· 335 * @dir contains the inode structure of the parent directory of the new link. 336 * @new_dentry contains the dentry structure for the new link. 337 * Return 0 if permission is granted. 338 + * @path_link: 339 + * Check permission before creating a new hard link to a file. 340 + * @old_dentry contains the dentry structure for an existing link 341 + * to the file. 342 + * @new_dir contains the path structure of the parent directory of 343 + * the new link. 344 + * @new_dentry contains the dentry structure for the new link. 345 + * Return 0 if permission is granted. 346 * @inode_unlink: 347 * Check the permission to remove a hard link to a file. 348 * @dir contains the inode structure of parent directory of the file. 349 * @dentry contains the dentry structure for file to be unlinked. 350 * Return 0 if permission is granted. 351 + * @path_unlink: 352 + * Check the permission to remove a hard link to a file. 353 + * @dir contains the path structure of parent directory of the file. 354 + * @dentry contains the dentry structure for file to be unlinked. 355 + * Return 0 if permission is granted. 356 * @inode_symlink: 357 * Check the permission to create a symbolic link to a file. 358 * @dir contains the inode structure of parent directory of the symbolic link. 359 + * @dentry contains the dentry structure of the symbolic link. 360 + * @old_name contains the pathname of file. 361 + * Return 0 if permission is granted. 362 + * @path_symlink: 363 + * Check the permission to create a symbolic link to a file. 364 + * @dir contains the path structure of parent directory of 365 + * the symbolic link. 366 * @dentry contains the dentry structure of the symbolic link. 367 * @old_name contains the pathname of file. 368 * Return 0 if permission is granted. ··· 353 * @dentry contains the dentry structure of new directory. 354 * @mode contains the mode of new directory. 355 * Return 0 if permission is granted. 356 + * @path_mkdir: 357 + * Check permissions to create a new directory in the existing directory 358 + * associated with path strcture @path. 359 + * @dir containst the path structure of parent of the directory 360 + * to be created. 361 + * @dentry contains the dentry structure of new directory. 362 + * @mode contains the mode of new directory. 363 + * Return 0 if permission is granted. 364 * @inode_rmdir: 365 * Check the permission to remove a directory. 366 * @dir contains the inode structure of parent of the directory to be removed. 367 + * @dentry contains the dentry structure of directory to be removed. 368 + * Return 0 if permission is granted. 369 + * @path_rmdir: 370 + * Check the permission to remove a directory. 371 + * @dir contains the path structure of parent of the directory to be 372 + * removed. 373 * @dentry contains the dentry structure of directory to be removed. 374 * Return 0 if permission is granted. 375 * @inode_mknod: ··· 368 * @mode contains the mode of the new file. 369 * @dev contains the device number. 370 * Return 0 if permission is granted. 371 + * @path_mknod: 372 + * Check permissions when creating a file. Note that this hook is called 373 + * even if mknod operation is being done for a regular file. 374 + * @dir contains the path structure of parent of the new file. 375 + * @dentry contains the dentry structure of the new file. 376 + * @mode contains the mode of the new file. 377 + * @dev contains the undecoded device number. Use new_decode_dev() to get 378 + * the decoded device number. 379 + * Return 0 if permission is granted. 380 * @inode_rename: 381 * Check for permission to rename a file or directory. 382 * @old_dir contains the inode structure for parent of the old link. 383 * @old_dentry contains the dentry structure of the old link. 384 * @new_dir contains the inode structure for parent of the new link. 385 + * @new_dentry contains the dentry structure of the new link. 386 + * Return 0 if permission is granted. 387 + * @path_rename: 388 + * Check for permission to rename a file or directory. 389 + * @old_dir contains the path structure for parent of the old link. 390 + * @old_dentry contains the dentry structure of the old link. 391 + * @new_dir contains the path structure for parent of the new link. 392 * @new_dentry contains the dentry structure of the new link. 393 * Return 0 if permission is granted. 394 * @inode_readlink: ··· 402 * operations, transferring disk quotas, etc). 403 * @dentry contains the dentry structure for the file. 404 * @attr is the iattr structure containing the new file attributes. 405 + * Return 0 if permission is granted. 406 + * @path_truncate: 407 + * Check permission before truncating a file. 408 + * @path contains the path structure for the file. 409 + * @length is the new length of the file. 410 + * @time_attrs is the flags passed to do_truncate(). 411 * Return 0 if permission is granted. 412 * @inode_getattr: 413 * Check permission before obtaining file attributes. ··· 1330 void (*sb_clone_mnt_opts) (const struct super_block *oldsb, 1331 struct super_block *newsb); 1332 int (*sb_parse_opts_str) (char *options, struct security_mnt_opts *opts); 1333 + 1334 + #ifdef CONFIG_SECURITY_PATH 1335 + int (*path_unlink) (struct path *dir, struct dentry *dentry); 1336 + int (*path_mkdir) (struct path *dir, struct dentry *dentry, int mode); 1337 + int (*path_rmdir) (struct path *dir, struct dentry *dentry); 1338 + int (*path_mknod) (struct path *dir, struct dentry *dentry, int mode, 1339 + unsigned int dev); 1340 + int (*path_truncate) (struct path *path, loff_t length, 1341 + unsigned int time_attrs); 1342 + int (*path_symlink) (struct path *dir, struct dentry *dentry, 1343 + const char *old_name); 1344 + int (*path_link) (struct dentry *old_dentry, struct path *new_dir, 1345 + struct dentry *new_dentry); 1346 + int (*path_rename) (struct path *old_dir, struct dentry *old_dentry, 1347 + struct path *new_dir, struct dentry *new_dentry); 1348 + #endif 1349 1350 int (*inode_alloc_security) (struct inode *inode); 1351 void (*inode_free_security) (struct inode *inode); ··· 2704 } 2705 2706 #endif /* CONFIG_SECURITY_NETWORK_XFRM */ 2707 + 2708 + #ifdef CONFIG_SECURITY_PATH 2709 + int security_path_unlink(struct path *dir, struct dentry *dentry); 2710 + int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode); 2711 + int security_path_rmdir(struct path *dir, struct dentry *dentry); 2712 + int security_path_mknod(struct path *dir, struct dentry *dentry, int mode, 2713 + unsigned int dev); 2714 + int security_path_truncate(struct path *path, loff_t length, 2715 + unsigned int time_attrs); 2716 + int security_path_symlink(struct path *dir, struct dentry *dentry, 2717 + const char *old_name); 2718 + int security_path_link(struct dentry *old_dentry, struct path *new_dir, 2719 + struct dentry *new_dentry); 2720 + int security_path_rename(struct path *old_dir, struct dentry *old_dentry, 2721 + struct path *new_dir, struct dentry *new_dentry); 2722 + #else /* CONFIG_SECURITY_PATH */ 2723 + static inline int security_path_unlink(struct path *dir, struct dentry *dentry) 2724 + { 2725 + return 0; 2726 + } 2727 + 2728 + static inline int security_path_mkdir(struct path *dir, struct dentry *dentry, 2729 + int mode) 2730 + { 2731 + return 0; 2732 + } 2733 + 2734 + static inline int security_path_rmdir(struct path *dir, struct dentry *dentry) 2735 + { 2736 + return 0; 2737 + } 2738 + 2739 + static inline int security_path_mknod(struct path *dir, struct dentry *dentry, 2740 + int mode, unsigned int dev) 2741 + { 2742 + return 0; 2743 + } 2744 + 2745 + static inline int security_path_truncate(struct path *path, loff_t length, 2746 + unsigned int time_attrs) 2747 + { 2748 + return 0; 2749 + } 2750 + 2751 + static inline int security_path_symlink(struct path *dir, struct dentry *dentry, 2752 + const char *old_name) 2753 + { 2754 + return 0; 2755 + } 2756 + 2757 + static inline int security_path_link(struct dentry *old_dentry, 2758 + struct path *new_dir, 2759 + struct dentry *new_dentry) 2760 + { 2761 + return 0; 2762 + } 2763 + 2764 + static inline int security_path_rename(struct path *old_dir, 2765 + struct dentry *old_dentry, 2766 + struct path *new_dir, 2767 + struct dentry *new_dentry) 2768 + { 2769 + return 0; 2770 + } 2771 + #endif /* CONFIG_SECURITY_PATH */ 2772 2773 #ifdef CONFIG_KEYS 2774 #ifdef CONFIG_SECURITY
+4
net/unix/af_unix.c
··· 836 err = mnt_want_write(nd.path.mnt); 837 if (err) 838 goto out_mknod_dput; 839 err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0); 840 mnt_drop_write(nd.path.mnt); 841 if (err) 842 goto out_mknod_dput;
··· 836 err = mnt_want_write(nd.path.mnt); 837 if (err) 838 goto out_mknod_dput; 839 + err = security_path_mknod(&nd.path, dentry, mode, 0); 840 + if (err) 841 + goto out_mknod_drop_write; 842 err = vfs_mknod(nd.path.dentry->d_inode, dentry, mode, 0); 843 + out_mknod_drop_write: 844 mnt_drop_write(nd.path.mnt); 845 if (err) 846 goto out_mknod_dput;
+9
security/Kconfig
··· 81 IPSec. 82 If you are unsure how to answer this question, answer N. 83 84 config SECURITY_FILE_CAPABILITIES 85 bool "File POSIX Capabilities" 86 default n
··· 81 IPSec. 82 If you are unsure how to answer this question, answer N. 83 84 + config SECURITY_PATH 85 + bool "Security hooks for pathname based access control" 86 + depends on SECURITY 87 + help 88 + This enables the security hooks for pathname based access control. 89 + If enabled, a security module can use these hooks to 90 + implement pathname based access controls. 91 + If you are unsure how to answer this question, answer N. 92 + 93 config SECURITY_FILE_CAPABILITIES 94 bool "File POSIX Capabilities" 95 default n
+57
security/capability.c
··· 263 *secid = 0; 264 } 265 266 static int cap_file_permission(struct file *file, int mask) 267 { 268 return 0; ··· 930 set_to_cap_if_null(ops, inode_setsecurity); 931 set_to_cap_if_null(ops, inode_listsecurity); 932 set_to_cap_if_null(ops, inode_getsecid); 933 set_to_cap_if_null(ops, file_permission); 934 set_to_cap_if_null(ops, file_alloc_security); 935 set_to_cap_if_null(ops, file_free_security);
··· 263 *secid = 0; 264 } 265 266 + #ifdef CONFIG_SECURITY_PATH 267 + static int cap_path_mknod(struct path *dir, struct dentry *dentry, int mode, 268 + unsigned int dev) 269 + { 270 + return 0; 271 + } 272 + 273 + static int cap_path_mkdir(struct path *dir, struct dentry *dentry, int mode) 274 + { 275 + return 0; 276 + } 277 + 278 + static int cap_path_rmdir(struct path *dir, struct dentry *dentry) 279 + { 280 + return 0; 281 + } 282 + 283 + static int cap_path_unlink(struct path *dir, struct dentry *dentry) 284 + { 285 + return 0; 286 + } 287 + 288 + static int cap_path_symlink(struct path *dir, struct dentry *dentry, 289 + const char *old_name) 290 + { 291 + return 0; 292 + } 293 + 294 + static int cap_path_link(struct dentry *old_dentry, struct path *new_dir, 295 + struct dentry *new_dentry) 296 + { 297 + return 0; 298 + } 299 + 300 + static int cap_path_rename(struct path *old_path, struct dentry *old_dentry, 301 + struct path *new_path, struct dentry *new_dentry) 302 + { 303 + return 0; 304 + } 305 + 306 + static int cap_path_truncate(struct path *path, loff_t length, 307 + unsigned int time_attrs) 308 + { 309 + return 0; 310 + } 311 + #endif 312 + 313 static int cap_file_permission(struct file *file, int mask) 314 { 315 return 0; ··· 883 set_to_cap_if_null(ops, inode_setsecurity); 884 set_to_cap_if_null(ops, inode_listsecurity); 885 set_to_cap_if_null(ops, inode_getsecid); 886 + #ifdef CONFIG_SECURITY_PATH 887 + set_to_cap_if_null(ops, path_mknod); 888 + set_to_cap_if_null(ops, path_mkdir); 889 + set_to_cap_if_null(ops, path_rmdir); 890 + set_to_cap_if_null(ops, path_unlink); 891 + set_to_cap_if_null(ops, path_symlink); 892 + set_to_cap_if_null(ops, path_link); 893 + set_to_cap_if_null(ops, path_rename); 894 + set_to_cap_if_null(ops, path_truncate); 895 + #endif 896 set_to_cap_if_null(ops, file_permission); 897 set_to_cap_if_null(ops, file_alloc_security); 898 set_to_cap_if_null(ops, file_free_security);
+66
security/security.c
··· 355 } 356 EXPORT_SYMBOL(security_inode_init_security); 357 358 int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) 359 { 360 if (unlikely(IS_PRIVATE(dir)))
··· 355 } 356 EXPORT_SYMBOL(security_inode_init_security); 357 358 + #ifdef CONFIG_SECURITY_PATH 359 + int security_path_mknod(struct path *path, struct dentry *dentry, int mode, 360 + unsigned int dev) 361 + { 362 + if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 363 + return 0; 364 + return security_ops->path_mknod(path, dentry, mode, dev); 365 + } 366 + EXPORT_SYMBOL(security_path_mknod); 367 + 368 + int security_path_mkdir(struct path *path, struct dentry *dentry, int mode) 369 + { 370 + if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 371 + return 0; 372 + return security_ops->path_mkdir(path, dentry, mode); 373 + } 374 + 375 + int security_path_rmdir(struct path *path, struct dentry *dentry) 376 + { 377 + if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 378 + return 0; 379 + return security_ops->path_rmdir(path, dentry); 380 + } 381 + 382 + int security_path_unlink(struct path *path, struct dentry *dentry) 383 + { 384 + if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 385 + return 0; 386 + return security_ops->path_unlink(path, dentry); 387 + } 388 + 389 + int security_path_symlink(struct path *path, struct dentry *dentry, 390 + const char *old_name) 391 + { 392 + if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 393 + return 0; 394 + return security_ops->path_symlink(path, dentry, old_name); 395 + } 396 + 397 + int security_path_link(struct dentry *old_dentry, struct path *new_dir, 398 + struct dentry *new_dentry) 399 + { 400 + if (unlikely(IS_PRIVATE(old_dentry->d_inode))) 401 + return 0; 402 + return security_ops->path_link(old_dentry, new_dir, new_dentry); 403 + } 404 + 405 + int security_path_rename(struct path *old_dir, struct dentry *old_dentry, 406 + struct path *new_dir, struct dentry *new_dentry) 407 + { 408 + if (unlikely(IS_PRIVATE(old_dentry->d_inode) || 409 + (new_dentry->d_inode && IS_PRIVATE(new_dentry->d_inode)))) 410 + return 0; 411 + return security_ops->path_rename(old_dir, old_dentry, new_dir, 412 + new_dentry); 413 + } 414 + 415 + int security_path_truncate(struct path *path, loff_t length, 416 + unsigned int time_attrs) 417 + { 418 + if (unlikely(IS_PRIVATE(path->dentry->d_inode))) 419 + return 0; 420 + return security_ops->path_truncate(path, length, time_attrs); 421 + } 422 + #endif 423 + 424 int security_inode_create(struct inode *dir, struct dentry *dentry, int mode) 425 { 426 if (unlikely(IS_PRIVATE(dir)))