Skip to content

Commit 87fbd63

Browse files
author
Al Viro
committed
affs_lookup: switch to d_splice_alias()
Making something exportable takes more than providing ->s_export_ops. In particular, ->lookup() *MUST* use d_splice_alias() instead of d_add(). Reading Documentation/filesystems/nfs/Exporting would've been a good idea; as it is, exporting AFFS is badly (and exploitably) broken. Partially-Fixes: ed4433d "fs/affs: make affs exportable" Acked-by: David Sterba <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 30da870 commit 87fbd63

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

fs/affs/namei.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
201201
struct super_block *sb = dir->i_sb;
202202
struct buffer_head *bh;
203203
struct inode *inode = NULL;
204+
struct dentry *res;
204205

205206
pr_debug("%s(\"%pd\")\n", __func__, dentry);
206207

@@ -223,14 +224,12 @@ affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
223224
}
224225
affs_brelse(bh);
225226
inode = affs_iget(sb, ino);
226-
if (IS_ERR(inode)) {
227-
affs_unlock_dir(dir);
228-
return ERR_CAST(inode);
229-
}
230227
}
231-
d_add(dentry, inode);
228+
res = d_splice_alias(inode, dentry);
229+
if (!IS_ERR_OR_NULL(res))
230+
res->d_fsdata = dentry->d_fsdata;
232231
affs_unlock_dir(dir);
233-
return NULL;
232+
return res;
234233
}
235234

236235
int

0 commit comments

Comments
 (0)