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