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 'misc.namei' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull namei updates from Al Viro:
"Clearing fallout from mkdirat in io_uring series. The fix in the
kern_path_locked() patch plus associated cleanups"

* 'misc.namei' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
putname(): IS_ERR_OR_NULL() is wrong here
namei: Standardize callers of filename_create()
namei: Standardize callers of filename_lookup()
rename __filename_parentat() to filename_parentat()
namei: Fix use after free in kern_path_locked

+59 -60
-1
fs/fs_parser.c
··· 165 165 return invalf(fc, "%s: not usable as path", param->key); 166 166 } 167 167 168 - f->refcnt++; /* filename_lookup() drops our ref. */ 169 168 ret = filename_lookup(param->dirfd, f, flags, _path, NULL); 170 169 if (ret < 0) { 171 170 errorf(fc, "%s: Lookup failure for '%s'", param->key, f->name);
+59 -59
fs/namei.c
··· 255 255 256 256 void putname(struct filename *name) 257 257 { 258 - if (IS_ERR_OR_NULL(name)) 258 + if (IS_ERR(name)) 259 259 return; 260 260 261 261 BUG_ON(name->refcnt <= 0); ··· 2467 2467 return err; 2468 2468 } 2469 2469 2470 - static int __filename_lookup(int dfd, struct filename *name, unsigned flags, 2470 + int filename_lookup(int dfd, struct filename *name, unsigned flags, 2471 2471 struct path *path, struct path *root) 2472 2472 { 2473 2473 int retval; ··· 2488 2488 return retval; 2489 2489 } 2490 2490 2491 - int filename_lookup(int dfd, struct filename *name, unsigned flags, 2492 - struct path *path, struct path *root) 2493 - { 2494 - int retval = __filename_lookup(dfd, name, flags, path, root); 2495 - 2496 - putname(name); 2497 - return retval; 2498 - } 2499 - 2500 2491 /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */ 2501 2492 static int path_parentat(struct nameidata *nd, unsigned flags, 2502 2493 struct path *parent) ··· 2505 2514 return err; 2506 2515 } 2507 2516 2508 - static int __filename_parentat(int dfd, struct filename *name, 2509 - unsigned int flags, struct path *parent, 2510 - struct qstr *last, int *type) 2517 + /* Note: this does not consume "name" */ 2518 + static int filename_parentat(int dfd, struct filename *name, 2519 + unsigned int flags, struct path *parent, 2520 + struct qstr *last, int *type) 2511 2521 { 2512 2522 int retval; 2513 2523 struct nameidata nd; ··· 2530 2538 return retval; 2531 2539 } 2532 2540 2533 - static int filename_parentat(int dfd, struct filename *name, 2534 - unsigned int flags, struct path *parent, 2535 - struct qstr *last, int *type) 2536 - { 2537 - int retval = __filename_parentat(dfd, name, flags, parent, last, type); 2538 - 2539 - putname(name); 2540 - return retval; 2541 - } 2542 - 2543 2541 /* does lookup, returns the object with parent locked */ 2544 - struct dentry *kern_path_locked(const char *name, struct path *path) 2542 + static struct dentry *__kern_path_locked(struct filename *name, struct path *path) 2545 2543 { 2546 2544 struct dentry *d; 2547 2545 struct qstr last; 2548 2546 int type, error; 2549 2547 2550 - error = filename_parentat(AT_FDCWD, getname_kernel(name), 0, path, 2551 - &last, &type); 2548 + error = filename_parentat(AT_FDCWD, name, 0, path, &last, &type); 2552 2549 if (error) 2553 2550 return ERR_PTR(error); 2554 2551 if (unlikely(type != LAST_NORM)) { ··· 2553 2572 return d; 2554 2573 } 2555 2574 2575 + struct dentry *kern_path_locked(const char *name, struct path *path) 2576 + { 2577 + struct filename *filename = getname_kernel(name); 2578 + struct dentry *res = __kern_path_locked(filename, path); 2579 + 2580 + putname(filename); 2581 + return res; 2582 + } 2583 + 2556 2584 int kern_path(const char *name, unsigned int flags, struct path *path) 2557 2585 { 2558 - return filename_lookup(AT_FDCWD, getname_kernel(name), 2559 - flags, path, NULL); 2586 + struct filename *filename = getname_kernel(name); 2587 + int ret = filename_lookup(AT_FDCWD, filename, flags, path, NULL); 2588 + 2589 + putname(filename); 2590 + return ret; 2591 + 2560 2592 } 2561 2593 EXPORT_SYMBOL(kern_path); 2562 2594 ··· 2585 2591 const char *name, unsigned int flags, 2586 2592 struct path *path) 2587 2593 { 2594 + struct filename *filename; 2588 2595 struct path root = {.mnt = mnt, .dentry = dentry}; 2596 + int ret; 2597 + 2598 + filename = getname_kernel(name); 2589 2599 /* the first argument of filename_lookup() is ignored with root */ 2590 - return filename_lookup(AT_FDCWD, getname_kernel(name), 2591 - flags , path, &root); 2600 + ret = filename_lookup(AT_FDCWD, filename, flags, path, &root); 2601 + putname(filename); 2602 + return ret; 2592 2603 } 2593 2604 EXPORT_SYMBOL(vfs_path_lookup); 2594 2605 ··· 2797 2798 int user_path_at_empty(int dfd, const char __user *name, unsigned flags, 2798 2799 struct path *path, int *empty) 2799 2800 { 2800 - return filename_lookup(dfd, getname_flags(name, flags, empty), 2801 - flags, path, NULL); 2801 + struct filename *filename = getname_flags(name, flags, empty); 2802 + int ret = filename_lookup(dfd, filename, flags, path, NULL); 2803 + 2804 + putname(filename); 2805 + return ret; 2802 2806 } 2803 2807 EXPORT_SYMBOL(user_path_at_empty); 2804 2808 ··· 3620 3618 return file; 3621 3619 } 3622 3620 3623 - static struct dentry *__filename_create(int dfd, struct filename *name, 3624 - struct path *path, unsigned int lookup_flags) 3621 + static struct dentry *filename_create(int dfd, struct filename *name, 3622 + struct path *path, unsigned int lookup_flags) 3625 3623 { 3626 3624 struct dentry *dentry = ERR_PTR(-EEXIST); 3627 3625 struct qstr last; ··· 3636 3634 */ 3637 3635 lookup_flags &= LOOKUP_REVAL; 3638 3636 3639 - error = __filename_parentat(dfd, name, lookup_flags, path, &last, &type); 3637 + error = filename_parentat(dfd, name, lookup_flags, path, &last, &type); 3640 3638 if (error) 3641 3639 return ERR_PTR(error); 3642 3640 ··· 3689 3687 return dentry; 3690 3688 } 3691 3689 3692 - static inline struct dentry *filename_create(int dfd, struct filename *name, 3693 - struct path *path, unsigned int lookup_flags) 3694 - { 3695 - struct dentry *res = __filename_create(dfd, name, path, lookup_flags); 3696 - 3697 - putname(name); 3698 - return res; 3699 - } 3700 - 3701 3690 struct dentry *kern_path_create(int dfd, const char *pathname, 3702 3691 struct path *path, unsigned int lookup_flags) 3703 3692 { 3704 - return filename_create(dfd, getname_kernel(pathname), 3705 - path, lookup_flags); 3693 + struct filename *filename = getname_kernel(pathname); 3694 + struct dentry *res = filename_create(dfd, filename, path, lookup_flags); 3695 + 3696 + putname(filename); 3697 + return res; 3706 3698 } 3707 3699 EXPORT_SYMBOL(kern_path_create); 3708 3700 ··· 3712 3716 inline struct dentry *user_path_create(int dfd, const char __user *pathname, 3713 3717 struct path *path, unsigned int lookup_flags) 3714 3718 { 3715 - return filename_create(dfd, getname(pathname), path, lookup_flags); 3719 + struct filename *filename = getname(pathname); 3720 + struct dentry *res = filename_create(dfd, filename, path, lookup_flags); 3721 + 3722 + putname(filename); 3723 + return res; 3716 3724 } 3717 3725 EXPORT_SYMBOL(user_path_create); 3718 3726 ··· 3797 3797 if (error) 3798 3798 goto out1; 3799 3799 retry: 3800 - dentry = __filename_create(dfd, name, &path, lookup_flags); 3800 + dentry = filename_create(dfd, name, &path, lookup_flags); 3801 3801 error = PTR_ERR(dentry); 3802 3802 if (IS_ERR(dentry)) 3803 3803 goto out1; ··· 3897 3897 unsigned int lookup_flags = LOOKUP_DIRECTORY; 3898 3898 3899 3899 retry: 3900 - dentry = __filename_create(dfd, name, &path, lookup_flags); 3900 + dentry = filename_create(dfd, name, &path, lookup_flags); 3901 3901 error = PTR_ERR(dentry); 3902 3902 if (IS_ERR(dentry)) 3903 3903 goto out_putname; ··· 3996 3996 int type; 3997 3997 unsigned int lookup_flags = 0; 3998 3998 retry: 3999 - error = __filename_parentat(dfd, name, lookup_flags, &path, &last, &type); 3999 + error = filename_parentat(dfd, name, lookup_flags, &path, &last, &type); 4000 4000 if (error) 4001 4001 goto exit1; 4002 4002 ··· 4137 4137 struct inode *delegated_inode = NULL; 4138 4138 unsigned int lookup_flags = 0; 4139 4139 retry: 4140 - error = __filename_parentat(dfd, name, lookup_flags, &path, &last, &type); 4140 + error = filename_parentat(dfd, name, lookup_flags, &path, &last, &type); 4141 4141 if (error) 4142 4142 goto exit1; 4143 4143 ··· 4266 4266 goto out_putnames; 4267 4267 } 4268 4268 retry: 4269 - dentry = __filename_create(newdfd, to, &path, lookup_flags); 4269 + dentry = filename_create(newdfd, to, &path, lookup_flags); 4270 4270 error = PTR_ERR(dentry); 4271 4271 if (IS_ERR(dentry)) 4272 4272 goto out_putnames; ··· 4426 4426 if (flags & AT_SYMLINK_FOLLOW) 4427 4427 how |= LOOKUP_FOLLOW; 4428 4428 retry: 4429 - error = __filename_lookup(olddfd, old, how, &old_path, NULL); 4429 + error = filename_lookup(olddfd, old, how, &old_path, NULL); 4430 4430 if (error) 4431 4431 goto out_putnames; 4432 4432 4433 - new_dentry = __filename_create(newdfd, new, &new_path, 4433 + new_dentry = filename_create(newdfd, new, &new_path, 4434 4434 (how & LOOKUP_REVAL)); 4435 4435 error = PTR_ERR(new_dentry); 4436 4436 if (IS_ERR(new_dentry)) ··· 4689 4689 target_flags = 0; 4690 4690 4691 4691 retry: 4692 - error = __filename_parentat(olddfd, from, lookup_flags, &old_path, 4693 - &old_last, &old_type); 4692 + error = filename_parentat(olddfd, from, lookup_flags, &old_path, 4693 + &old_last, &old_type); 4694 4694 if (error) 4695 4695 goto put_names; 4696 4696 4697 - error = __filename_parentat(newdfd, to, lookup_flags, &new_path, &new_last, 4698 - &new_type); 4697 + error = filename_parentat(newdfd, to, lookup_flags, &new_path, &new_last, 4698 + &new_type); 4699 4699 if (error) 4700 4700 goto exit1; 4701 4701