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

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: ed4433d72394 "fs/affs: make affs exportable"
Acked-by: David Sterba <dsterba@suse.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 87fbd639 30da870c

+5 -6
+5 -6
fs/affs/namei.c
··· 201 201 struct super_block *sb = dir->i_sb; 202 202 struct buffer_head *bh; 203 203 struct inode *inode = NULL; 204 + struct dentry *res; 204 205 205 206 pr_debug("%s(\"%pd\")\n", __func__, dentry); 206 207 ··· 224 223 } 225 224 affs_brelse(bh); 226 225 inode = affs_iget(sb, ino); 227 - if (IS_ERR(inode)) { 228 - affs_unlock_dir(dir); 229 - return ERR_CAST(inode); 230 - } 231 226 } 232 - d_add(dentry, inode); 227 + res = d_splice_alias(inode, dentry); 228 + if (!IS_ERR_OR_NULL(res)) 229 + res->d_fsdata = dentry->d_fsdata; 233 230 affs_unlock_dir(dir); 234 - return NULL; 231 + return res; 235 232 } 236 233 237 234 int