fs/ntfs/attrlist.c | 4 ++-- fs/ntfs/collate.c | 2 +- fs/ntfs/inode.c | 28 ++++++++++++++++++---------- fs/ntfs/reparse.c | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-)
From: Baolin Liu <liubaolin@kylinos.cn> Changes in v2: - Patch 2: Fixed ntfs_extent_inode_open() to use ERR_PTR() instead of NULL, so it can properly propagate error codes (suggested by maintainer). Updated ntfs_inode_attach_all_extents() to use IS_ERR()/PTR_ERR() to preserve the actual error code from ntfs_extent_inode_open(). - Patches 1, 3, 4, 5: No code changes, added Reviewed-by tag from Hyunchul Lee Five places in fs/ntfs/ return the wrong error code: a real errno is replaced by -1 or by a hardcoded substitute, so callers and userspace see something unrelated to what actually went wrong. The fixes are independent of each other. Patch 1 is different from the rest: there the error is not just mislabelled, it is not seen as an error at all. -1 is what a normal comparison returns for "collates before", so ntfs_ie_lookup() acts on it as a tree-descent hint, and a malformed entry in $Reparse/$R or $ObjId/$O is silently treated as a lookup miss instead of being reported. Patch 2 fixes ntfs_extent_inode_open() which had two bugs: it treated map_mft_record() failure as success, and returned NULL for all errors (losing error information). Now it returns ERR_PTR() with the actual error code (-EIO, -ENOMEM, -EINVAL). Patch 3 fixes a -1 return in inode.c that reaches userspace as EPERM. It loses ENOSPC among others, so a full volume misreports create(), mkdir() and link(). Patches 4 and 5 restore errors that are already available as an ERR_PTR. Both collapse -ENOMEM into something else, so an allocation failure is misreported. No control flow is changed; every callee already returned these codes. Based on ntfs-next (0fecc393f206). Baolin Liu (5): ntfs: return -EINVAL from ntfs_collate_ntofs_ulongs() on bad length ntfs: fix error handling in ntfs_extent_inode_open and propagate errors ntfs: preserve the truncate error in ntfs_enlarge_attribute() ntfs: propagate the map_mft_record() error in ntfs_attrlist_entry_add() ntfs: propagate the ntfs_attr_iget() error in update_reparse_data() fs/ntfs/attrlist.c | 4 ++-- fs/ntfs/collate.c | 2 +- fs/ntfs/inode.c | 28 ++++++++++++++++++---------- fs/ntfs/reparse.c | 2 +- 4 files changed, 22 insertions(+), 14 deletions(-) -- 2.51.0
On Fri, Sep 4, 2026 at 6:01 PM Baolin Liu <liubaolin12138@163.com> wrote:
>
> From: Baolin Liu <liubaolin@kylinos.cn>
>
> Changes in v2:
> - Patch 2: Fixed ntfs_extent_inode_open() to use ERR_PTR() instead of NULL,
> so it can properly propagate error codes (suggested by maintainer).
> Updated ntfs_inode_attach_all_extents() to use IS_ERR()/PTR_ERR() to
> preserve the actual error code from ntfs_extent_inode_open().
> - Patches 1, 3, 4, 5: No code changes, added Reviewed-by tag from Hyunchul Lee
>
> Five places in fs/ntfs/ return the wrong error code: a real errno is
> replaced by -1 or by a hardcoded substitute, so callers and userspace see
> something unrelated to what actually went wrong. The fixes are
> independent of each other.
>
> Patch 1 is different from the rest: there the error is not just
> mislabelled, it is not seen as an error at all. -1 is what a normal
> comparison returns for "collates before", so ntfs_ie_lookup() acts on it
> as a tree-descent hint, and a malformed entry in $Reparse/$R or $ObjId/$O
> is silently treated as a lookup miss instead of being reported.
>
> Patch 2 fixes ntfs_extent_inode_open() which had two bugs: it treated
> map_mft_record() failure as success, and returned NULL for all errors
> (losing error information). Now it returns ERR_PTR() with the actual
> error code (-EIO, -ENOMEM, -EINVAL).
>
> Patch 3 fixes a -1 return in inode.c that reaches userspace as EPERM.
> It loses ENOSPC among others, so a full volume misreports create(),
> mkdir() and link().
>
> Patches 4 and 5 restore errors that are already available as an ERR_PTR.
> Both collapse -ENOMEM into something else, so an allocation failure is
> misreported.
>
> No control flow is changed; every callee already returned these codes.
>
> Based on ntfs-next (0fecc393f206).
>
> Baolin Liu (5):
> ntfs: return -EINVAL from ntfs_collate_ntofs_ulongs() on bad length
> ntfs: fix error handling in ntfs_extent_inode_open and propagate errors
> ntfs: preserve the truncate error in ntfs_enlarge_attribute()
> ntfs: propagate the map_mft_record() error in ntfs_attrlist_entry_add()
> ntfs: propagate the ntfs_attr_iget() error in update_reparse_data()
Applied them to #ntfs-next except 0002 patch("ntfs: fix error handling
in ntfs_extent_inode_open and propagate errors").
Thanks!
在 2026/9/4 22:22, Namjae Jeon 写道:
> On Fri, Sep 4, 2026 at 6:01 PM Baolin Liu <liubaolin12138@163.com> wrote:
>>
>> From: Baolin Liu <liubaolin@kylinos.cn>
>>
>> Changes in v2:
>> - Patch 2: Fixed ntfs_extent_inode_open() to use ERR_PTR() instead of NULL,
>> so it can properly propagate error codes (suggested by maintainer).
>> Updated ntfs_inode_attach_all_extents() to use IS_ERR()/PTR_ERR() to
>> preserve the actual error code from ntfs_extent_inode_open().
>> - Patches 1, 3, 4, 5: No code changes, added Reviewed-by tag from Hyunchul Lee
>>
>> Five places in fs/ntfs/ return the wrong error code: a real errno is
>> replaced by -1 or by a hardcoded substitute, so callers and userspace see
>> something unrelated to what actually went wrong. The fixes are
>> independent of each other.
>>
>> Patch 1 is different from the rest: there the error is not just
>> mislabelled, it is not seen as an error at all. -1 is what a normal
>> comparison returns for "collates before", so ntfs_ie_lookup() acts on it
>> as a tree-descent hint, and a malformed entry in $Reparse/$R or $ObjId/$O
>> is silently treated as a lookup miss instead of being reported.
>>
>> Patch 2 fixes ntfs_extent_inode_open() which had two bugs: it treated
>> map_mft_record() failure as success, and returned NULL for all errors
>> (losing error information). Now it returns ERR_PTR() with the actual
>> error code (-EIO, -ENOMEM, -EINVAL).
>>
>> Patch 3 fixes a -1 return in inode.c that reaches userspace as EPERM.
>> It loses ENOSPC among others, so a full volume misreports create(),
>> mkdir() and link().
>>
>> Patches 4 and 5 restore errors that are already available as an ERR_PTR.
>> Both collapse -ENOMEM into something else, so an allocation failure is
>> misreported.
>>
>> No control flow is changed; every callee already returned these codes.
>>
>> Based on ntfs-next (0fecc393f206).
>>
>> Baolin Liu (5):
>> ntfs: return -EINVAL from ntfs_collate_ntofs_ulongs() on bad length
>> ntfs: fix error handling in ntfs_extent_inode_open and propagate errors
>> ntfs: preserve the truncate error in ntfs_enlarge_attribute()
>> ntfs: propagate the map_mft_record() error in ntfs_attrlist_entry_add()
>> ntfs: propagate the ntfs_attr_iget() error in update_reparse_data()
> Applied them to #ntfs-next except 0002 patch("ntfs: fix error handling
> in ntfs_extent_inode_open and propagate errors").
> Thanks!
Hi Namjae,
Thanks for applying them.I'll send the 0002 patch alone as v3.
Thanks,
Baolin.
© 2016 - 2026 Red Hat, Inc.