Skip to contentSkip to conversation

mmp:fix wrong comparison in ext2fs_mmp_stop

PATCH Applied lihaoxiang (F) 2 participants 4 messages Nov 29, 2022 – Jan 27, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmp:fix wrong comparison in ext2fs_mmp_stop

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.

---
 lib/ext2fs/mmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ext2fs/mmp.c +1 -1
index 7970aac2..14289706 100644
@@ -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;
 
Signature · 1 line
2.37.0.windows.1
#1 lore raw

friendly ping...

Quoted 34 lines · lihaoxiang (F)

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.

---
 lib/ext2fs/mmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ext2fs/mmp.c +1 -1
index 7970aac2..14289706 100644
@@ -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 lore raw

friendly ping...

Quoted 37 lines · lihaoxiang (F)

friendly ping...

Quoted 34 lines · lihaoxiang (F)

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.

---
 lib/ext2fs/mmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/ext2fs/mmp.c +1 -1
index 7970aac2..14289706 100644
@@ -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;
 
#3 lore raw
In reply to lihaoxiang (F)
Quoted 13 lines · lihaoxiang (F)

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.

Quoted 1 line

[...]

Applied, thanks!

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

Best regards,

Signature · 1 line
Theodore Ts'o <[email protected]>