public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ext4: fix infinite loop when replaying fast_commit
@ 2024-05-15  8:28 Luis Henriques (SUSE)
  2024-05-15 12:27 ` Zhang Yi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Luis Henriques (SUSE) @ 2024-05-15  8:28 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger, Zhang Yi, Harshad Shirwadkar
  Cc: linux-ext4, linux-kernel, Luis Henriques (SUSE)

When doing fast_commit replay an infinite loop may occur due to an
uninitialized extent_status struct.  ext4_ext_determine_insert_hole() does
not detect the replay and calls ext4_es_find_extent_range(), which will
return immediately without initializing the 'es' variable.

Because 'es' contains garbage, an integer overflow may happen causing an
infinite loop in this function, easily reproducible using fstest generic/039.

This commit fixes this issue by unconditionally initializing the structure
in function ext4_es_find_extent_range().

Thanks to Zhang Yi, for figuring out the real problem!

Fixes: 8016e29f4362 ("ext4: fast commit recovery path")
Signed-off-by: Luis Henriques (SUSE) <luis.henriques@linux.dev>
---
 fs/ext4/extents_status.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
index 4a00e2f019d9..3a53dbb85e15 100644
--- a/fs/ext4/extents_status.c
+++ b/fs/ext4/extents_status.c
@@ -310,6 +310,8 @@ void ext4_es_find_extent_range(struct inode *inode,
 			       ext4_lblk_t lblk, ext4_lblk_t end,
 			       struct extent_status *es)
 {
+	es->es_lblk = es->es_len = es->es_pblk = 0;
+
 	if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
 		return;
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ext4: fix infinite loop when replaying fast_commit
  2024-05-15  8:28 [PATCH v2] ext4: fix infinite loop when replaying fast_commit Luis Henriques (SUSE)
@ 2024-05-15 12:27 ` Zhang Yi
  2024-06-27 13:53 ` Luis Henriques
  2024-06-28 17:17 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Zhang Yi @ 2024-05-15 12:27 UTC (permalink / raw)
  To: Luis Henriques (SUSE)
  Cc: linux-ext4, linux-kernel, Theodore Ts'o, Andreas Dilger,
	Harshad Shirwadkar

On 2024/5/15 16:28, Luis Henriques (SUSE) wrote:
> When doing fast_commit replay an infinite loop may occur due to an
> uninitialized extent_status struct.  ext4_ext_determine_insert_hole() does
> not detect the replay and calls ext4_es_find_extent_range(), which will
> return immediately without initializing the 'es' variable.
> 
> Because 'es' contains garbage, an integer overflow may happen causing an
> infinite loop in this function, easily reproducible using fstest generic/039.
> 
> This commit fixes this issue by unconditionally initializing the structure
> in function ext4_es_find_extent_range().
> 
> Thanks to Zhang Yi, for figuring out the real problem!
> 
> Fixes: 8016e29f4362 ("ext4: fast commit recovery path")
> Signed-off-by: Luis Henriques (SUSE) <luis.henriques@linux.dev>

Thanks for fixing this issue,looks good to me.

Reviewed-by: Zhang Yi <yi.zhang@huawei.com>

> ---
>  fs/ext4/extents_status.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 4a00e2f019d9..3a53dbb85e15 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -310,6 +310,8 @@ void ext4_es_find_extent_range(struct inode *inode,
>  			       ext4_lblk_t lblk, ext4_lblk_t end,
>  			       struct extent_status *es)
>  {
> +	es->es_lblk = es->es_len = es->es_pblk = 0;
> +
>  	if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
>  		return;
>  
> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ext4: fix infinite loop when replaying fast_commit
  2024-05-15  8:28 [PATCH v2] ext4: fix infinite loop when replaying fast_commit Luis Henriques (SUSE)
  2024-05-15 12:27 ` Zhang Yi
@ 2024-06-27 13:53 ` Luis Henriques
  2024-06-28 17:17 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Luis Henriques @ 2024-06-27 13:53 UTC (permalink / raw)
  To: Theodore Ts'o, Andreas Dilger
  Cc: Zhang Yi, Harshad Shirwadkar, linux-ext4, linux-kernel

On Wed, May 15 2024, Luis Henriques (SUSE) wrote:

> When doing fast_commit replay an infinite loop may occur due to an
> uninitialized extent_status struct.  ext4_ext_determine_insert_hole() does
> not detect the replay and calls ext4_es_find_extent_range(), which will
> return immediately without initializing the 'es' variable.
>
> Because 'es' contains garbage, an integer overflow may happen causing an
> infinite loop in this function, easily reproducible using fstest generic/039.
>
> This commit fixes this issue by unconditionally initializing the structure
> in function ext4_es_find_extent_range().
>
> Thanks to Zhang Yi, for figuring out the real problem!
>
> Fixes: 8016e29f4362 ("ext4: fast commit recovery path")
> Signed-off-by: Luis Henriques (SUSE) <luis.henriques@linux.dev>

Gentle ping...  Has this fell through the cracks?

Cheers,
-- 
Luis

> ---
>  fs/ext4/extents_status.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c
> index 4a00e2f019d9..3a53dbb85e15 100644
> --- a/fs/ext4/extents_status.c
> +++ b/fs/ext4/extents_status.c
> @@ -310,6 +310,8 @@ void ext4_es_find_extent_range(struct inode *inode,
>  			       ext4_lblk_t lblk, ext4_lblk_t end,
>  			       struct extent_status *es)
>  {
> +	es->es_lblk = es->es_len = es->es_pblk = 0;
> +
>  	if (EXT4_SB(inode->i_sb)->s_mount_state & EXT4_FC_REPLAY)
>  		return;
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ext4: fix infinite loop when replaying fast_commit
  2024-05-15  8:28 [PATCH v2] ext4: fix infinite loop when replaying fast_commit Luis Henriques (SUSE)
  2024-05-15 12:27 ` Zhang Yi
  2024-06-27 13:53 ` Luis Henriques
@ 2024-06-28 17:17 ` Theodore Ts'o
  2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2024-06-28 17:17 UTC (permalink / raw)
  To: Andreas Dilger, Zhang Yi, Harshad Shirwadkar,
	Luis Henriques (SUSE)
  Cc: Theodore Ts'o, linux-ext4, linux-kernel


On Wed, 15 May 2024 09:28:57 +0100, Luis Henriques (SUSE) wrote:
> When doing fast_commit replay an infinite loop may occur due to an
> uninitialized extent_status struct.  ext4_ext_determine_insert_hole() does
> not detect the replay and calls ext4_es_find_extent_range(), which will
> return immediately without initializing the 'es' variable.
> 
> Because 'es' contains garbage, an integer overflow may happen causing an
> infinite loop in this function, easily reproducible using fstest generic/039.
> 
> [...]

Applied, thanks!

[1/1] ext4: fix infinite loop when replaying fast_commit
      commit: 907c3fe532253a6ef4eb9c4d67efb71fab58c706

Best regards,
-- 
Theodore Ts'o <tytso@mit.edu>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-06-28 17:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-15  8:28 [PATCH v2] ext4: fix infinite loop when replaying fast_commit Luis Henriques (SUSE)
2024-05-15 12:27 ` Zhang Yi
2024-06-27 13:53 ` Luis Henriques
2024-06-28 17:17 ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox