Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ecryptfs/ecryptfs-2.6:
eCryptfs: Copy up lower inode attrs in getattr
ecryptfs: read on a directory should return EISDIR if not supported
eCryptfs: Handle NULL nameidata pointers
eCryptfs: Revert "dont call lookup_one_len to avoid NULL nameidata"

+44 -120
+13 -9
fs/ecryptfs/dentry.c
··· 46 46 { 47 47 struct dentry *lower_dentry; 48 48 struct vfsmount *lower_mnt; 49 - struct dentry *dentry_save; 50 - struct vfsmount *vfsmount_save; 49 + struct dentry *dentry_save = NULL; 50 + struct vfsmount *vfsmount_save = NULL; 51 51 int rc = 1; 52 52 53 - if (nd->flags & LOOKUP_RCU) 53 + if (nd && nd->flags & LOOKUP_RCU) 54 54 return -ECHILD; 55 55 56 56 lower_dentry = ecryptfs_dentry_to_lower(dentry); 57 57 lower_mnt = ecryptfs_dentry_to_lower_mnt(dentry); 58 58 if (!lower_dentry->d_op || !lower_dentry->d_op->d_revalidate) 59 59 goto out; 60 - dentry_save = nd->path.dentry; 61 - vfsmount_save = nd->path.mnt; 62 - nd->path.dentry = lower_dentry; 63 - nd->path.mnt = lower_mnt; 60 + if (nd) { 61 + dentry_save = nd->path.dentry; 62 + vfsmount_save = nd->path.mnt; 63 + nd->path.dentry = lower_dentry; 64 + nd->path.mnt = lower_mnt; 65 + } 64 66 rc = lower_dentry->d_op->d_revalidate(lower_dentry, nd); 65 - nd->path.dentry = dentry_save; 66 - nd->path.mnt = vfsmount_save; 67 + if (nd) { 68 + nd->path.dentry = dentry_save; 69 + nd->path.mnt = vfsmount_save; 70 + } 67 71 if (dentry->d_inode) { 68 72 struct inode *lower_inode = 69 73 ecryptfs_inode_to_lower(dentry->d_inode);
+1 -2
fs/ecryptfs/ecryptfs_kernel.h
··· 632 632 u32 flags); 633 633 int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry, 634 634 struct dentry *lower_dentry, 635 - struct inode *ecryptfs_dir_inode, 636 - struct nameidata *ecryptfs_nd); 635 + struct inode *ecryptfs_dir_inode); 637 636 int ecryptfs_decode_and_decrypt_filename(char **decrypted_name, 638 637 size_t *decrypted_name_size, 639 638 struct dentry *ecryptfs_dentry,
+1
fs/ecryptfs/file.c
··· 317 317 318 318 const struct file_operations ecryptfs_dir_fops = { 319 319 .readdir = ecryptfs_readdir, 320 + .read = generic_read_dir, 320 321 .unlocked_ioctl = ecryptfs_unlocked_ioctl, 321 322 #ifdef CONFIG_COMPAT 322 323 .compat_ioctl = ecryptfs_compat_ioctl,
+29 -109
fs/ecryptfs/inode.c
··· 74 74 unsigned int flags_save; 75 75 int rc; 76 76 77 - dentry_save = nd->path.dentry; 78 - vfsmount_save = nd->path.mnt; 79 - flags_save = nd->flags; 80 - nd->path.dentry = lower_dentry; 81 - nd->path.mnt = lower_mnt; 82 - nd->flags &= ~LOOKUP_OPEN; 77 + if (nd) { 78 + dentry_save = nd->path.dentry; 79 + vfsmount_save = nd->path.mnt; 80 + flags_save = nd->flags; 81 + nd->path.dentry = lower_dentry; 82 + nd->path.mnt = lower_mnt; 83 + nd->flags &= ~LOOKUP_OPEN; 84 + } 83 85 rc = vfs_create(lower_dir_inode, lower_dentry, mode, nd); 84 - nd->path.dentry = dentry_save; 85 - nd->path.mnt = vfsmount_save; 86 - nd->flags = flags_save; 86 + if (nd) { 87 + nd->path.dentry = dentry_save; 88 + nd->path.mnt = vfsmount_save; 89 + nd->flags = flags_save; 90 + } 87 91 return rc; 88 92 } 89 93 ··· 245 241 */ 246 242 int ecryptfs_lookup_and_interpose_lower(struct dentry *ecryptfs_dentry, 247 243 struct dentry *lower_dentry, 248 - struct inode *ecryptfs_dir_inode, 249 - struct nameidata *ecryptfs_nd) 244 + struct inode *ecryptfs_dir_inode) 250 245 { 251 246 struct dentry *lower_dir_dentry; 252 247 struct vfsmount *lower_mnt; ··· 292 289 if (S_ISLNK(lower_inode->i_mode)) 293 290 goto out; 294 291 if (special_file(lower_inode->i_mode)) 295 - goto out; 296 - if (!ecryptfs_nd) 297 292 goto out; 298 293 /* Released in this function */ 299 294 page_virt = kmem_cache_zalloc(ecryptfs_header_cache_2, GFP_USER); ··· 350 349 } 351 350 352 351 /** 353 - * ecryptfs_new_lower_dentry 354 - * @name: The name of the new dentry. 355 - * @lower_dir_dentry: Parent directory of the new dentry. 356 - * @nd: nameidata from last lookup. 357 - * 358 - * Create a new dentry or get it from lower parent dir. 359 - */ 360 - static struct dentry * 361 - ecryptfs_new_lower_dentry(struct qstr *name, struct dentry *lower_dir_dentry, 362 - struct nameidata *nd) 363 - { 364 - struct dentry *new_dentry; 365 - struct dentry *tmp; 366 - struct inode *lower_dir_inode; 367 - 368 - lower_dir_inode = lower_dir_dentry->d_inode; 369 - 370 - tmp = d_alloc(lower_dir_dentry, name); 371 - if (!tmp) 372 - return ERR_PTR(-ENOMEM); 373 - 374 - mutex_lock(&lower_dir_inode->i_mutex); 375 - new_dentry = lower_dir_inode->i_op->lookup(lower_dir_inode, tmp, nd); 376 - mutex_unlock(&lower_dir_inode->i_mutex); 377 - 378 - if (!new_dentry) 379 - new_dentry = tmp; 380 - else 381 - dput(tmp); 382 - 383 - return new_dentry; 384 - } 385 - 386 - 387 - /** 388 - * ecryptfs_lookup_one_lower 389 - * @ecryptfs_dentry: The eCryptfs dentry that we are looking up 390 - * @lower_dir_dentry: lower parent directory 391 - * @name: lower file name 392 - * 393 - * Get the lower dentry from vfs. If lower dentry does not exist yet, 394 - * create it. 395 - */ 396 - static struct dentry * 397 - ecryptfs_lookup_one_lower(struct dentry *ecryptfs_dentry, 398 - struct dentry *lower_dir_dentry, struct qstr *name) 399 - { 400 - struct nameidata nd; 401 - struct vfsmount *lower_mnt; 402 - int err; 403 - 404 - lower_mnt = mntget(ecryptfs_dentry_to_lower_mnt( 405 - ecryptfs_dentry->d_parent)); 406 - err = vfs_path_lookup(lower_dir_dentry, lower_mnt, name->name , 0, &nd); 407 - mntput(lower_mnt); 408 - 409 - if (!err) { 410 - /* we dont need the mount */ 411 - mntput(nd.path.mnt); 412 - return nd.path.dentry; 413 - } 414 - if (err != -ENOENT) 415 - return ERR_PTR(err); 416 - 417 - /* create a new lower dentry */ 418 - return ecryptfs_new_lower_dentry(name, lower_dir_dentry, &nd); 419 - } 420 - 421 - /** 422 352 * ecryptfs_lookup 423 353 * @ecryptfs_dir_inode: The eCryptfs directory inode 424 354 * @ecryptfs_dentry: The eCryptfs dentry that we are looking up ··· 366 434 size_t encrypted_and_encoded_name_size; 367 435 struct ecryptfs_mount_crypt_stat *mount_crypt_stat = NULL; 368 436 struct dentry *lower_dir_dentry, *lower_dentry; 369 - struct qstr lower_name; 370 437 int rc = 0; 371 438 372 439 if ((ecryptfs_dentry->d_name.len == 1 ··· 375 444 goto out_d_drop; 376 445 } 377 446 lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent); 378 - lower_name.name = ecryptfs_dentry->d_name.name; 379 - lower_name.len = ecryptfs_dentry->d_name.len; 380 - lower_name.hash = ecryptfs_dentry->d_name.hash; 381 - if (lower_dir_dentry->d_op && lower_dir_dentry->d_op->d_hash) { 382 - rc = lower_dir_dentry->d_op->d_hash(lower_dir_dentry, 383 - lower_dir_dentry->d_inode, &lower_name); 384 - if (rc < 0) 385 - goto out_d_drop; 386 - } 387 - lower_dentry = ecryptfs_lookup_one_lower(ecryptfs_dentry, 388 - lower_dir_dentry, &lower_name); 447 + mutex_lock(&lower_dir_dentry->d_inode->i_mutex); 448 + lower_dentry = lookup_one_len(ecryptfs_dentry->d_name.name, 449 + lower_dir_dentry, 450 + ecryptfs_dentry->d_name.len); 451 + mutex_unlock(&lower_dir_dentry->d_inode->i_mutex); 389 452 if (IS_ERR(lower_dentry)) { 390 453 rc = PTR_ERR(lower_dentry); 391 - ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_lower() returned " 454 + ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 392 455 "[%d] on lower_dentry = [%s]\n", __func__, rc, 393 456 encrypted_and_encoded_name); 394 457 goto out_d_drop; ··· 404 479 "filename; rc = [%d]\n", __func__, rc); 405 480 goto out_d_drop; 406 481 } 407 - lower_name.name = encrypted_and_encoded_name; 408 - lower_name.len = encrypted_and_encoded_name_size; 409 - lower_name.hash = full_name_hash(lower_name.name, lower_name.len); 410 - if (lower_dir_dentry->d_op && lower_dir_dentry->d_op->d_hash) { 411 - rc = lower_dir_dentry->d_op->d_hash(lower_dir_dentry, 412 - lower_dir_dentry->d_inode, &lower_name); 413 - if (rc < 0) 414 - goto out_d_drop; 415 - } 416 - lower_dentry = ecryptfs_lookup_one_lower(ecryptfs_dentry, 417 - lower_dir_dentry, &lower_name); 482 + mutex_lock(&lower_dir_dentry->d_inode->i_mutex); 483 + lower_dentry = lookup_one_len(encrypted_and_encoded_name, 484 + lower_dir_dentry, 485 + encrypted_and_encoded_name_size); 486 + mutex_unlock(&lower_dir_dentry->d_inode->i_mutex); 418 487 if (IS_ERR(lower_dentry)) { 419 488 rc = PTR_ERR(lower_dentry); 420 - ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_lower() returned " 489 + ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned " 421 490 "[%d] on lower_dentry = [%s]\n", __func__, rc, 422 491 encrypted_and_encoded_name); 423 492 goto out_d_drop; 424 493 } 425 494 lookup_and_interpose: 426 495 rc = ecryptfs_lookup_and_interpose_lower(ecryptfs_dentry, lower_dentry, 427 - ecryptfs_dir_inode, 428 - ecryptfs_nd); 496 + ecryptfs_dir_inode); 429 497 goto out; 430 498 out_d_drop: 431 499 d_drop(ecryptfs_dentry); ··· 1010 1092 rc = vfs_getattr(ecryptfs_dentry_to_lower_mnt(dentry), 1011 1093 ecryptfs_dentry_to_lower(dentry), &lower_stat); 1012 1094 if (!rc) { 1095 + fsstack_copy_attr_all(dentry->d_inode, 1096 + ecryptfs_inode_to_lower(dentry->d_inode)); 1013 1097 generic_fillattr(dentry->d_inode, stat); 1014 1098 stat->blocks = lower_stat.blocks; 1015 1099 }