Commit b3d4650
VFS: filename_create(): fix incorrect intent.
When asked to create a path ending '/', but which is not to be a
directory (LOOKUP_DIRECTORY not set), filename_create() will never try
to create the file. If it doesn't exist, -ENOENT is reported.
However, it still passes LOOKUP_CREATE|LOOKUP_EXCL to the filesystems
->lookup() function, even though there is no intent to create. This is
misleading and can cause incorrect behaviour.
If you try
ln -s foo /path/dir/
where 'dir' is a directory on an NFS filesystem which is not currently
known in the dcache, this will fail with ENOENT.
But as the name is not in the dcache, nfs_lookup gets called with
LOOKUP_CREATE|LOOKUP_EXCL and so it returns NULL without performing any
lookup, with the expectation that a subsequent call to create the target
will be made, and the lookup can be combined with the creation. In the
case with a trailing '/' and no LOOKUP_DIRECTORY, that call is never
made. Instead filename_create() sees that the dentry is not (yet)
positive and returns -ENOENT - even though the directory actually
exists.
So only set LOOKUP_CREATE|LOOKUP_EXCL if there really is an intent to
create, and use the absence of these flags to decide if -ENOENT should
be returned.
Note that filename_parentat() is only interested in LOOKUP_REVAL, so we
split that out and store it in 'reval_flag'. __lookup_hash() then gets
reval_flag combined with whatever create flags were determined to be
needed.
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neilb@suse.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>1 parent 115acbb commit b3d4650
1 file changed
Lines changed: 10 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3673 | 3673 | | |
3674 | 3674 | | |
3675 | 3675 | | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
3676 | 3679 | | |
3677 | 3680 | | |
3678 | 3681 | | |
3679 | | - | |
3680 | 3682 | | |
3681 | | - | |
3682 | | - | |
3683 | | - | |
3684 | | - | |
3685 | | - | |
3686 | | - | |
3687 | | - | |
| 3683 | + | |
3688 | 3684 | | |
3689 | 3685 | | |
3690 | 3686 | | |
| |||
3698 | 3694 | | |
3699 | 3695 | | |
3700 | 3696 | | |
3701 | | - | |
| 3697 | + | |
| 3698 | + | |
3702 | 3699 | | |
3703 | | - | |
| 3700 | + | |
| 3701 | + | |
3704 | 3702 | | |
3705 | | - | |
| 3703 | + | |
3706 | 3704 | | |
3707 | 3705 | | |
3708 | 3706 | | |
| |||
3716 | 3714 | | |
3717 | 3715 | | |
3718 | 3716 | | |
3719 | | - | |
| 3717 | + | |
3720 | 3718 | | |
3721 | 3719 | | |
3722 | 3720 | | |
| |||
0 commit comments