Merge branch 'vfs' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl

* 'vfs' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/bkl: (30 commits)
BKL: remove BKL from freevxfs
BKL: remove BKL from qnx4
autofs4: Only declare function when CONFIG_COMPAT is defined
autofs: Only declare function when CONFIG_COMPAT is defined
ncpfs: Lock socket in ncpfs while setting its callbacks
fs/locks.c: prepare for BKL removal
BKL: Remove BKL from ncpfs
BKL: Remove BKL from OCFS2
BKL: Remove BKL from squashfs
BKL: Remove BKL from jffs2
BKL: Remove BKL from ecryptfs
BKL: Remove BKL from afs
BKL: Remove BKL from USB gadgetfs
BKL: Remove BKL from autofs4
BKL: Remove BKL from isofs
BKL: Remove BKL from fat
BKL: Remove BKL from ext2 filesystem
BKL: Remove BKL from do_new_mount()
BKL: Remove BKL from cgroup
BKL: Remove BKL from NTFS
...

+700 -720
-1
drivers/usb/gadget/inode.c
··· 33 33 #include <linux/sched.h> 34 34 #include <linux/slab.h> 35 35 #include <linux/poll.h> 36 - #include <linux/smp_lock.h> 37 36 38 37 #include <linux/device.h> 39 38 #include <linux/moduleparam.h>
+7 -1
fs/adfs/super.c
··· 352 352 struct adfs_sb_info *asb; 353 353 struct inode *root; 354 354 355 + lock_kernel(); 356 + 355 357 sb->s_flags |= MS_NODIRATIME; 356 358 357 359 asb = kzalloc(sizeof(*asb), GFP_KERNEL); 358 - if (!asb) 360 + if (!asb) { 361 + unlock_kernel(); 359 362 return -ENOMEM; 363 + } 360 364 sb->s_fs_info = asb; 361 365 362 366 /* set default options */ ··· 478 474 goto error; 479 475 } else 480 476 sb->s_root->d_op = &adfs_dentry_operations; 477 + unlock_kernel(); 481 478 return 0; 482 479 483 480 error_free_bh: ··· 486 481 error: 487 482 sb->s_fs_info = NULL; 488 483 kfree(asb); 484 + unlock_kernel(); 489 485 return -EINVAL; 490 486 } 491 487
+4 -10
fs/affs/super.c
··· 16 16 #include <linux/parser.h> 17 17 #include <linux/magic.h> 18 18 #include <linux/sched.h> 19 - #include <linux/smp_lock.h> 20 19 #include <linux/slab.h> 21 20 #include "affs.h" 22 21 ··· 45 46 struct affs_sb_info *sbi = AFFS_SB(sb); 46 47 pr_debug("AFFS: put_super()\n"); 47 48 48 - lock_kernel(); 49 - 50 49 if (!(sb->s_flags & MS_RDONLY) && sb->s_dirt) 51 50 affs_commit_super(sb, 1, 1); 52 51 ··· 53 56 affs_brelse(sbi->s_root_bh); 54 57 kfree(sbi); 55 58 sb->s_fs_info = NULL; 56 - 57 - unlock_kernel(); 58 59 } 59 60 60 61 static void ··· 297 302 sbi = kzalloc(sizeof(struct affs_sb_info), GFP_KERNEL); 298 303 if (!sbi) 299 304 return -ENOMEM; 305 + 300 306 sb->s_fs_info = sbi; 301 307 mutex_init(&sbi->s_bmlock); 302 308 spin_lock_init(&sbi->symlink_lock); ··· 523 527 kfree(new_opts); 524 528 return -EINVAL; 525 529 } 526 - lock_kernel(); 530 + 527 531 replace_mount_options(sb, new_opts); 528 532 529 533 sbi->s_flags = mount_flags; ··· 539 543 memcpy(sbi->s_volume, volume, 32); 540 544 spin_unlock(&sbi->symlink_lock); 541 545 542 - if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) { 543 - unlock_kernel(); 546 + if ((*flags & MS_RDONLY) == (sb->s_flags & MS_RDONLY)) 544 547 return 0; 545 - } 548 + 546 549 if (*flags & MS_RDONLY) { 547 550 affs_write_super(sb); 548 551 affs_free_bitmap(sb); 549 552 } else 550 553 res = affs_init_bitmap(sb, flags); 551 554 552 - unlock_kernel(); 553 555 return res; 554 556 } 555 557
+2 -3
fs/afs/flock.c
··· 9 9 * 2 of the License, or (at your option) any later version. 10 10 */ 11 11 12 - #include <linux/smp_lock.h> 13 12 #include "internal.h" 14 13 15 14 #define AFS_LOCK_GRANTED 0 ··· 273 274 274 275 type = (fl->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE; 275 276 276 - lock_kernel(); 277 + lock_flocks(); 277 278 278 279 /* make sure we've got a callback on this file and that our view of the 279 280 * data version is up to date */ ··· 420 421 afs_vnode_fetch_status(vnode, NULL, key); 421 422 422 423 error: 423 - unlock_kernel(); 424 + unlock_flocks(); 424 425 _leave(" = %d", ret); 425 426 return ret; 426 427
-5
fs/afs/super.c
··· 19 19 #include <linux/mount.h> 20 20 #include <linux/init.h> 21 21 #include <linux/slab.h> 22 - #include <linux/smp_lock.h> 23 22 #include <linux/fs.h> 24 23 #include <linux/pagemap.h> 25 24 #include <linux/parser.h> ··· 452 453 453 454 _enter(""); 454 455 455 - lock_kernel(); 456 - 457 456 afs_put_volume(as->volume); 458 - 459 - unlock_kernel(); 460 457 461 458 _leave(""); 462 459 }
+2
fs/autofs/root.c
··· 27 27 static int autofs_root_rmdir(struct inode *,struct dentry *); 28 28 static int autofs_root_mkdir(struct inode *,struct dentry *,int); 29 29 static long autofs_root_ioctl(struct file *,unsigned int,unsigned long); 30 + #ifdef CONFIG_COMPAT 30 31 static long autofs_root_compat_ioctl(struct file *,unsigned int,unsigned long); 32 + #endif 31 33 32 34 const struct file_operations autofs_root_operations = { 33 35 .llseek = generic_file_llseek,
+9 -5
fs/autofs4/root.c
··· 19 19 #include <linux/param.h> 20 20 #include <linux/time.h> 21 21 #include <linux/compat.h> 22 - #include <linux/smp_lock.h> 22 + #include <linux/mutex.h> 23 23 24 24 #include "autofs_i.h" 25 25 ··· 28 28 static int autofs4_dir_rmdir(struct inode *,struct dentry *); 29 29 static int autofs4_dir_mkdir(struct inode *,struct dentry *,int); 30 30 static long autofs4_root_ioctl(struct file *,unsigned int,unsigned long); 31 + #ifdef CONFIG_COMPAT 31 32 static long autofs4_root_compat_ioctl(struct file *,unsigned int,unsigned long); 33 + #endif 32 34 static int autofs4_dir_open(struct inode *inode, struct file *file); 33 35 static struct dentry *autofs4_lookup(struct inode *,struct dentry *, struct nameidata *); 34 36 static void *autofs4_follow_link(struct dentry *, struct nameidata *); ··· 980 978 } 981 979 } 982 980 981 + static DEFINE_MUTEX(autofs4_ioctl_mutex); 982 + 983 983 static long autofs4_root_ioctl(struct file *filp, 984 984 unsigned int cmd, unsigned long arg) 985 985 { 986 986 long ret; 987 987 struct inode *inode = filp->f_dentry->d_inode; 988 988 989 - lock_kernel(); 989 + mutex_lock(&autofs4_ioctl_mutex); 990 990 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); 991 - unlock_kernel(); 991 + mutex_unlock(&autofs4_ioctl_mutex); 992 992 993 993 return ret; 994 994 } ··· 1002 998 struct inode *inode = filp->f_path.dentry->d_inode; 1003 999 int ret; 1004 1000 1005 - lock_kernel(); 1001 + mutex_lock(&autofs4_ioctl_mutex); 1006 1002 if (cmd == AUTOFS_IOC_READY || cmd == AUTOFS_IOC_FAIL) 1007 1003 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, arg); 1008 1004 else 1009 1005 ret = autofs4_root_ioctl_unlocked(inode, filp, cmd, 1010 1006 (unsigned long)compat_ptr(arg)); 1011 - unlock_kernel(); 1007 + mutex_unlock(&autofs4_ioctl_mutex); 1012 1008 1013 1009 return ret; 1014 1010 }
-5
fs/bfs/inode.c
··· 12 12 #include <linux/slab.h> 13 13 #include <linux/init.h> 14 14 #include <linux/fs.h> 15 - #include <linux/smp_lock.h> 16 15 #include <linux/buffer_head.h> 17 16 #include <linux/vfs.h> 18 17 #include <linux/writeback.h> ··· 214 215 if (!info) 215 216 return; 216 217 217 - lock_kernel(); 218 - 219 218 mutex_destroy(&info->bfs_lock); 220 219 kfree(info->si_imap); 221 220 kfree(info); 222 221 s->s_fs_info = NULL; 223 - 224 - unlock_kernel(); 225 222 } 226 223 227 224 static int bfs_statfs(struct dentry *dentry, struct kstatfs *buf)
+5 -8
fs/cifs/cifsfs.c
··· 35 35 #include <linux/delay.h> 36 36 #include <linux/kthread.h> 37 37 #include <linux/freezer.h> 38 - #include <linux/smp_lock.h> 39 38 #include "cifsfs.h" 40 39 #include "cifspdu.h" 41 40 #define DECLARE_GLOBALS_HERE ··· 199 200 return; 200 201 } 201 202 202 - lock_kernel(); 203 - 204 203 rc = cifs_umount(sb, cifs_sb); 205 204 if (rc) 206 205 cERROR(1, "cifs_umount failed with return code %d", rc); ··· 212 215 unload_nls(cifs_sb->local_nls); 213 216 bdi_destroy(&cifs_sb->bdi); 214 217 kfree(cifs_sb); 215 - 216 - unlock_kernel(); 217 218 } 218 219 219 220 static int ··· 509 514 int flags, const char *dev_name, void *data, struct vfsmount *mnt) 510 515 { 511 516 int rc; 512 - struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL); 517 + struct super_block *sb; 518 + 519 + sb = sget(fs_type, NULL, set_anon_super, NULL); 513 520 514 521 cFYI(1, "Devname: %s flags: %d ", dev_name, flags); 515 522 ··· 562 565 563 566 static int cifs_setlease(struct file *file, long arg, struct file_lock **lease) 564 567 { 565 - /* note that this is called by vfs setlease with the BKL held 566 - although I doubt that BKL is needed here in cifs */ 568 + /* note that this is called by vfs setlease with lock_flocks held 569 + to protect *lease from going away */ 567 570 struct inode *inode = file->f_path.dentry->d_inode; 568 571 569 572 if (!(S_ISREG(inode->i_mode)))
+7 -1
fs/coda/inode.c
··· 148 148 int error; 149 149 int idx; 150 150 151 + lock_kernel(); 152 + 151 153 idx = get_device_index((struct coda_mount_data *) data); 152 154 153 155 /* Ignore errors in data, for backward compatibility */ ··· 161 159 vc = &coda_comms[idx]; 162 160 if (!vc->vc_inuse) { 163 161 printk("coda_read_super: No pseudo device\n"); 162 + unlock_kernel(); 164 163 return -EINVAL; 165 164 } 166 165 167 166 if ( vc->vc_sb ) { 168 167 printk("coda_read_super: Device already mounted\n"); 168 + unlock_kernel(); 169 169 return -EBUSY; 170 170 } 171 171 ··· 206 202 sb->s_root = d_alloc_root(root); 207 203 if (!sb->s_root) 208 204 goto error; 209 - return 0; 205 + unlock_kernel(); 206 + return 0; 210 207 211 208 error: 212 209 bdi_destroy(&vc->bdi); ··· 217 212 if (vc) 218 213 vc->vc_sb = NULL; 219 214 215 + unlock_kernel(); 220 216 return -EINVAL; 221 217 } 222 218
-3
fs/ecryptfs/file.c
··· 31 31 #include <linux/security.h> 32 32 #include <linux/compat.h> 33 33 #include <linux/fs_stack.h> 34 - #include <linux/smp_lock.h> 35 34 #include "ecryptfs_kernel.h" 36 35 37 36 /** ··· 283 284 int rc = 0; 284 285 struct file *lower_file = NULL; 285 286 286 - lock_kernel(); 287 287 lower_file = ecryptfs_file_to_lower(file); 288 288 if (lower_file->f_op && lower_file->f_op->fasync) 289 289 rc = lower_file->f_op->fasync(fd, lower_file, flag); 290 - unlock_kernel(); 291 290 return rc; 292 291 } 293 292
+4 -2
fs/ext2/super.c
··· 747 747 __le32 features; 748 748 int err; 749 749 750 + err = -ENOMEM; 750 751 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 751 752 if (!sbi) 752 - return -ENOMEM; 753 + goto failed_unlock; 753 754 754 755 sbi->s_blockgroup_lock = 755 756 kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL); 756 757 if (!sbi->s_blockgroup_lock) { 757 758 kfree(sbi); 758 - return -ENOMEM; 759 + goto failed_unlock; 759 760 } 760 761 sb->s_fs_info = sbi; 761 762 sbi->s_sb_block = sb_block; ··· 1108 1107 sb->s_fs_info = NULL; 1109 1108 kfree(sbi->s_blockgroup_lock); 1110 1109 kfree(sbi); 1110 + failed_unlock: 1111 1111 return ret; 1112 1112 } 1113 1113
-13
fs/ext3/super.c
··· 411 411 int i, err; 412 412 413 413 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); 414 - 415 - lock_kernel(); 416 - 417 414 ext3_xattr_put_super(sb); 418 415 err = journal_destroy(sbi->s_journal); 419 416 sbi->s_journal = NULL; ··· 459 462 sb->s_fs_info = NULL; 460 463 kfree(sbi->s_blockgroup_lock); 461 464 kfree(sbi); 462 - 463 - unlock_kernel(); 464 465 } 465 466 466 467 static struct kmem_cache *ext3_inode_cachep; ··· 1622 1627 sbi->s_resgid = EXT3_DEF_RESGID; 1623 1628 sbi->s_sb_block = sb_block; 1624 1629 1625 - unlock_kernel(); 1626 - 1627 1630 blocksize = sb_min_blocksize(sb, EXT3_MIN_BLOCK_SIZE); 1628 1631 if (!blocksize) { 1629 1632 ext3_msg(sb, KERN_ERR, "error: unable to set blocksize"); ··· 2018 2025 test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": 2019 2026 "writeback"); 2020 2027 2021 - lock_kernel(); 2022 2028 return 0; 2023 2029 2024 2030 cantfind_ext3: ··· 2047 2055 sb->s_fs_info = NULL; 2048 2056 kfree(sbi->s_blockgroup_lock); 2049 2057 kfree(sbi); 2050 - lock_kernel(); 2051 2058 return ret; 2052 2059 } 2053 2060 ··· 2529 2538 int i; 2530 2539 #endif 2531 2540 2532 - lock_kernel(); 2533 - 2534 2541 /* Store the original options */ 2535 2542 lock_super(sb); 2536 2543 old_sb_flags = sb->s_flags; ··· 2637 2648 kfree(old_opts.s_qf_names[i]); 2638 2649 #endif 2639 2650 unlock_super(sb); 2640 - unlock_kernel(); 2641 2651 2642 2652 if (enable_quota) 2643 2653 dquot_resume(sb, -1); ··· 2657 2669 } 2658 2670 #endif 2659 2671 unlock_super(sb); 2660 - unlock_kernel(); 2661 2672 return err; 2662 2673 } 2663 2674
-11
fs/ext4/super.c
··· 26 26 #include <linux/init.h> 27 27 #include <linux/blkdev.h> 28 28 #include <linux/parser.h> 29 - #include <linux/smp_lock.h> 30 29 #include <linux/buffer_head.h> 31 30 #include <linux/exportfs.h> 32 31 #include <linux/vfs.h> ··· 707 708 destroy_workqueue(sbi->dio_unwritten_wq); 708 709 709 710 lock_super(sb); 710 - lock_kernel(); 711 711 if (sb->s_dirt) 712 712 ext4_commit_super(sb, 1); 713 713 ··· 773 775 * Now that we are completely done shutting down the 774 776 * superblock, we need to actually destroy the kobject. 775 777 */ 776 - unlock_kernel(); 777 778 unlock_super(sb); 778 779 kobject_put(&sbi->s_kobj); 779 780 wait_for_completion(&sbi->s_kobj_unregister); ··· 2585 2588 sbi->s_sectors_written_start = 2586 2589 part_stat_read(sb->s_bdev->bd_part, sectors[1]); 2587 2590 2588 - unlock_kernel(); 2589 - 2590 2591 /* Cleanup superblock name */ 2591 2592 for (cp = sb->s_id; (cp = strchr(cp, '/'));) 2592 2593 *cp = '!'; ··· 3159 3164 if (es->s_error_count) 3160 3165 mod_timer(&sbi->s_err_report, jiffies + 300*HZ); /* 5 minutes */ 3161 3166 3162 - lock_kernel(); 3163 3167 kfree(orig_data); 3164 3168 return 0; 3165 3169 ··· 3205 3211 sb->s_fs_info = NULL; 3206 3212 kfree(sbi->s_blockgroup_lock); 3207 3213 kfree(sbi); 3208 - lock_kernel(); 3209 3214 out_free_orig: 3210 3215 kfree(orig_data); 3211 3216 return ret; ··· 3713 3720 #endif 3714 3721 char *orig_data = kstrdup(data, GFP_KERNEL); 3715 3722 3716 - lock_kernel(); 3717 - 3718 3723 /* Store the original options */ 3719 3724 lock_super(sb); 3720 3725 old_sb_flags = sb->s_flags; ··· 3847 3856 kfree(old_opts.s_qf_names[i]); 3848 3857 #endif 3849 3858 unlock_super(sb); 3850 - unlock_kernel(); 3851 3859 if (enable_quota) 3852 3860 dquot_resume(sb, -1); 3853 3861 ··· 3872 3882 } 3873 3883 #endif 3874 3884 unlock_super(sb); 3875 - unlock_kernel(); 3876 3885 kfree(orig_data); 3877 3886 return err; 3878 3887 }
-5
fs/fat/inode.c
··· 14 14 #include <linux/init.h> 15 15 #include <linux/time.h> 16 16 #include <linux/slab.h> 17 - #include <linux/smp_lock.h> 18 17 #include <linux/seq_file.h> 19 18 #include <linux/pagemap.h> 20 19 #include <linux/mpage.h> ··· 488 489 { 489 490 struct msdos_sb_info *sbi = MSDOS_SB(sb); 490 491 491 - lock_kernel(); 492 - 493 492 if (sb->s_dirt) 494 493 fat_write_super(sb); 495 494 ··· 501 504 502 505 sb->s_fs_info = NULL; 503 506 kfree(sbi); 504 - 505 - unlock_kernel(); 506 507 } 507 508 508 509 static struct kmem_cache *fat_inode_cachep;
+5 -1
fs/fat/namei_msdos.c
··· 662 662 { 663 663 int res; 664 664 665 + lock_super(sb); 665 666 res = fat_fill_super(sb, data, silent, &msdos_dir_inode_operations, 0); 666 - if (res) 667 + if (res) { 668 + unlock_super(sb); 667 669 return res; 670 + } 668 671 669 672 sb->s_flags |= MS_NOATIME; 670 673 sb->s_root->d_op = &msdos_dentry_operations; 674 + unlock_super(sb); 671 675 return 0; 672 676 } 673 677
+5 -1
fs/fat/namei_vfat.c
··· 1055 1055 { 1056 1056 int res; 1057 1057 1058 + lock_super(sb); 1058 1059 res = fat_fill_super(sb, data, silent, &vfat_dir_inode_operations, 1); 1059 - if (res) 1060 + if (res) { 1061 + unlock_super(sb); 1060 1062 return res; 1063 + } 1061 1064 1062 1065 if (MSDOS_SB(sb)->options.name_check != 's') 1063 1066 sb->s_root->d_op = &vfat_ci_dentry_ops; 1064 1067 else 1065 1068 sb->s_root->d_op = &vfat_dentry_ops; 1066 1069 1070 + unlock_super(sb); 1067 1071 return 0; 1068 1072 } 1069 1073
+2 -12
fs/freevxfs/vxfs_lookup.c
··· 36 36 #include <linux/highmem.h> 37 37 #include <linux/kernel.h> 38 38 #include <linux/pagemap.h> 39 - #include <linux/smp_lock.h> 40 39 41 40 #include "vxfs.h" 42 41 #include "vxfs_dir.h" ··· 211 212 if (dp->d_name.len > VXFS_NAMELEN) 212 213 return ERR_PTR(-ENAMETOOLONG); 213 214 214 - lock_kernel(); 215 215 ino = vxfs_inode_by_name(dip, dp); 216 216 if (ino) { 217 217 ip = vxfs_iget(dip->i_sb, ino); 218 - if (IS_ERR(ip)) { 219 - unlock_kernel(); 218 + if (IS_ERR(ip)) 220 219 return ERR_CAST(ip); 221 - } 222 220 } 223 - unlock_kernel(); 224 221 d_add(dp, ip); 225 222 return NULL; 226 223 } ··· 243 248 u_long page, npages, block, pblocks, nblocks, offset; 244 249 loff_t pos; 245 250 246 - lock_kernel(); 247 - 248 251 switch ((long)fp->f_pos) { 249 252 case 0: 250 253 if (filler(retp, ".", 1, fp->f_pos, ip->i_ino, DT_DIR) < 0) ··· 258 265 259 266 pos = fp->f_pos - 2; 260 267 261 - if (pos > VXFS_DIRROUND(ip->i_size)) { 262 - unlock_kernel(); 268 + if (pos > VXFS_DIRROUND(ip->i_size)) 263 269 return 0; 264 - } 265 270 266 271 npages = dir_pages(ip); 267 272 nblocks = dir_blocks(ip); ··· 318 327 done: 319 328 fp->f_pos = ((page << PAGE_CACHE_SHIFT) | offset) + 2; 320 329 out: 321 - unlock_kernel(); 322 330 return 0; 323 331 }
+1 -6
fs/freevxfs/vxfs_super.c
··· 38 38 #include <linux/buffer_head.h> 39 39 #include <linux/kernel.h> 40 40 #include <linux/slab.h> 41 - #include <linux/smp_lock.h> 42 41 #include <linux/stat.h> 43 42 #include <linux/vfs.h> 44 43 #include <linux/mount.h> ··· 80 81 { 81 82 struct vxfs_sb_info *infp = VXFS_SBI(sbp); 82 83 83 - lock_kernel(); 84 - 85 84 vxfs_put_fake_inode(infp->vsi_fship); 86 85 vxfs_put_fake_inode(infp->vsi_ilist); 87 86 vxfs_put_fake_inode(infp->vsi_stilist); 88 87 89 88 brelse(infp->vsi_bp); 90 89 kfree(infp); 91 - 92 - unlock_kernel(); 93 90 } 94 91 95 92 /** ··· 143 148 * The superblock on success, else %NULL. 144 149 * 145 150 * Locking: 146 - * We are under the bkl and @sbp->s_lock. 151 + * We are under @sbp->s_lock. 147 152 */ 148 153 static int vxfs_fill_super(struct super_block *sbp, void *dp, int silent) 149 154 {
+2
fs/gfs2/file.c
··· 622 622 * cluster; until we do, disable leases (by just returning -EINVAL), 623 623 * unless the administrator has requested purely local locking. 624 624 * 625 + * Locking: called under lock_flocks 626 + * 625 627 * Returns: errno 626 628 */ 627 629
+1 -5
fs/hfs/super.c
··· 20 20 #include <linux/parser.h> 21 21 #include <linux/seq_file.h> 22 22 #include <linux/slab.h> 23 - #include <linux/smp_lock.h> 24 23 #include <linux/vfs.h> 25 24 26 25 #include "hfs_fs.h" ··· 78 79 */ 79 80 static void hfs_put_super(struct super_block *sb) 80 81 { 81 - lock_kernel(); 82 - 83 82 if (sb->s_dirt) 84 83 hfs_write_super(sb); 85 84 hfs_mdb_close(sb); 86 85 /* release the MDB's resources */ 87 86 hfs_mdb_put(sb); 88 - 89 - unlock_kernel(); 90 87 } 91 88 92 89 /* ··· 380 385 sbi = kzalloc(sizeof(struct hfs_sb_info), GFP_KERNEL); 381 386 if (!sbi) 382 387 return -ENOMEM; 388 + 383 389 sb->s_fs_info = sbi; 384 390 INIT_HLIST_HEAD(&sbi->rsrc_inodes); 385 391
+7 -1
fs/hpfs/super.c
··· 477 477 478 478 int o; 479 479 480 + lock_kernel(); 481 + 480 482 save_mount_options(s, options); 481 483 482 484 sbi = kzalloc(sizeof(*sbi), GFP_KERNEL); 483 - if (!sbi) 485 + if (!sbi) { 486 + unlock_kernel(); 484 487 return -ENOMEM; 488 + } 485 489 s->s_fs_info = sbi; 486 490 487 491 sbi->sb_bmp_dir = NULL; ··· 670 666 root->i_blocks = 5; 671 667 hpfs_brelse4(&qbh); 672 668 } 669 + unlock_kernel(); 673 670 return 0; 674 671 675 672 bail4: brelse(bh2); ··· 682 677 kfree(sbi->sb_cp_table); 683 678 s->s_fs_info = NULL; 684 679 kfree(sbi); 680 + unlock_kernel(); 685 681 return -EINVAL; 686 682 } 687 683
+3 -3
fs/isofs/dir.c
··· 10 10 * 11 11 * isofs directory handling functions 12 12 */ 13 - #include <linux/smp_lock.h> 14 13 #include <linux/gfp.h> 15 14 #include "isofs.h" 16 15 ··· 254 255 char *tmpname; 255 256 struct iso_directory_record *tmpde; 256 257 struct inode *inode = filp->f_path.dentry->d_inode; 258 + struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb); 257 259 258 260 tmpname = (char *)__get_free_page(GFP_KERNEL); 259 261 if (tmpname == NULL) 260 262 return -ENOMEM; 261 263 262 - lock_kernel(); 264 + mutex_lock(&sbi->s_mutex); 263 265 tmpde = (struct iso_directory_record *) (tmpname+1024); 264 266 265 267 result = do_isofs_readdir(inode, filp, dirent, filldir, tmpname, tmpde); 266 268 267 269 free_page((unsigned long) tmpname); 268 - unlock_kernel(); 270 + mutex_unlock(&sbi->s_mutex); 269 271 return result; 270 272 } 271 273
+1 -8
fs/isofs/inode.c
··· 17 17 #include <linux/slab.h> 18 18 #include <linux/nls.h> 19 19 #include <linux/ctype.h> 20 - #include <linux/smp_lock.h> 21 20 #include <linux/statfs.h> 22 21 #include <linux/cdrom.h> 23 22 #include <linux/parser.h> ··· 43 44 struct isofs_sb_info *sbi = ISOFS_SB(sb); 44 45 45 46 #ifdef CONFIG_JOLIET 46 - lock_kernel(); 47 - 48 47 unload_nls(sbi->s_nls_iocharset); 49 - 50 - unlock_kernel(); 51 48 #endif 52 49 53 50 kfree(sbi); ··· 818 823 sbi->s_utf8 = opt.utf8; 819 824 sbi->s_nocompress = opt.nocompress; 820 825 sbi->s_overriderockperm = opt.overriderockperm; 826 + mutex_init(&sbi->s_mutex); 821 827 /* 822 828 * It would be incredibly stupid to allow people to mark every file 823 829 * on the disk as suid, so we merely allow them to set the default ··· 973 977 int section, rv, error; 974 978 struct iso_inode_info *ei = ISOFS_I(inode); 975 979 976 - lock_kernel(); 977 - 978 980 error = -EIO; 979 981 rv = 0; 980 982 if (iblock < 0 || iblock != iblock_s) { ··· 1048 1054 1049 1055 error = 0; 1050 1056 abort: 1051 - unlock_kernel(); 1052 1057 return rv != 0 ? rv : error; 1053 1058 } 1054 1059
+1
fs/isofs/isofs.h
··· 55 55 gid_t s_gid; 56 56 uid_t s_uid; 57 57 struct nls_table *s_nls_iocharset; /* Native language support table */ 58 + struct mutex s_mutex; /* replaces BKL, please remove if possible */ 58 59 }; 59 60 60 61 #define ISOFS_INVALID_MODE ((mode_t) -1)
+4 -4
fs/isofs/namei.c
··· 6 6 * (C) 1991 Linus Torvalds - minix filesystem 7 7 */ 8 8 9 - #include <linux/smp_lock.h> 10 9 #include <linux/gfp.h> 11 10 #include "isofs.h" 12 11 ··· 167 168 int found; 168 169 unsigned long uninitialized_var(block); 169 170 unsigned long uninitialized_var(offset); 171 + struct isofs_sb_info *sbi = ISOFS_SB(dir->i_sb); 170 172 struct inode *inode; 171 173 struct page *page; 172 174 ··· 177 177 if (!page) 178 178 return ERR_PTR(-ENOMEM); 179 179 180 - lock_kernel(); 180 + mutex_lock(&sbi->s_mutex); 181 181 found = isofs_find_entry(dir, dentry, 182 182 &block, &offset, 183 183 page_address(page), ··· 188 188 if (found) { 189 189 inode = isofs_iget(dir->i_sb, block, offset); 190 190 if (IS_ERR(inode)) { 191 - unlock_kernel(); 191 + mutex_unlock(&sbi->s_mutex); 192 192 return ERR_CAST(inode); 193 193 } 194 194 } 195 - unlock_kernel(); 195 + mutex_unlock(&sbi->s_mutex); 196 196 return d_splice_alias(inode, dentry); 197 197 }
+5 -5
fs/isofs/rock.c
··· 8 8 9 9 #include <linux/slab.h> 10 10 #include <linux/pagemap.h> 11 - #include <linux/smp_lock.h> 12 11 13 12 #include "isofs.h" 14 13 #include "rock.h" ··· 660 661 { 661 662 struct inode *inode = page->mapping->host; 662 663 struct iso_inode_info *ei = ISOFS_I(inode); 664 + struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb); 663 665 char *link = kmap(page); 664 666 unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); 665 667 struct buffer_head *bh; ··· 673 673 struct rock_state rs; 674 674 int ret; 675 675 676 - if (!ISOFS_SB(inode->i_sb)->s_rock) 676 + if (!sbi->s_rock) 677 677 goto error; 678 678 679 679 init_rock_state(&rs, inode); 680 680 block = ei->i_iget5_block; 681 - lock_kernel(); 681 + mutex_lock(&sbi->s_mutex); 682 682 bh = sb_bread(inode->i_sb, block); 683 683 if (!bh) 684 684 goto out_noread; ··· 748 748 goto fail; 749 749 brelse(bh); 750 750 *rpnt = '\0'; 751 - unlock_kernel(); 751 + mutex_unlock(&sbi->s_mutex); 752 752 SetPageUptodate(page); 753 753 kunmap(page); 754 754 unlock_page(page); ··· 765 765 printk("symlink spans iso9660 blocks\n"); 766 766 fail: 767 767 brelse(bh); 768 - unlock_kernel(); 768 + mutex_unlock(&sbi->s_mutex); 769 769 error: 770 770 SetPageError(page); 771 771 kunmap(page);
-4
fs/jffs2/fs.c
··· 21 21 #include <linux/vmalloc.h> 22 22 #include <linux/vfs.h> 23 23 #include <linux/crc32.h> 24 - #include <linux/smp_lock.h> 25 24 #include "nodelist.h" 26 25 27 26 static int jffs2_flash_setup(struct jffs2_sb_info *c); ··· 390 391 This also catches the case where it was stopped and this 391 392 is just a remount to restart it. 392 393 Flush the writebuffer, if neccecary, else we loose it */ 393 - lock_kernel(); 394 394 if (!(sb->s_flags & MS_RDONLY)) { 395 395 jffs2_stop_garbage_collect_thread(c); 396 396 mutex_lock(&c->alloc_sem); ··· 401 403 jffs2_start_garbage_collect_thread(c); 402 404 403 405 *flags |= MS_NOATIME; 404 - 405 - unlock_kernel(); 406 406 return 0; 407 407 } 408 408
+3 -6
fs/jffs2/super.c
··· 12 12 #include <linux/kernel.h> 13 13 #include <linux/module.h> 14 14 #include <linux/slab.h> 15 - #include <linux/smp_lock.h> 16 15 #include <linux/init.h> 17 16 #include <linux/list.h> 18 17 #include <linux/fs.h> ··· 145 146 static int jffs2_fill_super(struct super_block *sb, void *data, int silent) 146 147 { 147 148 struct jffs2_sb_info *c; 149 + int ret; 148 150 149 151 D1(printk(KERN_DEBUG "jffs2_get_sb_mtd():" 150 152 " New superblock for device %d (\"%s\")\n", ··· 175 175 #ifdef CONFIG_JFFS2_FS_POSIX_ACL 176 176 sb->s_flags |= MS_POSIXACL; 177 177 #endif 178 - return jffs2_do_fill_super(sb, data, silent); 178 + ret = jffs2_do_fill_super(sb, data, silent); 179 + return ret; 179 180 } 180 181 181 182 static int jffs2_get_sb(struct file_system_type *fs_type, ··· 192 191 struct jffs2_sb_info *c = JFFS2_SB_INFO(sb); 193 192 194 193 D2(printk(KERN_DEBUG "jffs2: jffs2_put_super()\n")); 195 - 196 - lock_kernel(); 197 194 198 195 if (sb->s_dirt) 199 196 jffs2_write_super(sb); ··· 213 214 jffs2_clear_xattr_subsystem(c); 214 215 if (c->mtd->sync) 215 216 c->mtd->sync(c->mtd); 216 - 217 - unlock_kernel(); 218 217 219 218 D1(printk(KERN_DEBUG "jffs2_put_super returning\n")); 220 219 }
+5 -18
fs/jfs/super.c
··· 33 33 #include <linux/slab.h> 34 34 #include <asm/uaccess.h> 35 35 #include <linux/seq_file.h> 36 - #include <linux/smp_lock.h> 37 36 38 37 #include "jfs_incore.h" 39 38 #include "jfs_filsys.h" ··· 175 176 176 177 dquot_disable(sb, -1, DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED); 177 178 178 - lock_kernel(); 179 - 180 179 rc = jfs_umount(sb); 181 180 if (rc) 182 181 jfs_err("jfs_umount failed with return code %d", rc); ··· 185 188 iput(sbi->direct_inode); 186 189 187 190 kfree(sbi); 188 - 189 - unlock_kernel(); 190 191 } 191 192 192 193 enum { ··· 364 369 if (!parse_options(data, sb, &newLVSize, &flag)) { 365 370 return -EINVAL; 366 371 } 367 - lock_kernel(); 372 + 368 373 if (newLVSize) { 369 374 if (sb->s_flags & MS_RDONLY) { 370 375 printk(KERN_ERR 371 376 "JFS: resize requires volume to be mounted read-write\n"); 372 - unlock_kernel(); 373 377 return -EROFS; 374 378 } 375 379 rc = jfs_extendfs(sb, newLVSize, 0); 376 - if (rc) { 377 - unlock_kernel(); 380 + if (rc) 378 381 return rc; 379 - } 380 382 } 381 383 382 384 if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) { ··· 389 397 /* mark the fs r/w for quota activity */ 390 398 sb->s_flags &= ~MS_RDONLY; 391 399 392 - unlock_kernel(); 393 400 dquot_resume(sb, -1); 394 401 return ret; 395 402 } 396 403 if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY)) { 397 404 rc = dquot_suspend(sb, -1); 398 405 if (rc < 0) { 399 - unlock_kernel(); 400 406 return rc; 401 407 } 402 408 rc = jfs_umount_rw(sb); 403 409 JFS_SBI(sb)->flag = flag; 404 - unlock_kernel(); 405 410 return rc; 406 411 } 407 412 if ((JFS_SBI(sb)->flag & JFS_NOINTEGRITY) != (flag & JFS_NOINTEGRITY)) 408 413 if (!(sb->s_flags & MS_RDONLY)) { 409 414 rc = jfs_umount_rw(sb); 410 - if (rc) { 411 - unlock_kernel(); 415 + if (rc) 412 416 return rc; 413 - } 417 + 414 418 JFS_SBI(sb)->flag = flag; 415 419 ret = jfs_mount_rw(sb, 1); 416 - unlock_kernel(); 417 420 return ret; 418 421 } 419 422 JFS_SBI(sb)->flag = flag; 420 423 421 - unlock_kernel(); 422 424 return 0; 423 425 } 424 426 ··· 432 446 sbi = kzalloc(sizeof (struct jfs_sb_info), GFP_KERNEL); 433 447 if (!sbi) 434 448 return -ENOMEM; 449 + 435 450 sb->s_fs_info = sbi; 436 451 sbi->sb = sb; 437 452 sbi->uid = sbi->gid = sbi->umask = -1;
+68 -44
fs/locks.c
··· 143 143 static LIST_HEAD(file_lock_list); 144 144 static LIST_HEAD(blocked_list); 145 145 146 + /* 147 + * Protects the two list heads above, plus the inode->i_flock list 148 + * FIXME: should use a spinlock, once lockd and ceph are ready. 149 + */ 150 + void lock_flocks(void) 151 + { 152 + lock_kernel(); 153 + } 154 + EXPORT_SYMBOL_GPL(lock_flocks); 155 + 156 + void unlock_flocks(void) 157 + { 158 + unlock_kernel(); 159 + } 160 + EXPORT_SYMBOL_GPL(unlock_flocks); 161 + 146 162 static struct kmem_cache *filelock_cache __read_mostly; 147 163 148 164 /* Allocate an empty lock structure. */ ··· 527 511 */ 528 512 static void locks_delete_block(struct file_lock *waiter) 529 513 { 530 - lock_kernel(); 514 + lock_flocks(); 531 515 __locks_delete_block(waiter); 532 - unlock_kernel(); 516 + unlock_flocks(); 533 517 } 534 518 535 519 /* Insert waiter into blocker's block list. ··· 660 644 { 661 645 struct file_lock *cfl; 662 646 663 - lock_kernel(); 647 + lock_flocks(); 664 648 for (cfl = filp->f_path.dentry->d_inode->i_flock; cfl; cfl = cfl->fl_next) { 665 649 if (!IS_POSIX(cfl)) 666 650 continue; ··· 673 657 fl->fl_pid = pid_vnr(cfl->fl_nspid); 674 658 } else 675 659 fl->fl_type = F_UNLCK; 676 - unlock_kernel(); 660 + unlock_flocks(); 677 661 return; 678 662 } 679 663 EXPORT_SYMBOL(posix_test_lock); ··· 746 730 int error = 0; 747 731 int found = 0; 748 732 749 - lock_kernel(); 733 + if (!(request->fl_flags & FL_ACCESS) && (request->fl_type != F_UNLCK)) { 734 + new_fl = locks_alloc_lock(); 735 + if (!new_fl) 736 + return -ENOMEM; 737 + } 738 + 739 + lock_flocks(); 750 740 if (request->fl_flags & FL_ACCESS) 751 741 goto find_conflict; 752 - 753 - if (request->fl_type != F_UNLCK) { 754 - error = -ENOMEM; 755 - new_fl = locks_alloc_lock(); 756 - if (new_fl == NULL) 757 - goto out; 758 - error = 0; 759 - } 760 742 761 743 for_each_lock(inode, before) { 762 744 struct file_lock *fl = *before; ··· 781 767 * If a higher-priority process was blocked on the old file lock, 782 768 * give it the opportunity to lock the file. 783 769 */ 784 - if (found) 770 + if (found) { 771 + unlock_flocks(); 785 772 cond_resched(); 773 + lock_flocks(); 774 + } 786 775 787 776 find_conflict: 788 777 for_each_lock(inode, before) { ··· 811 794 error = 0; 812 795 813 796 out: 814 - unlock_kernel(); 797 + unlock_flocks(); 815 798 if (new_fl) 816 799 locks_free_lock(new_fl); 817 800 return error; ··· 840 823 new_fl2 = locks_alloc_lock(); 841 824 } 842 825 843 - lock_kernel(); 826 + lock_flocks(); 844 827 if (request->fl_type != F_UNLCK) { 845 828 for_each_lock(inode, before) { 846 829 fl = *before; ··· 1008 991 locks_wake_up_blocks(left); 1009 992 } 1010 993 out: 1011 - unlock_kernel(); 994 + unlock_flocks(); 1012 995 /* 1013 996 * Free any unused locks. 1014 997 */ ··· 1083 1066 /* 1084 1067 * Search the lock list for this inode for any POSIX locks. 1085 1068 */ 1086 - lock_kernel(); 1069 + lock_flocks(); 1087 1070 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 1088 1071 if (!IS_POSIX(fl)) 1089 1072 continue; 1090 1073 if (fl->fl_owner != owner) 1091 1074 break; 1092 1075 } 1093 - unlock_kernel(); 1076 + unlock_flocks(); 1094 1077 return fl ? -EAGAIN : 0; 1095 1078 } 1096 1079 ··· 1203 1186 1204 1187 new_fl = lease_alloc(NULL, want_write ? F_WRLCK : F_RDLCK); 1205 1188 1206 - lock_kernel(); 1189 + lock_flocks(); 1207 1190 1208 1191 time_out_leases(inode); 1209 1192 ··· 1264 1247 break_time++; 1265 1248 } 1266 1249 locks_insert_block(flock, new_fl); 1250 + unlock_flocks(); 1267 1251 error = wait_event_interruptible_timeout(new_fl->fl_wait, 1268 1252 !new_fl->fl_next, break_time); 1253 + lock_flocks(); 1269 1254 __locks_delete_block(new_fl); 1270 1255 if (error >= 0) { 1271 1256 if (error == 0) ··· 1282 1263 } 1283 1264 1284 1265 out: 1285 - unlock_kernel(); 1266 + unlock_flocks(); 1286 1267 if (!IS_ERR(new_fl)) 1287 1268 locks_free_lock(new_fl); 1288 1269 return error; ··· 1338 1319 struct file_lock *fl; 1339 1320 int type = F_UNLCK; 1340 1321 1341 - lock_kernel(); 1322 + lock_flocks(); 1342 1323 time_out_leases(filp->f_path.dentry->d_inode); 1343 1324 for (fl = filp->f_path.dentry->d_inode->i_flock; fl && IS_LEASE(fl); 1344 1325 fl = fl->fl_next) { ··· 1347 1328 break; 1348 1329 } 1349 1330 } 1350 - unlock_kernel(); 1331 + unlock_flocks(); 1351 1332 return type; 1352 1333 } 1353 1334 ··· 1360 1341 * The (input) flp->fl_lmops->fl_break function is required 1361 1342 * by break_lease(). 1362 1343 * 1363 - * Called with kernel lock held. 1344 + * Called with file_lock_lock held. 1364 1345 */ 1365 1346 int generic_setlease(struct file *filp, long arg, struct file_lock **flp) 1366 1347 { ··· 1455 1436 } 1456 1437 EXPORT_SYMBOL(generic_setlease); 1457 1438 1458 - /** 1439 + static int __vfs_setlease(struct file *filp, long arg, struct file_lock **lease) 1440 + { 1441 + if (filp->f_op && filp->f_op->setlease) 1442 + return filp->f_op->setlease(filp, arg, lease); 1443 + else 1444 + return generic_setlease(filp, arg, lease); 1445 + } 1446 + 1447 + /** 1459 1448 * vfs_setlease - sets a lease on an open file 1460 1449 * @filp: file pointer 1461 1450 * @arg: type of lease to obtain ··· 1494 1467 { 1495 1468 int error; 1496 1469 1497 - lock_kernel(); 1498 - if (filp->f_op && filp->f_op->setlease) 1499 - error = filp->f_op->setlease(filp, arg, lease); 1500 - else 1501 - error = generic_setlease(filp, arg, lease); 1502 - unlock_kernel(); 1470 + lock_flocks(); 1471 + error = __vfs_setlease(filp, arg, lease); 1472 + unlock_flocks(); 1503 1473 1504 1474 return error; 1505 1475 } ··· 1523 1499 if (error) 1524 1500 return error; 1525 1501 1526 - lock_kernel(); 1502 + lock_flocks(); 1527 1503 1528 - error = vfs_setlease(filp, arg, &flp); 1504 + error = __vfs_setlease(filp, arg, &flp); 1529 1505 if (error || arg == F_UNLCK) 1530 1506 goto out_unlock; 1531 1507 ··· 1540 1516 1541 1517 error = __f_setown(filp, task_pid(current), PIDTYPE_PID, 0); 1542 1518 out_unlock: 1543 - unlock_kernel(); 1519 + unlock_flocks(); 1544 1520 return error; 1545 1521 } 1546 1522 ··· 2044 2020 fl.fl_ops->fl_release_private(&fl); 2045 2021 } 2046 2022 2047 - lock_kernel(); 2023 + lock_flocks(); 2048 2024 before = &inode->i_flock; 2049 2025 2050 2026 while ((fl = *before) != NULL) { ··· 2062 2038 } 2063 2039 before = &fl->fl_next; 2064 2040 } 2065 - unlock_kernel(); 2041 + unlock_flocks(); 2066 2042 } 2067 2043 2068 2044 /** ··· 2077 2053 { 2078 2054 int status = 0; 2079 2055 2080 - lock_kernel(); 2056 + lock_flocks(); 2081 2057 if (waiter->fl_next) 2082 2058 __locks_delete_block(waiter); 2083 2059 else 2084 2060 status = -ENOENT; 2085 - unlock_kernel(); 2061 + unlock_flocks(); 2086 2062 return status; 2087 2063 } 2088 2064 ··· 2196 2172 2197 2173 static void *locks_start(struct seq_file *f, loff_t *pos) 2198 2174 { 2199 - lock_kernel(); 2175 + lock_flocks(); 2200 2176 f->private = (void *)1; 2201 2177 return seq_list_start(&file_lock_list, *pos); 2202 2178 } ··· 2208 2184 2209 2185 static void locks_stop(struct seq_file *f, void *v) 2210 2186 { 2211 - unlock_kernel(); 2187 + unlock_flocks(); 2212 2188 } 2213 2189 2214 2190 static const struct seq_operations locks_seq_operations = { ··· 2255 2231 { 2256 2232 struct file_lock *fl; 2257 2233 int result = 1; 2258 - lock_kernel(); 2234 + lock_flocks(); 2259 2235 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 2260 2236 if (IS_POSIX(fl)) { 2261 2237 if (fl->fl_type == F_RDLCK) ··· 2272 2248 result = 0; 2273 2249 break; 2274 2250 } 2275 - unlock_kernel(); 2251 + unlock_flocks(); 2276 2252 return result; 2277 2253 } 2278 2254 ··· 2295 2271 { 2296 2272 struct file_lock *fl; 2297 2273 int result = 1; 2298 - lock_kernel(); 2274 + lock_flocks(); 2299 2275 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 2300 2276 if (IS_POSIX(fl)) { 2301 2277 if ((fl->fl_end < start) || (fl->fl_start > (start + len))) ··· 2310 2286 result = 0; 2311 2287 break; 2312 2288 } 2313 - unlock_kernel(); 2289 + unlock_flocks(); 2314 2290 return result; 2315 2291 } 2316 2292
-2
fs/namespace.c
··· 1744 1744 if (!capable(CAP_SYS_ADMIN)) 1745 1745 return -EPERM; 1746 1746 1747 - lock_kernel(); 1748 1747 mnt = do_kern_mount(type, flags, name, data); 1749 - unlock_kernel(); 1750 1748 if (IS_ERR(mnt)) 1751 1749 return PTR_ERR(mnt); 1752 1750
+129 -92
fs/ncpfs/dir.c
··· 95 95 }; 96 96 97 97 98 + #define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber]) 99 + 100 + static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator) 101 + { 102 + #ifdef CONFIG_NCPFS_SMALLDOS 103 + int ns = ncp_namespace(i); 104 + 105 + if ((ns == NW_NS_DOS) 106 + #ifdef CONFIG_NCPFS_OS2_NS 107 + || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS)) 108 + #endif /* CONFIG_NCPFS_OS2_NS */ 109 + ) 110 + return 0; 111 + #endif /* CONFIG_NCPFS_SMALLDOS */ 112 + return 1; 113 + } 114 + 115 + #define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS) 116 + 117 + static inline int ncp_case_sensitive(struct dentry *dentry) 118 + { 119 + #ifdef CONFIG_NCPFS_NFS_NS 120 + return ncp_namespace(dentry->d_inode) == NW_NS_NFS; 121 + #else 122 + return 0; 123 + #endif /* CONFIG_NCPFS_NFS_NS */ 124 + } 125 + 98 126 /* 99 127 * Note: leave the hash unchanged if the directory 100 128 * is case-sensitive. ··· 130 102 static int 131 103 ncp_hash_dentry(struct dentry *dentry, struct qstr *this) 132 104 { 133 - struct nls_table *t; 134 - unsigned long hash; 135 - int i; 105 + if (!ncp_case_sensitive(dentry)) { 106 + struct nls_table *t; 107 + unsigned long hash; 108 + int i; 136 109 137 - t = NCP_IO_TABLE(dentry); 138 - 139 - if (!ncp_case_sensitive(dentry->d_inode)) { 110 + t = NCP_IO_TABLE(dentry); 140 111 hash = init_name_hash(); 141 112 for (i=0; i<this->len ; i++) 142 113 hash = partial_name_hash(ncp_tolower(t, this->name[i]), ··· 151 124 if (a->len != b->len) 152 125 return 1; 153 126 154 - if (ncp_case_sensitive(dentry->d_inode)) 127 + if (ncp_case_sensitive(dentry)) 155 128 return strncmp(a->name, b->name, a->len); 156 129 157 130 return ncp_strnicmp(NCP_IO_TABLE(dentry), a->name, b->name, a->len); ··· 293 266 294 267 295 268 static int 296 - __ncp_lookup_validate(struct dentry *dentry) 269 + ncp_lookup_validate(struct dentry *dentry, struct nameidata *nd) 297 270 { 298 271 struct ncp_server *server; 299 272 struct dentry *parent; ··· 309 282 goto finished; 310 283 311 284 server = NCP_SERVER(dir); 312 - 313 - if (!ncp_conn_valid(server)) 314 - goto finished; 315 285 316 286 /* 317 287 * Inspired by smbfs: ··· 328 304 if (ncp_is_server_root(dir)) { 329 305 res = ncp_io2vol(server, __name, &len, dentry->d_name.name, 330 306 dentry->d_name.len, 1); 331 - if (!res) 307 + if (!res) { 332 308 res = ncp_lookup_volume(server, __name, &(finfo.i)); 309 + if (!res) 310 + ncp_update_known_namespace(server, finfo.i.volNumber, NULL); 311 + } 333 312 } else { 334 313 res = ncp_io2vol(server, __name, &len, dentry->d_name.name, 335 314 dentry->d_name.len, !ncp_preserve_case(dir)); ··· 347 320 * what we remember, it's not valid any more. 348 321 */ 349 322 if (!res) { 350 - if (finfo.i.dirEntNum == NCP_FINFO(dentry->d_inode)->dirEntNum) { 323 + struct inode *inode = dentry->d_inode; 324 + 325 + mutex_lock(&inode->i_mutex); 326 + if (finfo.i.dirEntNum == NCP_FINFO(inode)->dirEntNum) { 351 327 ncp_new_dentry(dentry); 352 328 val=1; 353 329 } else 354 330 DDPRINTK("ncp_lookup_validate: found, but dirEntNum changed\n"); 355 331 356 - ncp_update_inode2(dentry->d_inode, &finfo); 332 + ncp_update_inode2(inode, &finfo); 333 + mutex_unlock(&inode->i_mutex); 357 334 } 358 335 359 336 finished: 360 337 DDPRINTK("ncp_lookup_validate: result=%d\n", val); 361 338 dput(parent); 362 339 return val; 363 - } 364 - 365 - static int 366 - ncp_lookup_validate(struct dentry * dentry, struct nameidata *nd) 367 - { 368 - int res; 369 - lock_kernel(); 370 - res = __ncp_lookup_validate(dentry); 371 - unlock_kernel(); 372 - return res; 373 340 } 374 341 375 342 static struct dentry * ··· 432 411 int result, mtime_valid = 0; 433 412 time_t mtime = 0; 434 413 435 - lock_kernel(); 436 - 437 414 ctl.page = NULL; 438 415 ctl.cache = NULL; 439 416 ··· 440 421 (int) filp->f_pos); 441 422 442 423 result = -EIO; 424 + /* Do not generate '.' and '..' when server is dead. */ 443 425 if (!ncp_conn_valid(server)) 444 426 goto out; 445 427 ··· 552 532 ctl.head.end = ctl.fpos - 1; 553 533 ctl.head.eof = ctl.valid; 554 534 finished: 535 + if (ctl.page) { 536 + kunmap(ctl.page); 537 + SetPageUptodate(ctl.page); 538 + unlock_page(ctl.page); 539 + page_cache_release(ctl.page); 540 + } 555 541 if (page) { 556 542 cache->head = ctl.head; 557 543 kunmap(page); ··· 565 539 unlock_page(page); 566 540 page_cache_release(page); 567 541 } 568 - if (ctl.page) { 569 - kunmap(ctl.page); 570 - SetPageUptodate(ctl.page); 571 - unlock_page(ctl.page); 572 - page_cache_release(ctl.page); 573 - } 574 542 out: 575 - unlock_kernel(); 576 543 return result; 577 544 } 578 545 579 546 static int 580 547 ncp_fill_cache(struct file *filp, void *dirent, filldir_t filldir, 581 - struct ncp_cache_control *ctrl, struct ncp_entry_info *entry) 548 + struct ncp_cache_control *ctrl, struct ncp_entry_info *entry, 549 + int inval_childs) 582 550 { 583 551 struct dentry *newdent, *dentry = filp->f_path.dentry; 584 - struct inode *newino, *inode = dentry->d_inode; 552 + struct inode *dir = dentry->d_inode; 585 553 struct ncp_cache_control ctl = *ctrl; 586 554 struct qstr qname; 587 555 int valid = 0; ··· 584 564 __u8 __name[NCP_MAXPATHLEN + 1]; 585 565 586 566 qname.len = sizeof(__name); 587 - if (ncp_vol2io(NCP_SERVER(inode), __name, &qname.len, 567 + if (ncp_vol2io(NCP_SERVER(dir), __name, &qname.len, 588 568 entry->i.entryName, entry->i.nameLen, 589 - !ncp_preserve_entry_case(inode, entry->i.NSCreator))) 569 + !ncp_preserve_entry_case(dir, entry->i.NSCreator))) 590 570 return 1; /* I'm not sure */ 591 571 592 572 qname.name = __name; ··· 604 584 goto end_advance; 605 585 } else { 606 586 hashed = 1; 607 - memcpy((char *) newdent->d_name.name, qname.name, 608 - newdent->d_name.len); 587 + 588 + /* If case sensitivity changed for this volume, all entries below this one 589 + should be thrown away. This entry itself is not affected, as its case 590 + sensitivity is controlled by its own parent. */ 591 + if (inval_childs) 592 + shrink_dcache_parent(newdent); 593 + 594 + /* 595 + * It is not as dangerous as it looks. NetWare's OS2 namespace is 596 + * case preserving yet case insensitive. So we update dentry's name 597 + * as received from server. We found dentry via d_lookup with our 598 + * hash, so we know that hash does not change, and so replacing name 599 + * should be reasonably safe. 600 + */ 601 + if (qname.len == newdent->d_name.len && 602 + memcmp(newdent->d_name.name, qname.name, newdent->d_name.len)) { 603 + struct inode *inode = newdent->d_inode; 604 + 605 + /* 606 + * Inside ncpfs all uses of d_name are either for debugging, 607 + * or on functions which acquire inode mutex (mknod, creat, 608 + * lookup). So grab i_mutex here, to be sure. d_path 609 + * uses dcache_lock when generating path, so we should too. 610 + * And finally d_compare is protected by dentry's d_lock, so 611 + * here we go. 612 + */ 613 + if (inode) 614 + mutex_lock(&inode->i_mutex); 615 + spin_lock(&dcache_lock); 616 + spin_lock(&newdent->d_lock); 617 + memcpy((char *) newdent->d_name.name, qname.name, 618 + newdent->d_name.len); 619 + spin_unlock(&newdent->d_lock); 620 + spin_unlock(&dcache_lock); 621 + if (inode) 622 + mutex_unlock(&inode->i_mutex); 623 + } 609 624 } 610 625 611 626 if (!newdent->d_inode) { 627 + struct inode *inode; 628 + 612 629 entry->opened = 0; 613 - entry->ino = iunique(inode->i_sb, 2); 614 - newino = ncp_iget(inode->i_sb, entry); 615 - if (newino) { 630 + entry->ino = iunique(dir->i_sb, 2); 631 + inode = ncp_iget(dir->i_sb, entry); 632 + if (inode) { 616 633 newdent->d_op = &ncp_dentry_operations; 617 - d_instantiate(newdent, newino); 634 + d_instantiate(newdent, inode); 618 635 if (!hashed) 619 636 d_rehash(newdent); 620 637 } 621 - } else 622 - ncp_update_inode2(newdent->d_inode, entry); 638 + } else { 639 + struct inode *inode = newdent->d_inode; 640 + 641 + mutex_lock(&inode->i_mutex); 642 + ncp_update_inode2(inode, entry); 643 + mutex_unlock(&inode->i_mutex); 644 + } 623 645 624 646 if (newdent->d_inode) { 625 647 ino = newdent->d_inode->i_ino; ··· 679 617 ctl.cache = NULL; 680 618 ctl.idx -= NCP_DIRCACHE_SIZE; 681 619 ctl.ofs += 1; 682 - ctl.page = grab_cache_page(&inode->i_data, ctl.ofs); 620 + ctl.page = grab_cache_page(&dir->i_data, ctl.ofs); 683 621 if (ctl.page) 684 622 ctl.cache = kmap(ctl.page); 685 623 } ··· 695 633 if (!ino) 696 634 ino = find_inode_number(dentry, &qname); 697 635 if (!ino) 698 - ino = iunique(inode->i_sb, 2); 636 + ino = iunique(dir->i_sb, 2); 699 637 ctl.filled = filldir(dirent, qname.name, qname.len, 700 638 filp->f_pos, ino, DT_UNKNOWN); 701 639 if (!ctl.filled) ··· 722 660 (unsigned long) filp->f_pos); 723 661 724 662 for (i = 0; i < NCP_NUMBER_OF_VOLUMES; i++) { 663 + int inval_dentry; 725 664 726 665 if (ncp_get_volume_info_with_number(server, i, &info) != 0) 727 666 return; ··· 738 675 info.volume_name); 739 676 continue; 740 677 } 678 + inval_dentry = ncp_update_known_namespace(server, entry.i.volNumber, NULL); 741 679 entry.volume = entry.i.volNumber; 742 - if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry)) 680 + if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, inval_dentry)) 743 681 return; 744 682 } 745 683 } ··· 803 739 rpl += onerpl; 804 740 rpls -= onerpl; 805 741 entry.volume = entry.i.volNumber; 806 - if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry)) 742 + if (!ncp_fill_cache(filp, dirent, filldir, ctl, &entry, 0)) 807 743 break; 808 744 } 809 745 } while (more); ··· 839 775 if (dent) { 840 776 struct inode* ino = dent->d_inode; 841 777 if (ino) { 778 + ncp_update_known_namespace(server, volNumber, NULL); 842 779 NCP_FINFO(ino)->volNumber = volNumber; 843 780 NCP_FINFO(ino)->dirEntNum = dirEntNum; 844 781 NCP_FINFO(ino)->DosDirNum = DosDirNum; 782 + result = 0; 845 783 } else { 846 784 DPRINTK("ncpfs: sb->s_root->d_inode == NULL!\n"); 847 785 } 848 786 } else { 849 787 DPRINTK("ncpfs: sb->s_root == NULL!\n"); 850 788 } 851 - } 852 - result = 0; 789 + } else 790 + result = 0; 853 791 854 792 out: 855 793 return result; ··· 865 799 int error, res, len; 866 800 __u8 __name[NCP_MAXPATHLEN + 1]; 867 801 868 - lock_kernel(); 869 802 error = -EIO; 870 803 if (!ncp_conn_valid(server)) 871 804 goto finished; ··· 878 813 dentry->d_name.len, 1); 879 814 if (!res) 880 815 res = ncp_lookup_volume(server, __name, &(finfo.i)); 816 + if (!res) 817 + ncp_update_known_namespace(server, finfo.i.volNumber, NULL); 881 818 } else { 882 819 res = ncp_io2vol(server, __name, &len, dentry->d_name.name, 883 820 dentry->d_name.len, !ncp_preserve_case(dir)); ··· 913 846 914 847 finished: 915 848 PPRINTK("ncp_lookup: result=%d\n", error); 916 - unlock_kernel(); 917 849 return ERR_PTR(error); 918 850 } 919 851 ··· 953 887 PPRINTK("ncp_create_new: creating %s/%s, mode=%x\n", 954 888 dentry->d_parent->d_name.name, dentry->d_name.name, mode); 955 889 956 - error = -EIO; 957 - lock_kernel(); 958 - if (!ncp_conn_valid(server)) 959 - goto out; 960 - 961 890 ncp_age_dentry(server, dentry); 962 891 len = sizeof(__name); 963 892 error = ncp_io2vol(server, __name, &len, dentry->d_name.name, ··· 978 917 if (result) { 979 918 if (result == 0x87) 980 919 error = -ENAMETOOLONG; 920 + else if (result < 0) 921 + error = result; 981 922 DPRINTK("ncp_create: %s/%s failed\n", 982 923 dentry->d_parent->d_name.name, dentry->d_name.name); 983 924 goto out; ··· 998 935 999 936 error = ncp_instantiate(dir, dentry, &finfo); 1000 937 out: 1001 - unlock_kernel(); 1002 938 return error; 1003 939 } 1004 940 ··· 1017 955 DPRINTK("ncp_mkdir: making %s/%s\n", 1018 956 dentry->d_parent->d_name.name, dentry->d_name.name); 1019 957 1020 - error = -EIO; 1021 - lock_kernel(); 1022 - if (!ncp_conn_valid(server)) 1023 - goto out; 1024 - 1025 958 ncp_age_dentry(server, dentry); 1026 959 len = sizeof(__name); 1027 960 error = ncp_io2vol(server, __name, &len, dentry->d_name.name, ··· 1024 967 if (error) 1025 968 goto out; 1026 969 1027 - error = -EACCES; 1028 - if (ncp_open_create_file_or_subdir(server, dir, __name, 970 + error = ncp_open_create_file_or_subdir(server, dir, __name, 1029 971 OC_MODE_CREATE, aDIR, 1030 972 cpu_to_le16(0xffff), 1031 - &finfo) == 0) 1032 - { 973 + &finfo); 974 + if (error == 0) { 1033 975 if (ncp_is_nfs_extras(server, finfo.volume)) { 1034 976 mode |= S_IFDIR; 1035 977 finfo.i.nfs.mode = mode; ··· 1039 983 goto out; 1040 984 } 1041 985 error = ncp_instantiate(dir, dentry, &finfo); 986 + } else if (error > 0) { 987 + error = -EACCES; 1042 988 } 1043 989 out: 1044 - unlock_kernel(); 1045 990 return error; 1046 991 } 1047 992 ··· 1054 997 1055 998 DPRINTK("ncp_rmdir: removing %s/%s\n", 1056 999 dentry->d_parent->d_name.name, dentry->d_name.name); 1057 - 1058 - error = -EIO; 1059 - lock_kernel(); 1060 - if (!ncp_conn_valid(server)) 1061 - goto out; 1062 1000 1063 1001 error = -EBUSY; 1064 1002 if (!d_unhashed(dentry)) ··· 1088 1036 error = -ENOENT; 1089 1037 break; 1090 1038 default: 1091 - error = -EACCES; 1039 + error = result < 0 ? result : -EACCES; 1092 1040 break; 1093 1041 } 1094 1042 out: 1095 - unlock_kernel(); 1096 1043 return error; 1097 1044 } 1098 1045 ··· 1101 1050 struct ncp_server *server; 1102 1051 int error; 1103 1052 1104 - lock_kernel(); 1105 1053 server = NCP_SERVER(dir); 1106 1054 DPRINTK("ncp_unlink: unlinking %s/%s\n", 1107 1055 dentry->d_parent->d_name.name, dentry->d_name.name); 1108 1056 1109 - error = -EIO; 1110 - if (!ncp_conn_valid(server)) 1111 - goto out; 1112 - 1113 1057 /* 1114 1058 * Check whether to close the file ... 1115 1059 */ ··· 1143 1097 error = -ENOENT; 1144 1098 break; 1145 1099 default: 1146 - error = -EACCES; 1100 + error = error < 0 ? error : -EACCES; 1147 1101 break; 1148 1102 } 1149 - 1150 - out: 1151 - unlock_kernel(); 1152 1103 return error; 1153 1104 } 1154 1105 ··· 1160 1117 DPRINTK("ncp_rename: %s/%s to %s/%s\n", 1161 1118 old_dentry->d_parent->d_name.name, old_dentry->d_name.name, 1162 1119 new_dentry->d_parent->d_name.name, new_dentry->d_name.name); 1163 - 1164 - error = -EIO; 1165 - lock_kernel(); 1166 - if (!ncp_conn_valid(server)) 1167 - goto out; 1168 1120 1169 1121 ncp_age_dentry(server, old_dentry); 1170 1122 ncp_age_dentry(server, new_dentry); ··· 1199 1161 error = -ENOENT; 1200 1162 break; 1201 1163 default: 1202 - error = -EACCES; 1164 + error = error < 0 ? error : -EACCES; 1203 1165 break; 1204 1166 } 1205 1167 out: 1206 - unlock_kernel(); 1207 1168 return error; 1208 1169 } 1209 1170
+7 -18
fs/ncpfs/file.c
··· 113 113 DPRINTK("ncp_file_read: enter %s/%s\n", 114 114 dentry->d_parent->d_name.name, dentry->d_name.name); 115 115 116 - if (!ncp_conn_valid(NCP_SERVER(inode))) 117 - return -EIO; 118 - 119 116 pos = *ppos; 120 117 121 118 if ((ssize_t) count < 0) { ··· 189 192 190 193 DPRINTK("ncp_file_write: enter %s/%s\n", 191 194 dentry->d_parent->d_name.name, dentry->d_name.name); 192 - if (!ncp_conn_valid(NCP_SERVER(inode))) 193 - return -EIO; 194 195 if ((ssize_t) count < 0) 195 196 return -EINVAL; 196 197 pos = *ppos; 197 198 if (file->f_flags & O_APPEND) { 198 - pos = inode->i_size; 199 + pos = i_size_read(inode); 199 200 } 200 201 201 202 if (pos + count > MAX_NON_LFS && !(file->f_flags&O_LARGEFILE)) { ··· 259 264 260 265 *ppos = pos; 261 266 262 - if (pos > inode->i_size) { 263 - inode->i_size = pos; 267 + if (pos > i_size_read(inode)) { 268 + mutex_lock(&inode->i_mutex); 269 + if (pos > i_size_read(inode)) 270 + i_size_write(inode, pos); 271 + mutex_unlock(&inode->i_mutex); 264 272 } 265 273 DPRINTK("ncp_file_write: exit %s/%s\n", 266 274 dentry->d_parent->d_name.name, dentry->d_name.name); ··· 279 281 return 0; 280 282 } 281 283 282 - static loff_t ncp_remote_llseek(struct file *file, loff_t offset, int origin) 283 - { 284 - loff_t ret; 285 - lock_kernel(); 286 - ret = generic_file_llseek_unlocked(file, offset, origin); 287 - unlock_kernel(); 288 - return ret; 289 - } 290 - 291 284 const struct file_operations ncp_file_operations = 292 285 { 293 - .llseek = ncp_remote_llseek, 286 + .llseek = generic_file_llseek, 294 287 .read = ncp_file_read, 295 288 .write = ncp_file_write, 296 289 .unlocked_ioctl = ncp_ioctl,
+33 -22
fs/ncpfs/inode.c
··· 139 139 inode->i_mode = nwi->nfs.mode; 140 140 } 141 141 142 - inode->i_blocks = (inode->i_size + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT; 142 + inode->i_blocks = (i_size_read(inode) + NCP_BLOCK_SIZE - 1) >> NCP_BLOCK_SHIFT; 143 143 144 144 inode->i_mtime.tv_sec = ncp_date_dos2unix(nwi->modifyTime, nwi->modifyDate); 145 145 inode->i_ctime.tv_sec = ncp_date_dos2unix(nwi->creationTime, nwi->creationDate); ··· 158 158 inode->i_mode = server->m.dir_mode; 159 159 /* for directories dataStreamSize seems to be some 160 160 Object ID ??? */ 161 - inode->i_size = NCP_BLOCK_SIZE; 161 + i_size_write(inode, NCP_BLOCK_SIZE); 162 162 } else { 163 + u32 size; 164 + 163 165 inode->i_mode = server->m.file_mode; 164 - inode->i_size = le32_to_cpu(nwi->dataStreamSize); 166 + size = le32_to_cpu(nwi->dataStreamSize); 167 + i_size_write(inode, size); 165 168 #ifdef CONFIG_NCPFS_EXTRAS 166 169 if ((server->m.flags & (NCP_MOUNT_EXTRAS|NCP_MOUNT_SYMLINKS)) 167 170 && (nwi->attributes & aSHARED)) { 168 171 switch (nwi->attributes & (aHIDDEN|aSYSTEM)) { 169 172 case aHIDDEN: 170 173 if (server->m.flags & NCP_MOUNT_SYMLINKS) { 171 - if (/* (inode->i_size >= NCP_MIN_SYMLINK_SIZE) 172 - && */ (inode->i_size <= NCP_MAX_SYMLINK_SIZE)) { 174 + if (/* (size >= NCP_MIN_SYMLINK_SIZE) 175 + && */ (size <= NCP_MAX_SYMLINK_SIZE)) { 173 176 inode->i_mode = (inode->i_mode & ~S_IFMT) | S_IFLNK; 174 177 NCP_FINFO(inode)->flags |= NCPI_KLUDGE_SYMLINK; 175 178 break; ··· 211 208 } 212 209 213 210 /* 214 - * Fill in the inode based on the ncp_entry_info structure. 211 + * Fill in the inode based on the ncp_entry_info structure. Used only for brand new inodes. 215 212 */ 216 213 static void ncp_set_attr(struct inode *inode, struct ncp_entry_info *nwinfo) 217 214 { ··· 257 254 if (inode) { 258 255 atomic_set(&NCP_FINFO(inode)->opened, info->opened); 259 256 257 + inode->i_mapping->backing_dev_info = sb->s_bdi; 260 258 inode->i_ino = info->ino; 261 259 ncp_set_attr(inode, info); 262 260 if (S_ISREG(inode->i_mode)) { ··· 303 299 304 300 static void ncp_stop_tasks(struct ncp_server *server) { 305 301 struct sock* sk = server->ncp_sock->sk; 306 - 302 + 303 + lock_sock(sk); 307 304 sk->sk_error_report = server->error_report; 308 305 sk->sk_data_ready = server->data_ready; 309 306 sk->sk_write_space = server->write_space; 307 + release_sock(sk); 310 308 del_timer_sync(&server->timeout_tm); 311 309 flush_scheduled_work(); 312 310 } ··· 571 565 /* server->conn_status = 0; */ 572 566 /* server->root_dentry = NULL; */ 573 567 /* server->root_setuped = 0; */ 568 + mutex_init(&server->root_setup_lock); 574 569 #ifdef CONFIG_NCPFS_PACKET_SIGNING 575 570 /* server->sign_wanted = 0; */ 576 571 /* server->sign_active = 0; */ 577 572 #endif 573 + init_rwsem(&server->auth_rwsem); 578 574 server->auth.auth_type = NCP_AUTH_NONE; 579 575 /* server->auth.object_name_len = 0; */ 580 576 /* server->auth.object_name = NULL; */ ··· 601 593 server->nls_io = load_nls_default(); 602 594 #endif /* CONFIG_NCPFS_NLS */ 603 595 604 - server->dentry_ttl = 0; /* no caching */ 596 + atomic_set(&server->dentry_ttl, 0); /* no caching */ 605 597 606 598 INIT_LIST_HEAD(&server->tx.requests); 607 599 mutex_init(&server->rcv.creq_mutex); 608 600 server->tx.creq = NULL; 609 601 server->rcv.creq = NULL; 610 - server->data_ready = sock->sk->sk_data_ready; 611 - server->write_space = sock->sk->sk_write_space; 612 - server->error_report = sock->sk->sk_error_report; 613 - sock->sk->sk_user_data = server; 614 602 615 603 init_timer(&server->timeout_tm); 616 604 #undef NCP_PACKET_SIZE ··· 623 619 if (server->rxbuf == NULL) 624 620 goto out_txbuf; 625 621 622 + lock_sock(sock->sk); 623 + server->data_ready = sock->sk->sk_data_ready; 624 + server->write_space = sock->sk->sk_write_space; 625 + server->error_report = sock->sk->sk_error_report; 626 + sock->sk->sk_user_data = server; 626 627 sock->sk->sk_data_ready = ncp_tcp_data_ready; 627 628 sock->sk->sk_error_report = ncp_tcp_error_report; 628 629 if (sock->type == SOCK_STREAM) { ··· 643 634 server->timeout_tm.data = (unsigned long)server; 644 635 server->timeout_tm.function = ncpdgram_timeout_call; 645 636 } 637 + release_sock(sock->sk); 646 638 647 639 ncp_lock_server(server); 648 640 error = ncp_connect(server); ··· 668 658 goto out_disconnect; 669 659 } 670 660 } 661 + ncp_lock_server(server); 671 662 if (options & 2) 672 663 server->sign_wanted = 1; 664 + ncp_unlock_server(server); 673 665 } 674 666 else 675 667 #endif /* CONFIG_NCPFS_PACKET_SIGNING */ ··· 732 720 unload_nls(server->nls_io); 733 721 unload_nls(server->nls_vol); 734 722 #endif 723 + mutex_destroy(&server->rcv.creq_mutex); 724 + mutex_destroy(&server->root_setup_lock); 725 + mutex_destroy(&server->mutex); 735 726 out_fput2: 736 727 if (server->info_filp) 737 728 fput(server->info_filp); ··· 758 743 { 759 744 struct ncp_server *server = NCP_SBP(sb); 760 745 761 - lock_kernel(); 762 - 763 746 ncp_lock_server(server); 764 747 ncp_disconnect(server); 765 748 ncp_unlock_server(server); ··· 769 756 unload_nls(server->nls_vol); 770 757 unload_nls(server->nls_io); 771 758 #endif /* CONFIG_NCPFS_NLS */ 759 + mutex_destroy(&server->rcv.creq_mutex); 760 + mutex_destroy(&server->root_setup_lock); 761 + mutex_destroy(&server->mutex); 772 762 773 763 if (server->info_filp) 774 764 fput(server->info_filp); ··· 787 771 vfree(server->packet); 788 772 sb->s_fs_info = NULL; 789 773 kfree(server); 790 - 791 - unlock_kernel(); 792 774 } 793 775 794 776 static int ncp_statfs(struct dentry *dentry, struct kstatfs *buf) ··· 865 851 866 852 result = -EIO; 867 853 868 - lock_kernel(); 869 - 870 854 server = NCP_SERVER(inode); 871 - if ((!server) || !ncp_conn_valid(server)) 855 + if (!server) /* How this could happen? */ 872 856 goto out; 873 857 874 858 /* ageing the dentry to force validation */ ··· 993 981 result = ncp_modify_file_or_subdir_dos_info(NCP_SERVER(inode), 994 982 inode, info_mask, &info); 995 983 if (result != 0) { 996 - result = -EACCES; 997 - 998 984 if (info_mask == (DM_CREATE_TIME | DM_CREATE_DATE)) { 999 985 /* NetWare seems not to allow this. I 1000 986 do not know why. So, just tell the ··· 1015 1005 mark_inode_dirty(inode); 1016 1006 1017 1007 out: 1018 - unlock_kernel(); 1008 + if (result > 0) 1009 + result = -EACCES; 1019 1010 return result; 1020 1011 } 1021 1012
+264 -224
fs/ncpfs/ioctl.c
··· 35 35 #define NCP_PACKET_SIZE_INTERNAL 65536 36 36 37 37 static int 38 - ncp_get_fs_info(struct ncp_server * server, struct file *file, 38 + ncp_get_fs_info(struct ncp_server * server, struct inode *inode, 39 39 struct ncp_fs_info __user *arg) 40 40 { 41 - struct inode *inode = file->f_path.dentry->d_inode; 42 41 struct ncp_fs_info info; 43 - 44 - if (file_permission(file, MAY_WRITE) != 0 45 - && current_uid() != server->m.mounted_uid) 46 - return -EACCES; 47 42 48 43 if (copy_from_user(&info, arg, sizeof(info))) 49 44 return -EFAULT; ··· 60 65 } 61 66 62 67 static int 63 - ncp_get_fs_info_v2(struct ncp_server * server, struct file *file, 68 + ncp_get_fs_info_v2(struct ncp_server * server, struct inode *inode, 64 69 struct ncp_fs_info_v2 __user * arg) 65 70 { 66 - struct inode *inode = file->f_path.dentry->d_inode; 67 71 struct ncp_fs_info_v2 info2; 68 - 69 - if (file_permission(file, MAY_WRITE) != 0 70 - && current_uid() != server->m.mounted_uid) 71 - return -EACCES; 72 72 73 73 if (copy_from_user(&info2, arg, sizeof(info2))) 74 74 return -EFAULT; ··· 126 136 #define NCP_IOC_SETPRIVATEDATA_32 _IOR('n', 10, struct compat_ncp_privatedata_ioctl) 127 137 128 138 static int 129 - ncp_get_compat_fs_info_v2(struct ncp_server * server, struct file *file, 139 + ncp_get_compat_fs_info_v2(struct ncp_server * server, struct inode *inode, 130 140 struct compat_ncp_fs_info_v2 __user * arg) 131 141 { 132 - struct inode *inode = file->f_path.dentry->d_inode; 133 142 struct compat_ncp_fs_info_v2 info2; 134 - 135 - if (file_permission(file, MAY_WRITE) != 0 136 - && current_uid() != server->m.mounted_uid) 137 - return -EACCES; 138 143 139 144 if (copy_from_user(&info2, arg, sizeof(info2))) 140 145 return -EFAULT; ··· 167 182 struct nls_table *iocharset; 168 183 struct nls_table *oldset_io; 169 184 struct nls_table *oldset_cp; 170 - 171 - if (!capable(CAP_SYS_ADMIN)) 172 - return -EACCES; 173 - if (server->root_setuped) 174 - return -EBUSY; 185 + int utf8; 186 + int err; 175 187 176 188 if (copy_from_user(&user, arg, sizeof(user))) 177 189 return -EFAULT; ··· 188 206 user.iocharset[NCP_IOCSNAME_LEN] = 0; 189 207 if (!user.iocharset[0] || !strcmp(user.iocharset, "default")) { 190 208 iocharset = load_nls_default(); 191 - NCP_CLR_FLAG(server, NCP_FLAG_UTF8); 209 + utf8 = 0; 192 210 } else if (!strcmp(user.iocharset, "utf8")) { 193 211 iocharset = load_nls_default(); 194 - NCP_SET_FLAG(server, NCP_FLAG_UTF8); 212 + utf8 = 1; 195 213 } else { 196 214 iocharset = load_nls(user.iocharset); 197 215 if (!iocharset) { 198 216 unload_nls(codepage); 199 217 return -EBADRQC; 200 218 } 201 - NCP_CLR_FLAG(server, NCP_FLAG_UTF8); 219 + utf8 = 0; 202 220 } 203 221 204 - oldset_cp = server->nls_vol; 205 - server->nls_vol = codepage; 206 - oldset_io = server->nls_io; 207 - server->nls_io = iocharset; 208 - 222 + mutex_lock(&server->root_setup_lock); 223 + if (server->root_setuped) { 224 + oldset_cp = codepage; 225 + oldset_io = iocharset; 226 + err = -EBUSY; 227 + } else { 228 + if (utf8) 229 + NCP_SET_FLAG(server, NCP_FLAG_UTF8); 230 + else 231 + NCP_CLR_FLAG(server, NCP_FLAG_UTF8); 232 + oldset_cp = server->nls_vol; 233 + server->nls_vol = codepage; 234 + oldset_io = server->nls_io; 235 + server->nls_io = iocharset; 236 + err = 0; 237 + } 238 + mutex_unlock(&server->root_setup_lock); 209 239 unload_nls(oldset_cp); 210 240 unload_nls(oldset_io); 211 241 212 - return 0; 242 + return err; 213 243 } 214 244 215 245 static int ··· 231 237 int len; 232 238 233 239 memset(&user, 0, sizeof(user)); 240 + mutex_lock(&server->root_setup_lock); 234 241 if (server->nls_vol && server->nls_vol->charset) { 235 242 len = strlen(server->nls_vol->charset); 236 243 if (len > NCP_IOCSNAME_LEN) ··· 249 254 strncpy(user.iocharset, server->nls_io->charset, len); 250 255 user.iocharset[len] = 0; 251 256 } 257 + mutex_unlock(&server->root_setup_lock); 252 258 253 259 if (copy_to_user(arg, &user, sizeof(user))) 254 260 return -EFAULT; ··· 257 261 } 258 262 #endif /* CONFIG_NCPFS_NLS */ 259 263 260 - static long __ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 264 + static long __ncp_ioctl(struct inode *inode, unsigned int cmd, unsigned long arg) 261 265 { 262 - struct inode *inode = filp->f_dentry->d_inode; 263 266 struct ncp_server *server = NCP_SERVER(inode); 264 267 int result; 265 268 struct ncp_ioctl_request request; 266 269 char* bouncebuffer; 267 270 void __user *argp = (void __user *)arg; 268 - uid_t uid = current_uid(); 269 271 270 272 switch (cmd) { 271 273 #ifdef CONFIG_COMPAT 272 274 case NCP_IOC_NCPREQUEST_32: 273 275 #endif 274 276 case NCP_IOC_NCPREQUEST: 275 - if (file_permission(filp, MAY_WRITE) != 0 276 - && uid != server->m.mounted_uid) 277 - return -EACCES; 278 - 279 277 #ifdef CONFIG_COMPAT 280 278 if (cmd == NCP_IOC_NCPREQUEST_32) { 281 279 struct compat_ncp_ioctl_request request32; ··· 304 314 server->current_size = request.size; 305 315 memcpy(server->packet, bouncebuffer, request.size); 306 316 307 - result = ncp_request2(server, request.function, 317 + result = ncp_request2(server, request.function, 308 318 bouncebuffer, NCP_PACKET_SIZE_INTERNAL); 309 319 if (result < 0) 310 320 result = -EIO; ··· 321 331 322 332 case NCP_IOC_CONN_LOGGED_IN: 323 333 324 - if (!capable(CAP_SYS_ADMIN)) 325 - return -EACCES; 326 334 if (!(server->m.int_flags & NCP_IMOUNT_LOGGEDIN_POSSIBLE)) 327 335 return -EINVAL; 336 + mutex_lock(&server->root_setup_lock); 328 337 if (server->root_setuped) 329 - return -EBUSY; 330 - server->root_setuped = 1; 331 - return ncp_conn_logged_in(inode->i_sb); 338 + result = -EBUSY; 339 + else { 340 + result = ncp_conn_logged_in(inode->i_sb); 341 + if (result == 0) 342 + server->root_setuped = 1; 343 + } 344 + mutex_unlock(&server->root_setup_lock); 345 + return result; 332 346 333 347 case NCP_IOC_GET_FS_INFO: 334 - return ncp_get_fs_info(server, filp, argp); 348 + return ncp_get_fs_info(server, inode, argp); 335 349 336 350 case NCP_IOC_GET_FS_INFO_V2: 337 - return ncp_get_fs_info_v2(server, filp, argp); 351 + return ncp_get_fs_info_v2(server, inode, argp); 338 352 339 353 #ifdef CONFIG_COMPAT 340 354 case NCP_IOC_GET_FS_INFO_V2_32: 341 - return ncp_get_compat_fs_info_v2(server, filp, argp); 355 + return ncp_get_compat_fs_info_v2(server, inode, argp); 342 356 #endif 343 357 /* we have too many combinations of CONFIG_COMPAT, 344 358 * CONFIG_64BIT and CONFIG_UID16, so just handle 345 359 * any of the possible ioctls */ 346 360 case NCP_IOC_GETMOUNTUID16: 347 - case NCP_IOC_GETMOUNTUID32: 348 - case NCP_IOC_GETMOUNTUID64: 349 - if (file_permission(filp, MAY_READ) != 0 350 - && uid != server->m.mounted_uid) 351 - return -EACCES; 352 - 353 - if (cmd == NCP_IOC_GETMOUNTUID16) { 361 + { 354 362 u16 uid; 363 + 355 364 SET_UID(uid, server->m.mounted_uid); 356 365 if (put_user(uid, (u16 __user *)argp)) 357 366 return -EFAULT; 358 - } else if (cmd == NCP_IOC_GETMOUNTUID32) { 359 - if (put_user(server->m.mounted_uid, 360 - (u32 __user *)argp)) 361 - return -EFAULT; 362 - } else { 363 - if (put_user(server->m.mounted_uid, 364 - (u64 __user *)argp)) 365 - return -EFAULT; 367 + return 0; 366 368 } 369 + case NCP_IOC_GETMOUNTUID32: 370 + if (put_user(server->m.mounted_uid, 371 + (u32 __user *)argp)) 372 + return -EFAULT; 373 + return 0; 374 + case NCP_IOC_GETMOUNTUID64: 375 + if (put_user(server->m.mounted_uid, 376 + (u64 __user *)argp)) 377 + return -EFAULT; 367 378 return 0; 368 379 369 380 case NCP_IOC_GETROOT: 370 381 { 371 382 struct ncp_setroot_ioctl sr; 372 383 373 - if (file_permission(filp, MAY_READ) != 0 374 - && uid != server->m.mounted_uid) 375 - return -EACCES; 376 - 384 + result = -EACCES; 385 + mutex_lock(&server->root_setup_lock); 377 386 if (server->m.mounted_vol[0]) { 378 387 struct dentry* dentry = inode->i_sb->s_root; 379 388 380 389 if (dentry) { 381 390 struct inode* s_inode = dentry->d_inode; 382 - 391 + 383 392 if (s_inode) { 384 393 sr.volNumber = NCP_FINFO(s_inode)->volNumber; 385 394 sr.dirEntNum = NCP_FINFO(s_inode)->dirEntNum; 386 395 sr.namespace = server->name_space[sr.volNumber]; 396 + result = 0; 387 397 } else 388 398 DPRINTK("ncpfs: s_root->d_inode==NULL\n"); 389 399 } else ··· 392 402 sr.volNumber = -1; 393 403 sr.namespace = 0; 394 404 sr.dirEntNum = 0; 405 + result = 0; 395 406 } 396 - if (copy_to_user(argp, &sr, sizeof(sr))) 397 - return -EFAULT; 398 - return 0; 407 + mutex_unlock(&server->root_setup_lock); 408 + if (!result && copy_to_user(argp, &sr, sizeof(sr))) 409 + result = -EFAULT; 410 + return result; 399 411 } 400 412 401 413 case NCP_IOC_SETROOT: ··· 408 416 __le32 dosde; 409 417 struct dentry* dentry; 410 418 411 - if (!capable(CAP_SYS_ADMIN)) 412 - { 413 - return -EACCES; 414 - } 415 - if (server->root_setuped) return -EBUSY; 416 419 if (copy_from_user(&sr, argp, sizeof(sr))) 417 420 return -EFAULT; 418 - if (sr.volNumber < 0) { 419 - server->m.mounted_vol[0] = 0; 420 - vnum = NCP_NUMBER_OF_VOLUMES; 421 - de = 0; 422 - dosde = 0; 423 - } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) { 424 - return -EINVAL; 425 - } else if (ncp_mount_subdir(server, sr.volNumber, 426 - sr.namespace, sr.dirEntNum, 427 - &vnum, &de, &dosde)) { 428 - return -ENOENT; 429 - } 430 - 431 - dentry = inode->i_sb->s_root; 432 - server->root_setuped = 1; 433 - if (dentry) { 434 - struct inode* s_inode = dentry->d_inode; 435 - 436 - if (s_inode) { 437 - NCP_FINFO(s_inode)->volNumber = vnum; 438 - NCP_FINFO(s_inode)->dirEntNum = de; 439 - NCP_FINFO(s_inode)->DosDirNum = dosde; 421 + mutex_lock(&server->root_setup_lock); 422 + if (server->root_setuped) 423 + result = -EBUSY; 424 + else { 425 + if (sr.volNumber < 0) { 426 + server->m.mounted_vol[0] = 0; 427 + vnum = NCP_NUMBER_OF_VOLUMES; 428 + de = 0; 429 + dosde = 0; 430 + result = 0; 431 + } else if (sr.volNumber >= NCP_NUMBER_OF_VOLUMES) { 432 + result = -EINVAL; 433 + } else if (ncp_mount_subdir(server, sr.volNumber, 434 + sr.namespace, sr.dirEntNum, 435 + &vnum, &de, &dosde)) { 436 + result = -ENOENT; 440 437 } else 441 - DPRINTK("ncpfs: s_root->d_inode==NULL\n"); 442 - } else 443 - DPRINTK("ncpfs: s_root==NULL\n"); 438 + result = 0; 444 439 440 + if (result == 0) { 441 + dentry = inode->i_sb->s_root; 442 + if (dentry) { 443 + struct inode* s_inode = dentry->d_inode; 444 + 445 + if (s_inode) { 446 + NCP_FINFO(s_inode)->volNumber = vnum; 447 + NCP_FINFO(s_inode)->dirEntNum = de; 448 + NCP_FINFO(s_inode)->DosDirNum = dosde; 449 + server->root_setuped = 1; 450 + } else { 451 + DPRINTK("ncpfs: s_root->d_inode==NULL\n"); 452 + result = -EIO; 453 + } 454 + } else { 455 + DPRINTK("ncpfs: s_root==NULL\n"); 456 + result = -EIO; 457 + } 458 + } 459 + result = 0; 460 + } 461 + mutex_unlock(&server->root_setup_lock); 462 + 463 + return result; 464 + } 465 + 466 + #ifdef CONFIG_NCPFS_PACKET_SIGNING 467 + case NCP_IOC_SIGN_INIT: 468 + { 469 + struct ncp_sign_init sign; 470 + 471 + if (argp) 472 + if (copy_from_user(&sign, argp, sizeof(sign))) 473 + return -EFAULT; 474 + ncp_lock_server(server); 475 + mutex_lock(&server->rcv.creq_mutex); 476 + if (argp) { 477 + if (server->sign_wanted) { 478 + memcpy(server->sign_root,sign.sign_root,8); 479 + memcpy(server->sign_last,sign.sign_last,16); 480 + server->sign_active = 1; 481 + } 482 + /* ignore when signatures not wanted */ 483 + } else { 484 + server->sign_active = 0; 485 + } 486 + mutex_unlock(&server->rcv.creq_mutex); 487 + ncp_unlock_server(server); 445 488 return 0; 446 489 } 447 490 448 - #ifdef CONFIG_NCPFS_PACKET_SIGNING 449 - case NCP_IOC_SIGN_INIT: 450 - if (file_permission(filp, MAY_WRITE) != 0 451 - && uid != server->m.mounted_uid) 452 - return -EACCES; 453 - 454 - if (argp) { 455 - if (server->sign_wanted) 456 - { 457 - struct ncp_sign_init sign; 458 - 459 - if (copy_from_user(&sign, argp, sizeof(sign))) 460 - return -EFAULT; 461 - memcpy(server->sign_root,sign.sign_root,8); 462 - memcpy(server->sign_last,sign.sign_last,16); 463 - server->sign_active = 1; 464 - } 465 - /* ignore when signatures not wanted */ 466 - } else { 467 - server->sign_active = 0; 468 - } 469 - return 0; 470 - 471 491 case NCP_IOC_SIGN_WANTED: 472 - if (file_permission(filp, MAY_READ) != 0 473 - && uid != server->m.mounted_uid) 474 - return -EACCES; 475 - 476 - if (put_user(server->sign_wanted, (int __user *)argp)) 477 - return -EFAULT; 478 - return 0; 492 + { 493 + int state; 494 + 495 + ncp_lock_server(server); 496 + state = server->sign_wanted; 497 + ncp_unlock_server(server); 498 + if (put_user(state, (int __user *)argp)) 499 + return -EFAULT; 500 + return 0; 501 + } 479 502 480 503 case NCP_IOC_SET_SIGN_WANTED: 481 504 { 482 505 int newstate; 483 506 484 - if (file_permission(filp, MAY_WRITE) != 0 485 - && uid != server->m.mounted_uid) 486 - return -EACCES; 487 - 488 507 /* get only low 8 bits... */ 489 508 if (get_user(newstate, (unsigned char __user *)argp)) 490 509 return -EFAULT; 510 + result = 0; 511 + ncp_lock_server(server); 491 512 if (server->sign_active) { 492 513 /* cannot turn signatures OFF when active */ 493 - if (!newstate) return -EINVAL; 514 + if (!newstate) 515 + result = -EINVAL; 494 516 } else { 495 517 server->sign_wanted = newstate != 0; 496 518 } 497 - return 0; 519 + ncp_unlock_server(server); 520 + return result; 498 521 } 499 522 500 523 #endif /* CONFIG_NCPFS_PACKET_SIGNING */ 501 524 502 525 #ifdef CONFIG_NCPFS_IOCTL_LOCKING 503 526 case NCP_IOC_LOCKUNLOCK: 504 - if (file_permission(filp, MAY_WRITE) != 0 505 - && uid != server->m.mounted_uid) 506 - return -EACCES; 507 - 508 527 { 509 528 struct ncp_lock_ioctl rqdata; 510 529 ··· 544 541 { 545 542 return result; 546 543 } 547 - result = -EIO; 548 - if (!ncp_conn_valid(server)) 549 - goto outrel; 550 544 result = -EISDIR; 551 545 if (!S_ISREG(inode->i_mode)) 552 546 goto outrel; 553 547 if (rqdata.cmd == NCP_LOCK_CLEAR) 554 548 { 555 549 result = ncp_ClearPhysicalRecord(NCP_SERVER(inode), 556 - NCP_FINFO(inode)->file_handle, 550 + NCP_FINFO(inode)->file_handle, 557 551 rqdata.offset, 558 552 rqdata.length); 559 553 if (result > 0) result = 0; /* no such lock */ ··· 573 573 rqdata.timeout); 574 574 if (result > 0) result = -EAGAIN; 575 575 } 576 - outrel: 576 + outrel: 577 577 ncp_inode_close(inode); 578 578 return result; 579 579 } ··· 581 581 582 582 #ifdef CONFIG_COMPAT 583 583 case NCP_IOC_GETOBJECTNAME_32: 584 - if (uid != server->m.mounted_uid) 585 - return -EACCES; 586 584 { 587 585 struct compat_ncp_objectname_ioctl user; 588 586 size_t outl; 589 587 590 588 if (copy_from_user(&user, argp, sizeof(user))) 591 589 return -EFAULT; 590 + down_read(&server->auth_rwsem); 592 591 user.auth_type = server->auth.auth_type; 593 592 outl = user.object_name_len; 594 593 user.object_name_len = server->auth.object_name_len; 595 594 if (outl > user.object_name_len) 596 595 outl = user.object_name_len; 596 + result = 0; 597 597 if (outl) { 598 598 if (copy_to_user(compat_ptr(user.object_name), 599 599 server->auth.object_name, 600 - outl)) return -EFAULT; 600 + outl)) 601 + result = -EFAULT; 601 602 } 602 - if (copy_to_user(argp, &user, sizeof(user))) 603 - return -EFAULT; 604 - return 0; 603 + up_read(&server->auth_rwsem); 604 + if (!result && copy_to_user(argp, &user, sizeof(user))) 605 + result = -EFAULT; 606 + return result; 605 607 } 606 608 #endif 607 609 608 610 case NCP_IOC_GETOBJECTNAME: 609 - if (uid != server->m.mounted_uid) 610 - return -EACCES; 611 611 { 612 612 struct ncp_objectname_ioctl user; 613 613 size_t outl; 614 614 615 615 if (copy_from_user(&user, argp, sizeof(user))) 616 616 return -EFAULT; 617 + down_read(&server->auth_rwsem); 617 618 user.auth_type = server->auth.auth_type; 618 619 outl = user.object_name_len; 619 620 user.object_name_len = server->auth.object_name_len; 620 621 if (outl > user.object_name_len) 621 622 outl = user.object_name_len; 623 + result = 0; 622 624 if (outl) { 623 625 if (copy_to_user(user.object_name, 624 626 server->auth.object_name, 625 - outl)) return -EFAULT; 627 + outl)) 628 + result = -EFAULT; 626 629 } 627 - if (copy_to_user(argp, &user, sizeof(user))) 628 - return -EFAULT; 629 - return 0; 630 + up_read(&server->auth_rwsem); 631 + if (!result && copy_to_user(argp, &user, sizeof(user))) 632 + result = -EFAULT; 633 + return result; 630 634 } 631 635 632 636 #ifdef CONFIG_COMPAT 633 637 case NCP_IOC_SETOBJECTNAME_32: 634 638 #endif 635 639 case NCP_IOC_SETOBJECTNAME: 636 - if (uid != server->m.mounted_uid) 637 - return -EACCES; 638 640 { 639 641 struct ncp_objectname_ioctl user; 640 642 void* newname; ··· 668 666 } else { 669 667 newname = NULL; 670 668 } 671 - /* enter critical section */ 672 - /* maybe that kfree can sleep so do that this way */ 673 - /* it is at least more SMP friendly (in future...) */ 669 + down_write(&server->auth_rwsem); 674 670 oldname = server->auth.object_name; 675 671 oldnamelen = server->auth.object_name_len; 676 672 oldprivate = server->priv.data; ··· 678 678 server->auth.object_name = newname; 679 679 server->priv.len = 0; 680 680 server->priv.data = NULL; 681 - /* leave critical section */ 681 + up_write(&server->auth_rwsem); 682 682 kfree(oldprivate); 683 683 kfree(oldname); 684 684 return 0; ··· 688 688 case NCP_IOC_GETPRIVATEDATA_32: 689 689 #endif 690 690 case NCP_IOC_GETPRIVATEDATA: 691 - if (uid != server->m.mounted_uid) 692 - return -EACCES; 693 691 { 694 692 struct ncp_privatedata_ioctl user; 695 693 size_t outl; ··· 704 706 if (copy_from_user(&user, argp, sizeof(user))) 705 707 return -EFAULT; 706 708 709 + down_read(&server->auth_rwsem); 707 710 outl = user.len; 708 711 user.len = server->priv.len; 709 712 if (outl > user.len) outl = user.len; 713 + result = 0; 710 714 if (outl) { 711 715 if (copy_to_user(user.data, 712 716 server->priv.data, 713 - outl)) return -EFAULT; 717 + outl)) 718 + result = -EFAULT; 714 719 } 720 + up_read(&server->auth_rwsem); 721 + if (result) 722 + return result; 715 723 #ifdef CONFIG_COMPAT 716 724 if (cmd == NCP_IOC_GETPRIVATEDATA_32) { 717 725 struct compat_ncp_privatedata_ioctl user32; ··· 737 733 case NCP_IOC_SETPRIVATEDATA_32: 738 734 #endif 739 735 case NCP_IOC_SETPRIVATEDATA: 740 - if (uid != server->m.mounted_uid) 741 - return -EACCES; 742 736 { 743 737 struct ncp_privatedata_ioctl user; 744 738 void* new; ··· 764 762 } else { 765 763 new = NULL; 766 764 } 767 - /* enter critical section */ 765 + down_write(&server->auth_rwsem); 768 766 old = server->priv.data; 769 767 oldlen = server->priv.len; 770 768 server->priv.len = user.len; 771 769 server->priv.data = new; 772 - /* leave critical section */ 770 + up_write(&server->auth_rwsem); 773 771 kfree(old); 774 772 return 0; 775 773 } ··· 777 775 #ifdef CONFIG_NCPFS_NLS 778 776 case NCP_IOC_SETCHARSETS: 779 777 return ncp_set_charsets(server, argp); 780 - 778 + 781 779 case NCP_IOC_GETCHARSETS: 782 780 return ncp_get_charsets(server, argp); 783 781 784 782 #endif /* CONFIG_NCPFS_NLS */ 785 783 786 784 case NCP_IOC_SETDENTRYTTL: 787 - if (file_permission(filp, MAY_WRITE) != 0 && 788 - uid != server->m.mounted_uid) 789 - return -EACCES; 790 - 791 785 { 792 786 u_int32_t user; 793 787 ··· 793 795 if (user > 20000) 794 796 return -EINVAL; 795 797 user = (user * HZ) / 1000; 796 - server->dentry_ttl = user; 798 + atomic_set(&server->dentry_ttl, user); 797 799 return 0; 798 800 } 799 - 801 + 800 802 case NCP_IOC_GETDENTRYTTL: 801 803 { 802 - u_int32_t user = (server->dentry_ttl * 1000) / HZ; 804 + u_int32_t user = (atomic_read(&server->dentry_ttl) * 1000) / HZ; 803 805 if (copy_to_user(argp, &user, sizeof(user))) 804 806 return -EFAULT; 805 807 return 0; ··· 809 811 return -EINVAL; 810 812 } 811 813 812 - static int ncp_ioctl_need_write(unsigned int cmd) 813 - { 814 - switch (cmd) { 815 - case NCP_IOC_GET_FS_INFO: 816 - case NCP_IOC_GET_FS_INFO_V2: 817 - case NCP_IOC_NCPREQUEST: 818 - case NCP_IOC_SETDENTRYTTL: 819 - case NCP_IOC_SIGN_INIT: 820 - case NCP_IOC_LOCKUNLOCK: 821 - case NCP_IOC_SET_SIGN_WANTED: 822 - return 1; 823 - case NCP_IOC_GETOBJECTNAME: 824 - case NCP_IOC_SETOBJECTNAME: 825 - case NCP_IOC_GETPRIVATEDATA: 826 - case NCP_IOC_SETPRIVATEDATA: 827 - case NCP_IOC_SETCHARSETS: 828 - case NCP_IOC_GETCHARSETS: 829 - case NCP_IOC_CONN_LOGGED_IN: 830 - case NCP_IOC_GETDENTRYTTL: 831 - case NCP_IOC_GETMOUNTUID2: 832 - case NCP_IOC_SIGN_WANTED: 833 - case NCP_IOC_GETROOT: 834 - case NCP_IOC_SETROOT: 835 - return 0; 836 - default: 837 - /* unknown IOCTL command, assume write */ 838 - return 1; 839 - } 840 - } 841 - 842 814 long ncp_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) 843 815 { 816 + struct inode *inode = filp->f_dentry->d_inode; 817 + struct ncp_server *server = NCP_SERVER(inode); 818 + uid_t uid = current_uid(); 819 + int need_drop_write = 0; 844 820 long ret; 845 821 846 - lock_kernel(); 847 - if (ncp_ioctl_need_write(cmd)) { 848 - /* 849 - * inside the ioctl(), any failures which 850 - * are because of file_permission() are 851 - * -EACCESS, so it seems consistent to keep 852 - * that here. 853 - */ 854 - if (mnt_want_write(filp->f_path.mnt)) { 822 + switch (cmd) { 823 + case NCP_IOC_SETCHARSETS: 824 + case NCP_IOC_CONN_LOGGED_IN: 825 + case NCP_IOC_SETROOT: 826 + if (!capable(CAP_SYS_ADMIN)) { 855 827 ret = -EACCES; 856 828 goto out; 857 829 } 830 + break; 858 831 } 859 - ret = __ncp_ioctl(filp, cmd, arg); 860 - if (ncp_ioctl_need_write(cmd)) 832 + if (server->m.mounted_uid != uid) { 833 + switch (cmd) { 834 + /* 835 + * Only mount owner can issue these ioctls. Information 836 + * necessary to authenticate to other NDS servers are 837 + * stored here. 838 + */ 839 + case NCP_IOC_GETOBJECTNAME: 840 + case NCP_IOC_SETOBJECTNAME: 841 + case NCP_IOC_GETPRIVATEDATA: 842 + case NCP_IOC_SETPRIVATEDATA: 843 + #ifdef CONFIG_COMPAT 844 + case NCP_IOC_GETOBJECTNAME_32: 845 + case NCP_IOC_SETOBJECTNAME_32: 846 + case NCP_IOC_GETPRIVATEDATA_32: 847 + case NCP_IOC_SETPRIVATEDATA_32: 848 + #endif 849 + ret = -EACCES; 850 + goto out; 851 + /* 852 + * These require write access on the inode if user id 853 + * does not match. Note that they do not write to the 854 + * file... But old code did mnt_want_write, so I keep 855 + * it as is. Of course not for mountpoint owner, as 856 + * that breaks read-only mounts altogether as ncpmount 857 + * needs working NCP_IOC_NCPREQUEST and 858 + * NCP_IOC_GET_FS_INFO. Some of these codes (setdentryttl, 859 + * signinit, setsignwanted) should be probably restricted 860 + * to owner only, or even more to CAP_SYS_ADMIN). 861 + */ 862 + case NCP_IOC_GET_FS_INFO: 863 + case NCP_IOC_GET_FS_INFO_V2: 864 + case NCP_IOC_NCPREQUEST: 865 + case NCP_IOC_SETDENTRYTTL: 866 + case NCP_IOC_SIGN_INIT: 867 + case NCP_IOC_LOCKUNLOCK: 868 + case NCP_IOC_SET_SIGN_WANTED: 869 + #ifdef CONFIG_COMPAT 870 + case NCP_IOC_GET_FS_INFO_V2_32: 871 + case NCP_IOC_NCPREQUEST_32: 872 + #endif 873 + ret = mnt_want_write_file(filp); 874 + if (ret) 875 + goto out; 876 + need_drop_write = 1; 877 + ret = inode_permission(inode, MAY_WRITE); 878 + if (ret) 879 + goto outDropWrite; 880 + break; 881 + /* 882 + * Read access required. 883 + */ 884 + case NCP_IOC_GETMOUNTUID16: 885 + case NCP_IOC_GETMOUNTUID32: 886 + case NCP_IOC_GETMOUNTUID64: 887 + case NCP_IOC_GETROOT: 888 + case NCP_IOC_SIGN_WANTED: 889 + ret = inode_permission(inode, MAY_READ); 890 + if (ret) 891 + goto out; 892 + break; 893 + /* 894 + * Anybody can read these. 895 + */ 896 + case NCP_IOC_GETCHARSETS: 897 + case NCP_IOC_GETDENTRYTTL: 898 + default: 899 + /* Three codes below are protected by CAP_SYS_ADMIN above. */ 900 + case NCP_IOC_SETCHARSETS: 901 + case NCP_IOC_CONN_LOGGED_IN: 902 + case NCP_IOC_SETROOT: 903 + break; 904 + } 905 + } 906 + ret = __ncp_ioctl(inode, cmd, arg); 907 + outDropWrite: 908 + if (need_drop_write) 861 909 mnt_drop_write(filp->f_path.mnt); 862 - 863 910 out: 864 - unlock_kernel(); 865 911 return ret; 866 912 } 867 913 ··· 914 872 { 915 873 long ret; 916 874 917 - lock_kernel(); 918 875 arg = (unsigned long) compat_ptr(arg); 919 876 ret = ncp_ioctl(file, cmd, arg); 920 - unlock_kernel(); 921 877 return ret; 922 878 } 923 879 #endif
+56 -45
fs/ncpfs/ncplib_kernel.c
··· 107 107 return &(server->packet[sizeof(struct ncp_reply_header) + offset]); 108 108 } 109 109 110 - static inline u8 BVAL(void *data) 110 + static inline u8 BVAL(const void *data) 111 111 { 112 - return *(u8 *)data; 112 + return *(const u8 *)data; 113 113 } 114 114 115 115 static u8 ncp_reply_byte(struct ncp_server *server, int offset) 116 116 { 117 - return *(u8 *)ncp_reply_data(server, offset); 117 + return *(const u8 *)ncp_reply_data(server, offset); 118 118 } 119 119 120 - static inline u16 WVAL_LH(void *data) 120 + static inline u16 WVAL_LH(const void *data) 121 121 { 122 122 return get_unaligned_le16(data); 123 123 } ··· 134 134 return get_unaligned_be16(ncp_reply_data(server, offset)); 135 135 } 136 136 137 - static inline u32 DVAL_LH(void *data) 137 + static inline u32 DVAL_LH(const void *data) 138 138 { 139 139 return get_unaligned_le32(data); 140 140 } ··· 349 349 return result; 350 350 } 351 351 352 - void ncp_extract_file_info(void *structure, struct nw_info_struct *target) 352 + void ncp_extract_file_info(const void *structure, struct nw_info_struct *target) 353 353 { 354 - __u8 *name_len; 354 + const __u8 *name_len; 355 355 const int info_struct_size = offsetof(struct nw_info_struct, nameLen); 356 356 357 357 memcpy(target, structure, info_struct_size); ··· 364 364 } 365 365 366 366 #ifdef CONFIG_NCPFS_NFS_NS 367 - static inline void ncp_extract_nfs_info(unsigned char *structure, 367 + static inline void ncp_extract_nfs_info(const unsigned char *structure, 368 368 struct nw_nfs_info *target) 369 369 { 370 370 target->mode = DVAL_LH(structure); ··· 417 417 * Returns information for a (one-component) name relative to 418 418 * the specified directory. 419 419 */ 420 - int ncp_obtain_info(struct ncp_server *server, struct inode *dir, char *path, 420 + int ncp_obtain_info(struct ncp_server *server, struct inode *dir, const char *path, 421 421 struct nw_info_struct *target) 422 422 { 423 423 __u8 volnum = NCP_FINFO(dir)->volNumber; ··· 452 452 #ifdef CONFIG_NCPFS_NFS_NS 453 453 static int 454 454 ncp_obtain_DOS_dir_base(struct ncp_server *server, 455 - __u8 volnum, __le32 dirent, 456 - char *path, /* At most 1 component */ 455 + __u8 ns, __u8 volnum, __le32 dirent, 456 + const char *path, /* At most 1 component */ 457 457 __le32 *DOS_dir_base) 458 458 { 459 459 int result; 460 460 461 461 ncp_init_request(server); 462 462 ncp_add_byte(server, 6); /* subfunction */ 463 - ncp_add_byte(server, server->name_space[volnum]); 464 - ncp_add_byte(server, server->name_space[volnum]); 463 + ncp_add_byte(server, ns); 464 + ncp_add_byte(server, ns); 465 465 ncp_add_word(server, cpu_to_le16(0x8006)); /* get all */ 466 466 ncp_add_dword(server, RIM_DIRECTORY); 467 467 ncp_add_handle_path(server, volnum, dirent, 1, path); ··· 523 523 #endif /* defined(CONFIG_NCPFS_OS2_NS) || defined(CONFIG_NCPFS_NFS_NS) */ 524 524 } 525 525 526 + int 527 + ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns) 528 + { 529 + int ns = ncp_get_known_namespace(server, volume); 530 + 531 + if (ret_ns) 532 + *ret_ns = ns; 533 + 534 + DPRINTK("lookup_vol: namespace[%d] = %d\n", 535 + volume, server->name_space[volume]); 536 + 537 + if (server->name_space[volume] == ns) 538 + return 0; 539 + server->name_space[volume] = ns; 540 + return 1; 541 + } 542 + 526 543 static int 527 544 ncp_ObtainSpecificDirBase(struct ncp_server *server, 528 545 __u8 nsSrc, __u8 nsDst, __u8 vol_num, __le32 dir_base, 529 - char *path, /* At most 1 component */ 546 + const char *path, /* At most 1 component */ 530 547 __le32 *dirEntNum, __le32 *DosDirNum) 531 548 { 532 549 int result; ··· 577 560 { 578 561 int dstNS; 579 562 int result; 580 - 581 - dstNS = ncp_get_known_namespace(server, volNumber); 563 + 564 + ncp_update_known_namespace(server, volNumber, &dstNS); 582 565 if ((result = ncp_ObtainSpecificDirBase(server, srcNS, dstNS, volNumber, 583 566 dirEntNum, NULL, newDirEnt, newDosEnt)) != 0) 584 567 { 585 568 return result; 586 569 } 587 - server->name_space[volNumber] = dstNS; 588 570 *volume = volNumber; 589 571 server->m.mounted_vol[1] = 0; 590 572 server->m.mounted_vol[0] = 'X'; ··· 591 575 } 592 576 593 577 int 594 - ncp_get_volume_root(struct ncp_server *server, const char *volname, 595 - __u32* volume, __le32* dirent, __le32* dosdirent) 578 + ncp_get_volume_root(struct ncp_server *server, 579 + const char *volname, __u32* volume, __le32* dirent, __le32* dosdirent) 596 580 { 597 581 int result; 598 - __u8 volnum; 599 582 600 583 DPRINTK("ncp_get_volume_root: looking up vol %s\n", volname); 601 584 ··· 616 601 return result; 617 602 } 618 603 *dirent = *dosdirent = ncp_reply_dword(server, 4); 619 - volnum = ncp_reply_byte(server, 8); 604 + *volume = ncp_reply_byte(server, 8); 620 605 ncp_unlock_server(server); 621 - *volume = volnum; 622 - 623 - server->name_space[volnum] = ncp_get_known_namespace(server, volnum); 624 - 625 - DPRINTK("lookup_vol: namespace[%d] = %d\n", 626 - volnum, server->name_space[volnum]); 627 - 628 606 return 0; 629 607 } 630 608 631 609 int 632 - ncp_lookup_volume(struct ncp_server *server, const char *volname, 633 - struct nw_info_struct *target) 610 + ncp_lookup_volume(struct ncp_server *server, 611 + const char *volname, struct nw_info_struct *target) 634 612 { 635 613 int result; 636 614 ··· 633 625 if (result) { 634 626 return result; 635 627 } 628 + ncp_update_known_namespace(server, target->volNumber, NULL); 636 629 target->nameLen = strlen(volname); 637 630 memcpy(target->entryName, volname, target->nameLen+1); 638 631 target->attributes = aDIR; ··· 685 676 { 686 677 int result = 0; 687 678 679 + ncp_init_request(server); 688 680 if (server->name_space[volnum] == NW_NS_NFS) { 689 - ncp_init_request(server); 690 681 ncp_add_byte(server, 25); /* subfunction */ 691 682 ncp_add_byte(server, server->name_space[volnum]); 692 683 ncp_add_byte(server, NW_NS_NFS); ··· 699 690 ncp_add_dword_lh(server, 1); /* nlinks */ 700 691 ncp_add_dword_lh(server, rdev); 701 692 result = ncp_request(server, 87); 702 - ncp_unlock_server(server); 703 693 } 694 + ncp_unlock_server(server); 704 695 return result; 705 696 } 706 697 #endif ··· 709 700 static int 710 701 ncp_DeleteNSEntry(struct ncp_server *server, 711 702 __u8 have_dir_base, __u8 volnum, __le32 dirent, 712 - char* name, __u8 ns, __le16 attr) 703 + const char* name, __u8 ns, __le16 attr) 713 704 { 714 705 int result; 715 706 ··· 743 734 744 735 int 745 736 ncp_del_file_or_subdir(struct ncp_server *server, 746 - struct inode *dir, char *name) 737 + struct inode *dir, const char *name) 747 738 { 748 739 __u8 volnum = NCP_FINFO(dir)->volNumber; 749 740 __le32 dirent = NCP_FINFO(dir)->dirEntNum; 741 + int name_space; 750 742 743 + name_space = server->name_space[volnum]; 751 744 #ifdef CONFIG_NCPFS_NFS_NS 752 - if (server->name_space[volnum]==NW_NS_NFS) 745 + if (name_space == NW_NS_NFS) 753 746 { 754 747 int result; 755 748 756 - result=ncp_obtain_DOS_dir_base(server, volnum, dirent, name, &dirent); 749 + result=ncp_obtain_DOS_dir_base(server, name_space, volnum, dirent, name, &dirent); 757 750 if (result) return result; 758 - return ncp_DeleteNSEntry(server, 1, volnum, dirent, NULL, NW_NS_DOS, cpu_to_le16(0x8006)); 751 + name = NULL; 752 + name_space = NW_NS_DOS; 759 753 } 760 - else 761 754 #endif /* CONFIG_NCPFS_NFS_NS */ 762 - return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, server->name_space[volnum], cpu_to_le16(0x8006)); 755 + return ncp_DeleteNSEntry(server, 1, volnum, dirent, name, name_space, cpu_to_le16(0x8006)); 763 756 } 764 757 765 758 static inline void ConvertToNWfromDWORD(__u16 v0, __u16 v1, __u8 ret[6]) ··· 776 765 /* If both dir and name are NULL, then in target there's already a 777 766 looked-up entry that wants to be opened. */ 778 767 int ncp_open_create_file_or_subdir(struct ncp_server *server, 779 - struct inode *dir, char *name, 768 + struct inode *dir, const char *name, 780 769 int open_create_mode, 781 770 __le32 create_attributes, 782 771 __le16 desired_acc_rights, ··· 901 890 902 891 static int 903 892 ncp_RenameNSEntry(struct ncp_server *server, 904 - struct inode *old_dir, char *old_name, __le16 old_type, 905 - struct inode *new_dir, char *new_name) 893 + struct inode *old_dir, const char *old_name, __le16 old_type, 894 + struct inode *new_dir, const char *new_name) 906 895 { 907 896 int result = -EINVAL; 908 897 ··· 940 929 } 941 930 942 931 int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, 943 - struct inode *old_dir, char *old_name, 944 - struct inode *new_dir, char *new_name) 932 + struct inode *old_dir, const char *old_name, 933 + struct inode *new_dir, const char *new_name) 945 934 { 946 935 int result; 947 936 __le16 old_type = cpu_to_le16(0x06); ··· 969 958 ncp_read_kernel(struct ncp_server *server, const char *file_id, 970 959 __u32 offset, __u16 to_read, char *target, int *bytes_read) 971 960 { 972 - char *source; 961 + const char *source; 973 962 int result; 974 963 975 964 ncp_init_request(server);
+8 -7
fs/ncpfs/ncplib_kernel.h
··· 65 65 atomic_dec(&NCP_FINFO(inode)->opened); 66 66 } 67 67 68 - void ncp_extract_file_info(void* src, struct nw_info_struct* target); 69 - int ncp_obtain_info(struct ncp_server *server, struct inode *, char *, 68 + void ncp_extract_file_info(const void* src, struct nw_info_struct* target); 69 + int ncp_obtain_info(struct ncp_server *server, struct inode *, const char *, 70 70 struct nw_info_struct *target); 71 71 int ncp_obtain_nfs_info(struct ncp_server *server, struct nw_info_struct *target); 72 + int ncp_update_known_namespace(struct ncp_server *server, __u8 volume, int *ret_ns); 72 73 int ncp_get_volume_root(struct ncp_server *server, const char *volname, 73 74 __u32 *volume, __le32 *dirent, __le32 *dosdirent); 74 75 int ncp_lookup_volume(struct ncp_server *, const char *, struct nw_info_struct *); ··· 81 80 __u32 mode, __u32 rdev); 82 81 83 82 int ncp_del_file_or_subdir2(struct ncp_server *, struct dentry*); 84 - int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, char *); 85 - int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, char *, 83 + int ncp_del_file_or_subdir(struct ncp_server *, struct inode *, const char *); 84 + int ncp_open_create_file_or_subdir(struct ncp_server *, struct inode *, const char *, 86 85 int, __le32, __le16, struct ncp_entry_info *); 87 86 88 87 int ncp_initialize_search(struct ncp_server *, struct inode *, ··· 94 93 char** rbuf, size_t* rsize); 95 94 96 95 int ncp_ren_or_mov_file_or_subdir(struct ncp_server *server, 97 - struct inode *, char *, struct inode *, char *); 96 + struct inode *, const char *, struct inode *, const char *); 98 97 99 98 100 99 int ··· 171 170 #endif /* CONFIG_NCPFS_NLS */ 172 171 173 172 #define NCP_GET_AGE(dentry) (jiffies - (dentry)->d_time) 174 - #define NCP_MAX_AGE(server) ((server)->dentry_ttl) 173 + #define NCP_MAX_AGE(server) atomic_read(&(server)->dentry_ttl) 175 174 #define NCP_TEST_AGE(server,dentry) (NCP_GET_AGE(dentry) < NCP_MAX_AGE(server)) 176 175 177 176 static inline void 178 177 ncp_age_dentry(struct ncp_server* server, struct dentry* dentry) 179 178 { 180 - dentry->d_time = jiffies - server->dentry_ttl; 179 + dentry->d_time = jiffies - NCP_MAX_AGE(server); 181 180 } 182 181 183 182 static inline void
+5 -5
fs/ncpfs/ncpsign_kernel.c
··· 15 15 16 16 /* i386: 32-bit, little endian, handles mis-alignment */ 17 17 #ifdef __i386__ 18 - #define GET_LE32(p) (*(int *)(p)) 18 + #define GET_LE32(p) (*(const int *)(p)) 19 19 #define PUT_LE32(p,v) { *(int *)(p)=v; } 20 20 #else 21 21 /* from include/ncplib.h */ 22 - #define BVAL(buf,pos) (((__u8 *)(buf))[pos]) 22 + #define BVAL(buf,pos) (((const __u8 *)(buf))[pos]) 23 23 #define PVAL(buf,pos) ((unsigned)BVAL(buf,pos)) 24 - #define BSET(buf,pos,val) (BVAL(buf,pos) = (val)) 24 + #define BSET(buf,pos,val) (((__u8 *)(buf))[pos] = (val)) 25 25 26 26 static inline __u16 27 - WVAL_LH(__u8 * buf, int pos) 27 + WVAL_LH(const __u8 * buf, int pos) 28 28 { 29 29 return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8; 30 30 } 31 31 static inline __u32 32 - DVAL_LH(__u8 * buf, int pos) 32 + DVAL_LH(const __u8 * buf, int pos) 33 33 { 34 34 return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16; 35 35 }
-1
fs/ncpfs/sock.c
··· 746 746 return -EIO; 747 747 } 748 748 if (!ncp_conn_valid(server)) { 749 - printk(KERN_ERR "ncpfs: Connection invalid!\n"); 750 749 return -EIO; 751 750 } 752 751 {
+5 -5
fs/nfs/delegation.c
··· 71 71 if (inode->i_flock == NULL) 72 72 goto out; 73 73 74 - /* Protect inode->i_flock using the BKL */ 75 - lock_kernel(); 74 + /* Protect inode->i_flock using the file locks lock */ 75 + lock_flocks(); 76 76 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 77 77 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) 78 78 continue; 79 79 if (nfs_file_open_context(fl->fl_file) != ctx) 80 80 continue; 81 - unlock_kernel(); 81 + unlock_flocks(); 82 82 status = nfs4_lock_delegation_recall(state, fl); 83 83 if (status < 0) 84 84 goto out; 85 - lock_kernel(); 85 + lock_flocks(); 86 86 } 87 - unlock_kernel(); 87 + unlock_flocks(); 88 88 out: 89 89 return status; 90 90 }
+5 -5
fs/nfs/nfs4state.c
··· 40 40 41 41 #include <linux/kernel.h> 42 42 #include <linux/slab.h> 43 - #include <linux/smp_lock.h> 43 + #include <linux/fs.h> 44 44 #include <linux/nfs_fs.h> 45 45 #include <linux/nfs_idmap.h> 46 46 #include <linux/kthread.h> ··· 970 970 /* Guard against delegation returns and new lock/unlock calls */ 971 971 down_write(&nfsi->rwsem); 972 972 /* Protect inode->i_flock using the BKL */ 973 - lock_kernel(); 973 + lock_flocks(); 974 974 for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) { 975 975 if (!(fl->fl_flags & (FL_POSIX|FL_FLOCK))) 976 976 continue; 977 977 if (nfs_file_open_context(fl->fl_file)->state != state) 978 978 continue; 979 - unlock_kernel(); 979 + unlock_flocks(); 980 980 status = ops->recover_lock(state, fl); 981 981 switch (status) { 982 982 case 0: ··· 1003 1003 /* kill_proc(fl->fl_pid, SIGLOST, 1); */ 1004 1004 status = 0; 1005 1005 } 1006 - lock_kernel(); 1006 + lock_flocks(); 1007 1007 } 1008 - unlock_kernel(); 1008 + unlock_flocks(); 1009 1009 out: 1010 1010 up_write(&nfsi->rwsem); 1011 1011 return status;
+3 -3
fs/nfsd/nfs4state.c
··· 33 33 */ 34 34 35 35 #include <linux/file.h> 36 - #include <linux/smp_lock.h> 36 + #include <linux/fs.h> 37 37 #include <linux/slab.h> 38 38 #include <linux/namei.h> 39 39 #include <linux/swap.h> ··· 3895 3895 struct inode *inode = filp->fi_inode; 3896 3896 int status = 0; 3897 3897 3898 - lock_kernel(); 3898 + lock_flocks(); 3899 3899 for (flpp = &inode->i_flock; *flpp != NULL; flpp = &(*flpp)->fl_next) { 3900 3900 if ((*flpp)->fl_owner == (fl_owner_t)lowner) { 3901 3901 status = 1; ··· 3903 3903 } 3904 3904 } 3905 3905 out: 3906 - unlock_kernel(); 3906 + unlock_flocks(); 3907 3907 return status; 3908 3908 } 3909 3909
-1
fs/nilfs2/ioctl.c
··· 22 22 23 23 #include <linux/fs.h> 24 24 #include <linux/wait.h> 25 - #include <linux/smp_lock.h> /* lock_kernel(), unlock_kernel() */ 26 25 #include <linux/slab.h> 27 26 #include <linux/capability.h> /* capable() */ 28 27 #include <linux/uaccess.h> /* copy_from_user(), copy_to_user() */
-10
fs/nilfs2/super.c
··· 45 45 #include <linux/parser.h> 46 46 #include <linux/random.h> 47 47 #include <linux/crc32.h> 48 - #include <linux/smp_lock.h> 49 48 #include <linux/vfs.h> 50 49 #include <linux/writeback.h> 51 50 #include <linux/kobject.h> ··· 341 342 struct nilfs_sb_info *sbi = NILFS_SB(sb); 342 343 struct the_nilfs *nilfs = sbi->s_nilfs; 343 344 344 - lock_kernel(); 345 - 346 345 nilfs_detach_segment_constructor(sbi); 347 346 348 347 if (!(sb->s_flags & MS_RDONLY)) { ··· 358 361 sbi->s_super = NULL; 359 362 sb->s_fs_info = NULL; 360 363 nilfs_put_sbinfo(sbi); 361 - 362 - unlock_kernel(); 363 364 } 364 365 365 366 static int nilfs_sync_fs(struct super_block *sb, int wait) ··· 944 949 struct nilfs_mount_options old_opts; 945 950 int was_snapshot, err; 946 951 947 - lock_kernel(); 948 - 949 952 down_write(&nilfs->ns_super_sem); 950 953 old_sb_flags = sb->s_flags; 951 954 old_opts.mount_opt = sbi->s_mount_opt; ··· 1017 1024 } 1018 1025 out: 1019 1026 up_write(&nilfs->ns_super_sem); 1020 - unlock_kernel(); 1021 1027 return 0; 1022 1028 1023 1029 restore_opts: ··· 1024 1032 sbi->s_mount_opt = old_opts.mount_opt; 1025 1033 sbi->s_snapshot_cno = old_opts.snapshot_cno; 1026 1034 up_write(&nilfs->ns_super_sem); 1027 - unlock_kernel(); 1028 1035 return err; 1029 1036 } 1030 1037 ··· 1196 1205 put_nilfs(nilfs); 1197 1206 failed: 1198 1207 close_bdev_exclusive(sd.bdev, mode); 1199 - 1200 1208 return err; 1201 1209 1202 1210 cancel_new:
+2 -22
fs/ntfs/super.c
··· 30 30 #include <linux/buffer_head.h> 31 31 #include <linux/vfs.h> 32 32 #include <linux/moduleparam.h> 33 - #include <linux/smp_lock.h> 34 33 #include <linux/bitmap.h> 35 34 36 35 #include "sysctl.h" ··· 444 445 445 446 ntfs_debug("Entering with remount options string: %s", opt); 446 447 447 - lock_kernel(); 448 448 #ifndef NTFS_RW 449 449 /* For read-only compiled driver, enforce read-only flag. */ 450 450 *flags |= MS_RDONLY; ··· 467 469 if (NVolErrors(vol)) { 468 470 ntfs_error(sb, "Volume has errors and is read-only%s", 469 471 es); 470 - unlock_kernel(); 471 472 return -EROFS; 472 473 } 473 474 if (vol->vol_flags & VOLUME_IS_DIRTY) { 474 475 ntfs_error(sb, "Volume is dirty and read-only%s", es); 475 - unlock_kernel(); 476 476 return -EROFS; 477 477 } 478 478 if (vol->vol_flags & VOLUME_MODIFIED_BY_CHKDSK) { 479 479 ntfs_error(sb, "Volume has been modified by chkdsk " 480 480 "and is read-only%s", es); 481 - unlock_kernel(); 482 481 return -EROFS; 483 482 } 484 483 if (vol->vol_flags & VOLUME_MUST_MOUNT_RO_MASK) { ··· 483 488 "(0x%x) and is read-only%s", 484 489 (unsigned)le16_to_cpu(vol->vol_flags), 485 490 es); 486 - unlock_kernel(); 487 491 return -EROFS; 488 492 } 489 493 if (ntfs_set_volume_flags(vol, VOLUME_IS_DIRTY)) { 490 494 ntfs_error(sb, "Failed to set dirty bit in volume " 491 495 "information flags%s", es); 492 - unlock_kernel(); 493 496 return -EROFS; 494 497 } 495 498 #if 0 ··· 507 514 ntfs_error(sb, "Failed to empty journal $LogFile%s", 508 515 es); 509 516 NVolSetErrors(vol); 510 - unlock_kernel(); 511 517 return -EROFS; 512 518 } 513 519 if (!ntfs_mark_quotas_out_of_date(vol)) { 514 520 ntfs_error(sb, "Failed to mark quotas out of date%s", 515 521 es); 516 522 NVolSetErrors(vol); 517 - unlock_kernel(); 518 523 return -EROFS; 519 524 } 520 525 if (!ntfs_stamp_usnjrnl(vol)) { 521 526 ntfs_error(sb, "Failed to stamp transation log " 522 527 "($UsnJrnl)%s", es); 523 528 NVolSetErrors(vol); 524 - unlock_kernel(); 525 529 return -EROFS; 526 530 } 527 531 } else if (!(sb->s_flags & MS_RDONLY) && (*flags & MS_RDONLY)) { ··· 534 544 535 545 // TODO: Deal with *flags. 536 546 537 - if (!parse_options(vol, opt)) { 538 - unlock_kernel(); 547 + if (!parse_options(vol, opt)) 539 548 return -EINVAL; 540 - } 541 - unlock_kernel(); 549 + 542 550 ntfs_debug("Done."); 543 551 return 0; 544 552 } ··· 2249 2261 2250 2262 ntfs_debug("Entering."); 2251 2263 2252 - lock_kernel(); 2253 - 2254 2264 #ifdef NTFS_RW 2255 2265 /* 2256 2266 * Commit all inodes while they are still open in case some of them ··· 2419 2433 2420 2434 sb->s_fs_info = NULL; 2421 2435 kfree(vol); 2422 - 2423 - unlock_kernel(); 2424 2436 } 2425 2437 2426 2438 /** ··· 2756 2772 init_rwsem(&vol->mftbmp_lock); 2757 2773 init_rwsem(&vol->lcnbmp_lock); 2758 2774 2759 - unlock_kernel(); 2760 - 2761 2775 /* By default, enable sparse support. */ 2762 2776 NVolSetSparseEnabled(vol); 2763 2777 ··· 2922 2940 } 2923 2941 mutex_unlock(&ntfs_lock); 2924 2942 sb->s_export_op = &ntfs_export_ops; 2925 - lock_kernel(); 2926 2943 lockdep_on(); 2927 2944 return 0; 2928 2945 } ··· 3038 3057 } 3039 3058 /* Errors at this stage are irrelevant. */ 3040 3059 err_out_now: 3041 - lock_kernel(); 3042 3060 sb->s_fs_info = NULL; 3043 3061 kfree(vol); 3044 3062 ntfs_debug("Failed, returning -EINVAL.");
-3
fs/ocfs2/stack_user.c
··· 22 22 #include <linux/miscdevice.h> 23 23 #include <linux/mutex.h> 24 24 #include <linux/slab.h> 25 - #include <linux/smp_lock.h> 26 25 #include <linux/reboot.h> 27 26 #include <asm/uaccess.h> 28 27 ··· 611 612 return -ENOMEM; 612 613 p->op_this_node = -1; 613 614 614 - lock_kernel(); 615 615 mutex_lock(&ocfs2_control_lock); 616 616 file->private_data = p; 617 617 list_add(&p->op_list, &ocfs2_control_private_list); 618 618 mutex_unlock(&ocfs2_control_lock); 619 - unlock_kernel(); 620 619 621 620 return 0; 622 621 }
-7
fs/ocfs2/super.c
··· 630 630 struct ocfs2_super *osb = OCFS2_SB(sb); 631 631 u32 tmp; 632 632 633 - lock_kernel(); 634 - 635 633 if (!ocfs2_parse_options(sb, data, &parsed_options, 1) || 636 634 !ocfs2_check_set_options(sb, &parsed_options)) { 637 635 ret = -EINVAL; ··· 737 739 MS_POSIXACL : 0); 738 740 } 739 741 out: 740 - unlock_kernel(); 741 742 return ret; 742 743 } 743 744 ··· 1693 1696 { 1694 1697 mlog_entry("(0x%p)\n", sb); 1695 1698 1696 - lock_kernel(); 1697 - 1698 1699 ocfs2_sync_blockdev(sb); 1699 1700 ocfs2_dismount_volume(sb, 0); 1700 - 1701 - unlock_kernel(); 1702 1701 1703 1702 mlog_exit_void(); 1704 1703 }
-4
fs/qnx4/dir.c
··· 11 11 * 20-06-1998 by Frank Denis : Linux 2.1.99+ & dcache support. 12 12 */ 13 13 14 - #include <linux/smp_lock.h> 15 14 #include <linux/buffer_head.h> 16 15 #include "qnx4.h" 17 16 ··· 27 28 28 29 QNX4DEBUG((KERN_INFO "qnx4_readdir:i_size = %ld\n", (long) inode->i_size)); 29 30 QNX4DEBUG((KERN_INFO "filp->f_pos = %ld\n", (long) filp->f_pos)); 30 - 31 - lock_kernel(); 32 31 33 32 while (filp->f_pos < inode->i_size) { 34 33 blknum = qnx4_block_map( inode, filp->f_pos >> QNX4_BLOCK_SIZE_BITS ); ··· 68 71 brelse(bh); 69 72 } 70 73 out: 71 - unlock_kernel(); 72 74 return 0; 73 75 } 74 76
-6
fs/qnx4/inode.c
··· 16 16 #include <linux/init.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/highuid.h> 19 - #include <linux/smp_lock.h> 20 19 #include <linux/pagemap.h> 21 20 #include <linux/buffer_head.h> 22 21 #include <linux/writeback.h> ··· 156 157 struct super_block *sb = dentry->d_sb; 157 158 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); 158 159 159 - lock_kernel(); 160 - 161 160 buf->f_type = sb->s_magic; 162 161 buf->f_bsize = sb->s_blocksize; 163 162 buf->f_blocks = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size) * 8; ··· 164 167 buf->f_namelen = QNX4_NAME_MAX; 165 168 buf->f_fsid.val[0] = (u32)id; 166 169 buf->f_fsid.val[1] = (u32)(id >> 32); 167 - 168 - unlock_kernel(); 169 170 170 171 return 0; 171 172 } ··· 278 283 goto outi; 279 284 280 285 brelse(bh); 281 - 282 286 return 0; 283 287 284 288 outi:
-4
fs/qnx4/namei.c
··· 12 12 * 04-07-1998 by Frank Denis : first step for rmdir/unlink. 13 13 */ 14 14 15 - #include <linux/smp_lock.h> 16 15 #include <linux/buffer_head.h> 17 16 #include "qnx4.h" 18 17 ··· 108 109 int len = dentry->d_name.len; 109 110 struct inode *foundinode = NULL; 110 111 111 - lock_kernel(); 112 112 if (!(bh = qnx4_find_entry(len, dir, name, &de, &ino))) 113 113 goto out; 114 114 /* The entry is linked, let's get the real info */ ··· 121 123 122 124 foundinode = qnx4_iget(dir->i_sb, ino); 123 125 if (IS_ERR(foundinode)) { 124 - unlock_kernel(); 125 126 QNX4DEBUG((KERN_ERR "qnx4: lookup->iget -> error %ld\n", 126 127 PTR_ERR(foundinode))); 127 128 return ERR_CAST(foundinode); 128 129 } 129 130 out: 130 - unlock_kernel(); 131 131 d_add(dentry, foundinode); 132 132 133 133 return NULL;
+5
fs/smbfs/inode.c
··· 501 501 void *mem; 502 502 static int warn_count; 503 503 504 + lock_kernel(); 505 + 504 506 if (warn_count < 5) { 505 507 warn_count++; 506 508 printk(KERN_EMERG "smbfs is deprecated and will be removed" ··· 623 621 624 622 smb_new_dentry(sb->s_root); 625 623 624 + unlock_kernel(); 626 625 return 0; 627 626 628 627 out_no_root: ··· 646 643 out_no_data: 647 644 printk(KERN_ERR "smb_fill_super: missing data argument\n"); 648 645 out_fail: 646 + unlock_kernel(); 649 647 return -EINVAL; 650 648 out_no_server: 651 649 printk(KERN_ERR "smb_fill_super: cannot allocate struct smb_sb_info\n"); 650 + unlock_kernel(); 652 651 return -ENOMEM; 653 652 } 654 653
-5
fs/squashfs/super.c
··· 30 30 #include <linux/fs.h> 31 31 #include <linux/vfs.h> 32 32 #include <linux/slab.h> 33 - #include <linux/smp_lock.h> 34 33 #include <linux/mutex.h> 35 34 #include <linux/pagemap.h> 36 35 #include <linux/init.h> ··· 353 354 354 355 static void squashfs_put_super(struct super_block *sb) 355 356 { 356 - lock_kernel(); 357 - 358 357 if (sb->s_fs_info) { 359 358 struct squashfs_sb_info *sbi = sb->s_fs_info; 360 359 squashfs_cache_delete(sbi->block_cache); ··· 367 370 kfree(sb->s_fs_info); 368 371 sb->s_fs_info = NULL; 369 372 } 370 - 371 - unlock_kernel(); 372 373 } 373 374 374 375
+7 -1
fs/udf/super.c
··· 1880 1880 struct kernel_lb_addr rootdir, fileset; 1881 1881 struct udf_sb_info *sbi; 1882 1882 1883 + lock_kernel(); 1884 + 1883 1885 uopt.flags = (1 << UDF_FLAG_USE_AD_IN_ICB) | (1 << UDF_FLAG_STRICT); 1884 1886 uopt.uid = -1; 1885 1887 uopt.gid = -1; ··· 1890 1888 uopt.dmode = UDF_INVALID_MODE; 1891 1889 1892 1890 sbi = kzalloc(sizeof(struct udf_sb_info), GFP_KERNEL); 1893 - if (!sbi) 1891 + if (!sbi) { 1892 + unlock_kernel(); 1894 1893 return -ENOMEM; 1894 + } 1895 1895 1896 1896 sb->s_fs_info = sbi; 1897 1897 ··· 2039 2035 goto error_out; 2040 2036 } 2041 2037 sb->s_maxbytes = MAX_LFS_FILESIZE; 2038 + unlock_kernel(); 2042 2039 return 0; 2043 2040 2044 2041 error_out: ··· 2060 2055 kfree(sbi); 2061 2056 sb->s_fs_info = NULL; 2062 2057 2058 + unlock_kernel(); 2063 2059 return -EINVAL; 2064 2060 } 2065 2061
+5
fs/ufs/super.c
··· 696 696 unsigned maxsymlen; 697 697 int ret = -EINVAL; 698 698 699 + lock_kernel(); 700 + 699 701 uspi = NULL; 700 702 ubh = NULL; 701 703 flags = 0; ··· 1165 1163 goto failed; 1166 1164 1167 1165 UFSD("EXIT\n"); 1166 + unlock_kernel(); 1168 1167 return 0; 1169 1168 1170 1169 dalloc_failed: ··· 1177 1174 kfree(sbi); 1178 1175 sb->s_fs_info = NULL; 1179 1176 UFSD("EXIT (FAILED)\n"); 1177 + unlock_kernel(); 1180 1178 return ret; 1181 1179 1182 1180 failed_nomem: 1183 1181 UFSD("EXIT (NOMEM)\n"); 1182 + unlock_kernel(); 1184 1183 return -ENOMEM; 1185 1184 } 1186 1185
+10 -4
include/linux/fs.h
··· 1093 1093 1094 1094 #include <linux/fcntl.h> 1095 1095 1096 - /* temporary stubs for BKL removal */ 1097 - #define lock_flocks() lock_kernel() 1098 - #define unlock_flocks() unlock_kernel() 1099 - 1100 1096 extern void send_sigio(struct fown_struct *fown, int fd, int band); 1101 1097 1102 1098 #ifdef CONFIG_FILE_LOCKING ··· 1131 1135 extern int lease_modify(struct file_lock **, int); 1132 1136 extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 1133 1137 extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 1138 + extern void lock_flocks(void); 1139 + extern void unlock_flocks(void); 1134 1140 #else /* !CONFIG_FILE_LOCKING */ 1135 1141 static inline int fcntl_getlk(struct file *file, struct flock __user *user) 1136 1142 { ··· 1273 1275 unsigned long len) 1274 1276 { 1275 1277 return 1; 1278 + } 1279 + 1280 + static inline void lock_flocks(void) 1281 + { 1282 + } 1283 + 1284 + static inline void unlock_flocks(void) 1285 + { 1276 1286 } 1277 1287 1278 1288 #endif /* !CONFIG_FILE_LOCKING */
-28
include/linux/ncp_fs.h
··· 241 241 /* linux/fs/ncpfs/ncplib_kernel.c */ 242 242 int ncp_make_closed(struct inode *); 243 243 244 - #define ncp_namespace(i) (NCP_SERVER(i)->name_space[NCP_FINFO(i)->volNumber]) 245 - 246 - static inline int ncp_preserve_entry_case(struct inode *i, __u32 nscreator) 247 - { 248 - #ifdef CONFIG_NCPFS_SMALLDOS 249 - int ns = ncp_namespace(i); 250 - 251 - if ((ns == NW_NS_DOS) 252 - #ifdef CONFIG_NCPFS_OS2_NS 253 - || ((ns == NW_NS_OS2) && (nscreator == NW_NS_DOS)) 254 - #endif /* CONFIG_NCPFS_OS2_NS */ 255 - ) 256 - return 0; 257 - #endif /* CONFIG_NCPFS_SMALLDOS */ 258 - return 1; 259 - } 260 - 261 - #define ncp_preserve_case(i) (ncp_namespace(i) != NW_NS_DOS) 262 - 263 - static inline int ncp_case_sensitive(struct inode *i) 264 - { 265 - #ifdef CONFIG_NCPFS_NFS_NS 266 - return ncp_namespace(i) == NW_NS_NFS; 267 - #else 268 - return 0; 269 - #endif /* CONFIG_NCPFS_NFS_NS */ 270 - } 271 - 272 244 #endif /* __KERNEL__ */ 273 245 274 246 #endif /* _LINUX_NCP_FS_H */
+3 -1
include/linux/ncp_fs_sb.h
··· 62 62 int ncp_reply_size; 63 63 64 64 int root_setuped; 65 + struct mutex root_setup_lock; 65 66 66 67 /* info for packet signing */ 67 68 int sign_wanted; /* 1=Server needs signed packets */ ··· 82 81 size_t len; 83 82 void* data; 84 83 } priv; 84 + struct rw_semaphore auth_rwsem; 85 85 86 86 /* nls info: codepage for volume and charset for I/O */ 87 87 struct nls_table *nls_vol; 88 88 struct nls_table *nls_io; 89 89 90 90 /* maximum age in jiffies */ 91 - int dentry_ttl; 91 + atomic_t dentry_ttl; 92 92 93 93 /* miscellaneous */ 94 94 unsigned int flags;
-4
kernel/cgroup.c
··· 52 52 #include <linux/cgroupstats.h> 53 53 #include <linux/hash.h> 54 54 #include <linux/namei.h> 55 - #include <linux/smp_lock.h> 56 55 #include <linux/pid_namespace.h> 57 56 #include <linux/idr.h> 58 57 #include <linux/vmalloc.h> /* TODO: replace with more sophisticated array */ ··· 1221 1222 struct cgroup *cgrp = &root->top_cgroup; 1222 1223 struct cgroup_sb_opts opts; 1223 1224 1224 - lock_kernel(); 1225 1225 mutex_lock(&cgrp->dentry->d_inode->i_mutex); 1226 1226 mutex_lock(&cgroup_mutex); 1227 1227 ··· 1253 1255 kfree(opts.name); 1254 1256 mutex_unlock(&cgroup_mutex); 1255 1257 mutex_unlock(&cgrp->dentry->d_inode->i_mutex); 1256 - unlock_kernel(); 1257 1258 return ret; 1258 1259 } 1259 1260 ··· 1565 1568 out_err: 1566 1569 kfree(opts.release_agent); 1567 1570 kfree(opts.name); 1568 - 1569 1571 return ret; 1570 1572 } 1571 1573