diff options
| author | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2010-01-11 13:32:24 -0500 |
|---|---|---|
| committer | OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> | 2010-01-11 13:47:25 -0500 |
| commit | 8045e2985012bdb95d832dfbcceae1815880a6ed (patch) | |
| tree | 513a853a81eee10f86047b681bf52132592b36b9 | |
| parent | 3c8ad49b015eb115fbd6982f56d530f53cf57f84 (diff) | |
fat: Fix vfat_lookup()
After d_find_alias(), vfat_lookup() checks !(->d_flags & DCACHE_DISCONNECTED)
without IS_ROOT(). This means it hits non-anonymous but disconnected
dentry. (NOTE: d_splice_alias() doesn't clear DCACHE_DISCONNECTED)
But, vfat_lookup() has interest to alias if it was non-anonymous. So,
this adds vfat_d_anon_disconn() helper to check it correctly.
Another bug is refcnt leak. It needs dput() for uninterested alias.
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
| -rw-r--r-- | fs/fat/namei_vfat.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index f565f24019b5..411c192a05fa 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
| @@ -701,6 +701,15 @@ static int vfat_find(struct inode *dir, struct qstr *qname, | |||
| 701 | return fat_search_long(dir, qname->name, len, sinfo); | 701 | return fat_search_long(dir, qname->name, len, sinfo); |
| 702 | } | 702 | } |
| 703 | 703 | ||
| 704 | /* | ||
| 705 | * (nfsd's) anonymous disconnected dentry? | ||
| 706 | * NOTE: !IS_ROOT() is not anonymous (I.e. d_splice_alias() did the job). | ||
| 707 | */ | ||
| 708 | static int vfat_d_anon_disconn(struct dentry *dentry) | ||
| 709 | { | ||
| 710 | return IS_ROOT(dentry) && (dentry->d_flags & DCACHE_DISCONNECTED); | ||
| 711 | } | ||
| 712 | |||
| 704 | static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | 713 | static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, |
| 705 | struct nameidata *nd) | 714 | struct nameidata *nd) |
| 706 | { | 715 | { |
| @@ -729,11 +738,11 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
| 729 | } | 738 | } |
| 730 | 739 | ||
| 731 | alias = d_find_alias(inode); | 740 | alias = d_find_alias(inode); |
| 732 | if (alias && !(alias->d_flags & DCACHE_DISCONNECTED)) { | 741 | if (alias && !vfat_d_anon_disconn(alias)) { |
| 733 | /* | 742 | /* |
| 734 | * This inode has non DCACHE_DISCONNECTED dentry. This | 743 | * This inode has non anonymous-DCACHE_DISCONNECTED |
| 735 | * means, the user did ->lookup() by an another name | 744 | * dentry. This means, the user did ->lookup() by an |
| 736 | * (longname vs 8.3 alias of it) in past. | 745 | * another name (longname vs 8.3 alias of it) in past. |
| 737 | * | 746 | * |
| 738 | * Switch to new one for reason of locality if possible. | 747 | * Switch to new one for reason of locality if possible. |
| 739 | */ | 748 | */ |
| @@ -743,7 +752,9 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry, | |||
| 743 | iput(inode); | 752 | iput(inode); |
| 744 | unlock_super(sb); | 753 | unlock_super(sb); |
| 745 | return alias; | 754 | return alias; |
| 746 | } | 755 | } else |
| 756 | dput(alias); | ||
| 757 | |||
| 747 | out: | 758 | out: |
| 748 | unlock_super(sb); | 759 | unlock_super(sb); |
| 749 | dentry->d_op = sb->s_root->d_op; | 760 | dentry->d_op = sb->s_root->d_op; |
