* [PATCH] afs: Fix endless loop in directory parsing
@ 2024-02-23 13:15 David Howells
2024-02-23 13:28 ` Marc Dionne
2024-02-23 15:15 ` Christian Brauner
0 siblings, 2 replies; 3+ messages in thread
From: David Howells @ 2024-02-23 13:15 UTC (permalink / raw)
To: Marc Dionne
Cc: dhowells, Markus Suvanto, Christian Brauner, linux-afs,
linux-fsdevel, linux-kernel
If a directory has a block with only ".__afsXXXX" files in it (from
uncompleted silly-rename), these .__afsXXXX files are skipped but without
advancing the file position in the dir_context. This leads to
afs_dir_iterate() repeating the block again and again.
Fix this by making the code that skips the .__afsXXXX file also manually
advance the file position.
The symptoms are a soft lookup:
watchdog: BUG: soft lockup - CPU#3 stuck for 52s! [check:5737]
...
RIP: 0010:afs_dir_iterate_block+0x39/0x1fd
...
? watchdog_timer_fn+0x1a6/0x213
...
? asm_sysvec_apic_timer_interrupt+0x16/0x20
? afs_dir_iterate_block+0x39/0x1fd
afs_dir_iterate+0x10a/0x148
afs_readdir+0x30/0x4a
iterate_dir+0x93/0xd3
__do_sys_getdents64+0x6b/0xd4
This is almost certainly the actual fix for:
https://bugzilla.kernel.org/show_bug.cgi?id=218496
Fixes: 57e9d49c5452 ("afs: Hide silly-rename files from userspace")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: Markus Suvanto <markus.suvanto@gmail.com>
cc: linux-afs@lists.infradead.org
---
fs/afs/dir.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index b5b8de521f99..8a67fc427e74 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -479,8 +479,10 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,
dire->u.name[0] == '.' &&
ctx->actor != afs_lookup_filldir &&
ctx->actor != afs_lookup_one_filldir &&
- memcmp(dire->u.name, ".__afs", 6) == 0)
+ memcmp(dire->u.name, ".__afs", 6) == 0) {
+ ctx->pos = blkoff + next * sizeof(union afs_xdr_dirent);
continue;
+ }
/* found the next entry */
if (!dir_emit(ctx, dire->u.name, nlen,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] afs: Fix endless loop in directory parsing
2024-02-23 13:15 [PATCH] afs: Fix endless loop in directory parsing David Howells
@ 2024-02-23 13:28 ` Marc Dionne
2024-02-23 15:15 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Marc Dionne @ 2024-02-23 13:28 UTC (permalink / raw)
To: David Howells
Cc: Markus Suvanto, Christian Brauner, linux-afs, linux-fsdevel,
linux-kernel
On Fri, Feb 23, 2024 at 9:15 AM David Howells <dhowells@redhat.com> wrote:
>
>
> If a directory has a block with only ".__afsXXXX" files in it (from
> uncompleted silly-rename), these .__afsXXXX files are skipped but without
> advancing the file position in the dir_context. This leads to
> afs_dir_iterate() repeating the block again and again.
>
> Fix this by making the code that skips the .__afsXXXX file also manually
> advance the file position.
>
> The symptoms are a soft lookup:
>
> watchdog: BUG: soft lockup - CPU#3 stuck for 52s! [check:5737]
> ...
> RIP: 0010:afs_dir_iterate_block+0x39/0x1fd
> ...
> ? watchdog_timer_fn+0x1a6/0x213
> ...
> ? asm_sysvec_apic_timer_interrupt+0x16/0x20
> ? afs_dir_iterate_block+0x39/0x1fd
> afs_dir_iterate+0x10a/0x148
> afs_readdir+0x30/0x4a
> iterate_dir+0x93/0xd3
> __do_sys_getdents64+0x6b/0xd4
>
> This is almost certainly the actual fix for:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=218496
>
> Fixes: 57e9d49c5452 ("afs: Hide silly-rename files from userspace")
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: Marc Dionne <marc.dionne@auristor.com>
> cc: Markus Suvanto <markus.suvanto@gmail.com>
> cc: linux-afs@lists.infradead.org
> ---
> fs/afs/dir.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index b5b8de521f99..8a67fc427e74 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -479,8 +479,10 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode,
> dire->u.name[0] == '.' &&
> ctx->actor != afs_lookup_filldir &&
> ctx->actor != afs_lookup_one_filldir &&
> - memcmp(dire->u.name, ".__afs", 6) == 0)
> + memcmp(dire->u.name, ".__afs", 6) == 0) {
> + ctx->pos = blkoff + next * sizeof(union afs_xdr_dirent);
> continue;
> + }
>
> /* found the next entry */
> if (!dir_emit(ctx, dire->u.name, nlen,
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
Marc
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] afs: Fix endless loop in directory parsing
2024-02-23 13:15 [PATCH] afs: Fix endless loop in directory parsing David Howells
2024-02-23 13:28 ` Marc Dionne
@ 2024-02-23 15:15 ` Christian Brauner
1 sibling, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2024-02-23 15:15 UTC (permalink / raw)
To: Marc Dionne, David Howells
Cc: Christian Brauner, Markus Suvanto, linux-afs, linux-fsdevel,
linux-kernel
On Fri, 23 Feb 2024 13:15:02 +0000, David Howells wrote:
>
> If a directory has a block with only ".__afsXXXX" files in it (from
> uncompleted silly-rename), these .__afsXXXX files are skipped but without
> advancing the file position in the dir_context. This leads to
> afs_dir_iterate() repeating the block again and again.
>
> Fix this by making the code that skips the .__afsXXXX file also manually
> advance the file position.
>
> [...]
Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes
[1/1] afs: Fix endless loop in directory parsing
https://git.kernel.org/vfs/vfs/c/c7742709248d
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-23 15:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-23 13:15 [PATCH] afs: Fix endless loop in directory parsing David Howells
2024-02-23 13:28 ` Marc Dionne
2024-02-23 15:15 ` Christian Brauner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®