Skip to content

Commit 57e9d49

Browse files
committed
afs: Hide silly-rename files from userspace
There appears to be a race between silly-rename files being created/removed and various userspace tools iterating over the contents of a directory, leading to such errors as: find: './kernel/.tmp_cpio_dir/include/dt-bindings/reset/.__afs2080': No such file or directory tar: ./include/linux/greybus/.__afs3C95: File removed before we read it when building a kernel. Fix afs_readdir() so that it doesn't return .__afsXXXX silly-rename files to userspace. This doesn't stop them being looked up directly by name as we need to be able to look them up from within the kernel as part of the silly-rename algorithm. Fixes: 79ddbfa ("afs: Implement sillyrename for unlink and rename") Signed-off-by: David Howells <[email protected]> cc: Marc Dionne <[email protected]> cc: [email protected]
1 parent c3d6569 commit 57e9d49

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/afs/dir.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,14 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,
474474
continue;
475475
}
476476

477+
/* Don't expose silly rename entries to userspace. */
478+
if (nlen > 6 &&
479+
dire->u.name[0] == '.' &&
480+
ctx->actor != afs_lookup_filldir &&
481+
ctx->actor != afs_lookup_one_filldir &&
482+
memcmp(dire->u.name, ".__afs", 6) == 0)
483+
continue;
484+
477485
/* found the next entry */
478486
if (!dir_emit(ctx, dire->u.name, nlen,
479487
ntohl(dire->u.vnode),

0 commit comments

Comments
 (0)