[PATCH 5.4 032/267] afs: Hide silly-rename files from userspace
Jeffrey E Altman
jaltman at auristor.com
Sat Mar 2 20:32:04 PST 2024
Greg,
If its not too late it would be best not to backport this change to 6.7,
6.6, 6.1, 5.15, 5.10, and 5.4.
This change can result in an infinite loop in directory parsing and the
fix for that has yet to be merged by Linus.
Sorry for the additional work.
Thank you.
Jeffrey Altman
On 2/21/2024 8:06 AM, Greg Kroah-Hartman wrote:
> 5.4-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: David Howells <dhowells at redhat.com>
>
> [ Upstream commit 57e9d49c54528c49b8bffe6d99d782ea051ea534 ]
>
> 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: 79ddbfa500b3 ("afs: Implement sillyrename for unlink and rename")
> Signed-off-by: David Howells <dhowells at redhat.com>
> cc: Marc Dionne <marc.dionne at auristor.com>
> cc: linux-afs at lists.infradead.org
> Signed-off-by: Sasha Levin <sashal at kernel.org>
> ---
> fs/afs/dir.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 43f5b972fcea..8bed9df09230 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -421,6 +421,14 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,
> continue;
> }
>
> + /* Don't expose silly rename entries to userspace. */
> + if (nlen > 6 &&
> + dire->u.name[0] == '.' &&
> + ctx->actor != afs_lookup_filldir &&
> + ctx->actor != afs_lookup_one_filldir &&
> + memcmp(dire->u.name, ".__afs", 6) == 0)
> + continue;
> +
> /* found the next entry */
> if (!dir_emit(ctx, dire->u.name, nlen,
> ntohl(dire->u.vnode),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4039 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.infradead.org/pipermail/linux-afs/attachments/20240302/3979f14f/attachment.p7s>
More information about the linux-afs
mailing list