All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] fs/ntfs3: prevent positive E_NTFS_NONRESIDENT from reaching writeback error handling
@ 2026-07-13  8:41 Vidhu Sarwal
  2026-07-23 13:34 ` Jori Koolstra
  0 siblings, 1 reply; 2+ messages in thread
From: Vidhu Sarwal @ 2026-07-13  8:41 UTC (permalink / raw)
  To: almaz.alexandrovich
  Cc: ntfs3, linux-kernel, linux-fsdevel, skhan, linux-kernel-mentees,
	Vidhu Sarwal, syzbot+57f9327d593d301ce2a2

attr_data_write_resident() returns the internal positive status code
E_NTFS_NONRESIDENT when the DATA attribute becomes non-resident.
ntfs_writepages() propagates this value into generic writeback error
handling, which expects a standard negative errno and triggers
WARN_ON_ONCE(err > 0).

Translate positive E_NTFS_* status codes to -EIO before recording
the writeback error. This prevents positive internal status codes from
reaching generic writeback code while preserving the existing behaviour
of treating this path as a writeback error.

Reported-by: syzbot+57f9327d593d301ce2a2@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=57f9327d593d301ce2a2
Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
---
RFC:

I'd appreciate guidance on whether -EIO is the appropriate errno here.

E_NTFS_NONRESIDENT indicates that the DATA attribute became
non-resident during writeback. Translating it to -EIO prevents the
positive internal status code from reaching generic writeback code and
preserves the existing behaviour of treating this path as a writeback
error.

However, if the intended behaviour is to retry the write using the
non-resident path instead of failing it, then the correct solution would
be more than a simple errno translation. The proposed change assumes the
current terminal-error behaviour is intentional.
 fs/ntfs3/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 0c9bd669117d..9458867c6b0b 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -1019,6 +1019,15 @@ static int ntfs_writepages(struct address_space *mapping,
 
 			folio_unlock(folio);
 			if (err2) {
+				/*
+				 * attr_data_write_resident() can return the
+				 * positive internal code E_NTFS_NONRESIDENT;
+				 * both mapping_set_error() and writeback_iter()
+				 * need a negative errno and warn on a positive
+				 * value.
+				 */
+				if (err2 > 0)
+					err2 = -EIO;
 				mapping_set_error(mapping, err2);
 				if (!err)
 					err = err2;

base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa
-- 
2.53.0


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

* Re: [RFC PATCH] fs/ntfs3: prevent positive E_NTFS_NONRESIDENT from reaching writeback error handling
  2026-07-13  8:41 [RFC PATCH] fs/ntfs3: prevent positive E_NTFS_NONRESIDENT from reaching writeback error handling Vidhu Sarwal
@ 2026-07-23 13:34 ` Jori Koolstra
  0 siblings, 0 replies; 2+ messages in thread
From: Jori Koolstra @ 2026-07-23 13:34 UTC (permalink / raw)
  To: Vidhu Sarwal
  Cc: almaz.alexandrovich, ntfs3, linux-kernel, linux-fsdevel, skhan,
	linux-kernel-mentees, syzbot+57f9327d593d301ce2a2

On Mon, Jul 13, 2026 at 02:11:40PM +0530, Vidhu Sarwal wrote:
> attr_data_write_resident() returns the internal positive status code
> E_NTFS_NONRESIDENT when the DATA attribute becomes non-resident.
> ntfs_writepages() propagates this value into generic writeback error
> handling, which expects a standard negative errno and triggers
> WARN_ON_ONCE(err > 0).
> 
> Translate positive E_NTFS_* status codes to -EIO before recording
> the writeback error. This prevents positive internal status codes from
> reaching generic writeback code while preserving the existing behaviour
> of treating this path as a writeback error.

Should attr_data_write_resident() be returning positive values on error?
If this is correct, and this is a matter of data corruption you can use
EFSCORRUPTED (EIO may also be fine if this is what NTFS uses in other
places).

Thanks,
Jori.

> 
> Reported-by: syzbot+57f9327d593d301ce2a2@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=57f9327d593d301ce2a2
> Signed-off-by: Vidhu Sarwal <vidhu.linux@gmail.com>
> ---
> RFC:
> 
> I'd appreciate guidance on whether -EIO is the appropriate errno here.
> 
> E_NTFS_NONRESIDENT indicates that the DATA attribute became
> non-resident during writeback. Translating it to -EIO prevents the
> positive internal status code from reaching generic writeback code and
> preserves the existing behaviour of treating this path as a writeback
> error.
> 
> However, if the intended behaviour is to retry the write using the
> non-resident path instead of failing it, then the correct solution would
> be more than a simple errno translation. The proposed change assumes the
> current terminal-error behaviour is intentional.
>  fs/ntfs3/inode.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index 0c9bd669117d..9458867c6b0b 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -1019,6 +1019,15 @@ static int ntfs_writepages(struct address_space *mapping,
>  
>  			folio_unlock(folio);
>  			if (err2) {
> +				/*
> +				 * attr_data_write_resident() can return the
> +				 * positive internal code E_NTFS_NONRESIDENT;
> +				 * both mapping_set_error() and writeback_iter()
> +				 * need a negative errno and warn on a positive
> +				 * value.
> +				 */
> +				if (err2 > 0)
> +					err2 = -EIO;
>  				mapping_set_error(mapping, err2);
>  				if (!err)
>  					err = err2;
> 
> base-commit: a13c140cc289c0b7b3770bce5b3ad42ab35074aa
> -- 
> 2.53.0
> 

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

end of thread, other threads:[~2026-07-23 13:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13  8:41 [RFC PATCH] fs/ntfs3: prevent positive E_NTFS_NONRESIDENT from reaching writeback error handling Vidhu Sarwal
2026-07-23 13:34 ` Jori Koolstra

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.