Linux-ext4 Archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop
@ 2022-11-29  7:02 lihaoxiang (F)
  2022-12-09  3:37 ` lihaoxiang (F)
  2023-01-26 16:01 ` Theodore Ts'o
  0 siblings, 2 replies; 4+ messages in thread
From: lihaoxiang (F) @ 2022-11-29  7:02 UTC (permalink / raw
  To: tytso; +Cc: linux-ext4, Zhiqiang Liu, linfeilong, louhongxiang, lijinlin (A)

In our knowledge, ext2fs_mmp_stop use to process the rest of work
when mmp will finish. Critically, it must check if the mmp block is
not changed. But there exist an error in comparing the mmp and mmp_cmp.

Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the
superblock of disk and it copy to mmp_buf if mmp_buf is not none
and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop
pass the no NULL pointer fs->mmp_buf which has possed the mmp info to
ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf
by fs->mmp_cmp so that loss the meaning of comparing themselves
after that and worse yet, couldn't judge whether the struct of mmp
has changed.

In fact, we only need to modify the parameter to NULL pointer for
solving this problem.

Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
---
 lib/ext2fs/mmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index 7970aac2..14289706 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -407,7 +407,7 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs)
 	    (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL))
 		goto mmp_error;

-	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
+	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
 	if (retval)
 		goto mmp_error;

-- 
2.37.0.windows.1

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

* Re: [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop
  2022-11-29  7:02 [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop lihaoxiang (F)
@ 2022-12-09  3:37 ` lihaoxiang (F)
  2023-01-10  9:03   ` lihaoxiang (F)
  2023-01-26 16:01 ` Theodore Ts'o
  1 sibling, 1 reply; 4+ messages in thread
From: lihaoxiang (F) @ 2022-12-09  3:37 UTC (permalink / raw
  To: tytso; +Cc: linux-ext4, Zhiqiang Liu, linfeilong, louhongxiang, lijinlin (A)

friendly ping...

On 2022/11/29 15:02, lihaoxiang (F) wrote:
> In our knowledge, ext2fs_mmp_stop use to process the rest of work
> when mmp will finish. Critically, it must check if the mmp block is
> not changed. But there exist an error in comparing the mmp and mmp_cmp.
> 
> Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the
> superblock of disk and it copy to mmp_buf if mmp_buf is not none
> and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop
> pass the no NULL pointer fs->mmp_buf which has possed the mmp info to
> ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf
> by fs->mmp_cmp so that loss the meaning of comparing themselves
> after that and worse yet, couldn't judge whether the struct of mmp
> has changed.
> 
> In fact, we only need to modify the parameter to NULL pointer for
> solving this problem.
> 
> Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
> ---
>  lib/ext2fs/mmp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
> index 7970aac2..14289706 100644
> --- a/lib/ext2fs/mmp.c
> +++ b/lib/ext2fs/mmp.c
> @@ -407,7 +407,7 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs)
>  	    (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL))
>  		goto mmp_error;
> 
> -	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
> +	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
>  	if (retval)
>  		goto mmp_error;
> 

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

* Re: [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop
  2022-12-09  3:37 ` lihaoxiang (F)
@ 2023-01-10  9:03   ` lihaoxiang (F)
  0 siblings, 0 replies; 4+ messages in thread
From: lihaoxiang (F) @ 2023-01-10  9:03 UTC (permalink / raw
  To: tytso; +Cc: linux-ext4, Zhiqiang Liu, linfeilong, louhongxiang, lijinlin (A)

friendly ping...

On 2022/12/9 11:37, lihaoxiang (F) wrote:
> friendly ping...
> 
> On 2022/11/29 15:02, lihaoxiang (F) wrote:
>> In our knowledge, ext2fs_mmp_stop use to process the rest of work
>> when mmp will finish. Critically, it must check if the mmp block is
>> not changed. But there exist an error in comparing the mmp and mmp_cmp.
>>
>> Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the
>> superblock of disk and it copy to mmp_buf if mmp_buf is not none
>> and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop
>> pass the no NULL pointer fs->mmp_buf which has possed the mmp info to
>> ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf
>> by fs->mmp_cmp so that loss the meaning of comparing themselves
>> after that and worse yet, couldn't judge whether the struct of mmp
>> has changed.
>>
>> In fact, we only need to modify the parameter to NULL pointer for
>> solving this problem.
>>
>> Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com>
>> ---
>>  lib/ext2fs/mmp.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
>> index 7970aac2..14289706 100644
>> --- a/lib/ext2fs/mmp.c
>> +++ b/lib/ext2fs/mmp.c
>> @@ -407,7 +407,7 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs)
>>  	    (fs->mmp_buf == NULL) || (fs->mmp_cmp == NULL))
>>  		goto mmp_error;
>>
>> -	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, fs->mmp_buf);
>> +	retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
>>  	if (retval)
>>  		goto mmp_error;
>>

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

* Re: [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop
  2022-11-29  7:02 [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop lihaoxiang (F)
  2022-12-09  3:37 ` lihaoxiang (F)
@ 2023-01-26 16:01 ` Theodore Ts'o
  1 sibling, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2023-01-26 16:01 UTC (permalink / raw
  To: lihaoxiang (F)
  Cc: Theodore Ts'o, Zhiqiang Liu, lijinlin (A), linfeilong,
	louhongxiang, linux-ext4

On Tue, 29 Nov 2022 15:02:39 +0800, lihaoxiang (F) wrote:
> In our knowledge, ext2fs_mmp_stop use to process the rest of work
> when mmp will finish. Critically, it must check if the mmp block is
> not changed. But there exist an error in comparing the mmp and mmp_cmp.
> 
> Look to ext2fs_mmp_read, the assignment of mmp_cmp retrieve from the
> superblock of disk and it copy to mmp_buf if mmp_buf is not none
> and not equal to mmp_cmp in the meanwhile. However, ext2fs_mmp_stop
> pass the no NULL pointer fs->mmp_buf which has possed the mmp info to
> ext2fs_mmp_read. Consequently, ext2fs_mmp_read override fs->mmp_buf
> by fs->mmp_cmp so that loss the meaning of comparing themselves
> after that and worse yet, couldn't judge whether the struct of mmp
> has changed.
> 
> [...]

Applied, thanks!

[1/1] mmp:fix wrong comparison in ext2fs_mmp_stop
      (no commit info)

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

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

end of thread, other threads:[~2023-01-27 17:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29  7:02 [PATCH] mmp:fix wrong comparison in ext2fs_mmp_stop lihaoxiang (F)
2022-12-09  3:37 ` lihaoxiang (F)
2023-01-10  9:03   ` lihaoxiang (F)
2023-01-26 16:01 ` 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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).