* [PATCH] fs/ntfs3: Fix error handling in ntfs_new_inode()
@ 2023-01-04 12:39 Shigeru Yoshida
2023-01-13 9:44 ` Konstantin Komarov
0 siblings, 1 reply; 3+ messages in thread
From: Shigeru Yoshida @ 2023-01-04 12:39 UTC (permalink / raw)
To: almaz.alexandrovich; +Cc: ntfs3, linux-kernel, Shigeru Yoshida
When memory allocation for mi->mrec fails, ntfs_new_inode() calls
iput(). iput() calls ni_write_inode() indirectly, it references
uninitialized mi->mrec, and this causes the kernel crash. This patch
fixes the issue by making the inode bad before calling iput().
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
---
fs/ntfs3/fsntfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
index 567563771bf8..7b93f2aeb6f6 100644
--- a/fs/ntfs3/fsntfs.c
+++ b/fs/ntfs3/fsntfs.c
@@ -1683,6 +1683,7 @@ struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST rno, bool dir)
out:
if (err) {
+ _ntfs_bad_inode(inode);
iput(inode);
ni = ERR_PTR(err);
}
--
2.39.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ntfs3: Fix error handling in ntfs_new_inode()
2023-01-04 12:39 [PATCH] fs/ntfs3: Fix error handling in ntfs_new_inode() Shigeru Yoshida
@ 2023-01-13 9:44 ` Konstantin Komarov
2023-01-16 8:33 ` Shigeru Yoshida
0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Komarov @ 2023-01-13 9:44 UTC (permalink / raw)
To: Shigeru Yoshida; +Cc: ntfs3, linux-kernel
On 04.01.2023 16:39, Shigeru Yoshida wrote:
> When memory allocation for mi->mrec fails, ntfs_new_inode() calls
> iput(). iput() calls ni_write_inode() indirectly, it references
> uninitialized mi->mrec, and this causes the kernel crash. This patch
> fixes the issue by making the inode bad before calling iput().
>
> Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
> ---
> fs/ntfs3/fsntfs.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
> index 567563771bf8..7b93f2aeb6f6 100644
> --- a/fs/ntfs3/fsntfs.c
> +++ b/fs/ntfs3/fsntfs.c
> @@ -1683,6 +1683,7 @@ struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST rno, bool dir)
>
> out:
> if (err) {
> + _ntfs_bad_inode(inode);
> iput(inode);
> ni = ERR_PTR(err);
> }
Hello.
This bug have been already fixed by Ye Bin
(https://lore.kernel.org/lkml/20221117091912.3436127-1-yebin@huaweicloud.com/).
* Thanks for your work.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/ntfs3: Fix error handling in ntfs_new_inode()
2023-01-13 9:44 ` Konstantin Komarov
@ 2023-01-16 8:33 ` Shigeru Yoshida
0 siblings, 0 replies; 3+ messages in thread
From: Shigeru Yoshida @ 2023-01-16 8:33 UTC (permalink / raw)
To: Konstantin Komarov; +Cc: ntfs3, linux-kernel
Hi,
On Fri, Jan 13, 2023 at 01:44:48PM +0400, Konstantin Komarov wrote:
> On 04.01.2023 16:39, Shigeru Yoshida wrote:
> > When memory allocation for mi->mrec fails, ntfs_new_inode() calls
> > iput(). iput() calls ni_write_inode() indirectly, it references
> > uninitialized mi->mrec, and this causes the kernel crash. This patch
> > fixes the issue by making the inode bad before calling iput().
> >
> > Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
> > ---
> > fs/ntfs3/fsntfs.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/fs/ntfs3/fsntfs.c b/fs/ntfs3/fsntfs.c
> > index 567563771bf8..7b93f2aeb6f6 100644
> > --- a/fs/ntfs3/fsntfs.c
> > +++ b/fs/ntfs3/fsntfs.c
> > @@ -1683,6 +1683,7 @@ struct ntfs_inode *ntfs_new_inode(struct ntfs_sb_info *sbi, CLST rno, bool dir)
> > out:
> > if (err) {
> > + _ntfs_bad_inode(inode);
> > iput(inode);
> > ni = ERR_PTR(err);
> > }
>
> Hello.
>
> This bug have been already fixed by Ye Bin (https://lore.kernel.org/lkml/20221117091912.3436127-1-yebin@huaweicloud.com/).
I've missed the fix you mentioned.
Thank you so much for your reply!
Shigeru
>
> * Thanks for your work.
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-16 8:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 12:39 [PATCH] fs/ntfs3: Fix error handling in ntfs_new_inode() Shigeru Yoshida
2023-01-13 9:44 ` Konstantin Komarov
2023-01-16 8:33 ` Shigeru Yoshida
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 NNTP newsgroup(s).