[PATCH] ubifs: prevent corrupted data write via error_remove_folio

fan.yu9@zte.com.cn posted 1 patch 1 month, 2 weeks ago
There is a newer version of this series
fs/ubifs/file.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] ubifs: prevent corrupted data write via error_remove_folio
Posted by fan.yu9@zte.com.cn 1 month, 2 weeks ago
From: Jinpeng Cui <cui.jinpeng2@zte.com.cn>

When a memory corruption event triggers memory_failure, ext4 releases references to the affected dirty pages,
ensuring that no corrupted data is written to disk. However, ubifs currently lacks the error_remove_folio capability
and therefore cannot release references to faulty private memory. As a result, corrupted data may eventually be
written to flash storage.

Add generic_error_remove_folio support to ubifs, preventing corrupted memory data from being persisted to flash.

Signed-off-by: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
Signed-off-by: Fan Yu <fan.yu9@zte.com.cn>
Cc: Shengming Hu <hu.shengming@zte.com.cn>
---
 fs/ubifs/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index 3dc3ca1..34445b7 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1631,6 +1631,7 @@ static int ubifs_symlink_getattr(struct mnt_idmap *idmap,
    .dirty_folio    = ubifs_dirty_folio,
    .migrate_folio  = filemap_migrate_folio,
    .release_folio  = ubifs_release_folio,
+   .error_remove_folio = generic_error_remove_folio,
 };

 const struct inode_operations ubifs_file_inode_operations = {
--
1.8.3.1
Re: [PATCH] ubifs: prevent corrupted data write via error_remove_folio
Posted by xu.xin16@zte.com.cn 1 month, 2 weeks ago
> From: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
> 
> When a memory corruption event triggers memory_failure, ext4 releases references to the affected dirty pages,
> ensuring that no corrupted data is written to disk. However, ubifs currently lacks the error_remove_folio capability
> and therefore cannot release references to faulty private memory. As a result, corrupted data may eventually be
> written to flash storage.
> 
> Add generic_error_remove_folio support to ubifs, preventing corrupted memory data from being persisted to flash.

The commit description is unwrapped (exceeds 75 chars per line).

> 
> Signed-off-by: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
> Signed-off-by: Fan Yu <fan.yu9@zte.com.cn>
> Cc: Shengming Hu <hu.shengming@zte.com.cn>
> ---
>  fs/ubifs/file.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index 3dc3ca1..34445b7 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -1631,6 +1631,7 @@ static int ubifs_symlink_getattr(struct mnt_idmap *idmap,
>     .dirty_folio    = ubifs_dirty_folio,
>     .migrate_folio  = filemap_migrate_folio,
>     .release_folio  = ubifs_release_folio,
> +   .error_remove_folio = generic_error_remove_folio,

There's a space at the start of a line. Try to use ./scripts/checkpatch.pl.

Thanks.


>  };
> 
>  const struct inode_operations ubifs_file_inode_operations = {
> --
> 1.8.3.1
>

Xu Xin
Re: [PATCH] ubifs: prevent corrupted data write via error_remove_folio
Posted by Zhihao Cheng 1 month, 2 weeks ago
在 2026/2/11 15:40, fan.yu9@zte.com.cn 写道:
> From: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
> 
> When a memory corruption event triggers memory_failure, ext4 releases references to the affected dirty pages,
> ensuring that no corrupted data is written to disk. However, ubifs currently lacks the error_remove_folio capability
> and therefore cannot release references to faulty private memory. As a result, corrupted data may eventually be
> written to flash storage.
> 
> Add generic_error_remove_folio support to ubifs, preventing corrupted memory data from being persisted to flash.
> 
> Signed-off-by: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
> Signed-off-by: Fan Yu <fan.yu9@zte.com.cn>
> Cc: Shengming Hu <hu.shengming@zte.com.cn>
> ---
>   fs/ubifs/file.c | 1 +
>   1 file changed, 1 insertion(+)
> 

The 'error_remove_folio' was introduced in commit 
257187362123f15d9d1("HWPOISON: Define a new error_remove_page address 
space op for async truncation") to distinguish the error handling 
behavior beteween metadata page and data page. Files' datapage will be 
truncated if memory error happens during page copy(eg. migration, 
mmap_cow). Then several filesystems(with '.migrate_page' implemtented) 
supportted it. So, I'm fine with this patch.

Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index 3dc3ca1..34445b7 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -1631,6 +1631,7 @@ static int ubifs_symlink_getattr(struct mnt_idmap *idmap,
>      .dirty_folio    = ubifs_dirty_folio,
>      .migrate_folio  = filemap_migrate_folio,
>      .release_folio  = ubifs_release_folio,
> +   .error_remove_folio = generic_error_remove_folio,
>   };
> 
>   const struct inode_operations ubifs_file_inode_operations = {
> --
> 1.8.3.1
> .
>