* [PATCH] fs/ntfs3: Fix NULL dereference in ni_write_inode
@ 2022-10-30 7:02 ` Abdun Nihaal
0 siblings, 0 replies; 4+ messages in thread
From: Abdun Nihaal @ 2022-10-30 7:02 UTC (permalink / raw)
To: almaz.alexandrovich
Cc: ntfs3, linux-kernel, skhan, linux-kernel-mentees, Abdun Nihaal,
syzbot+f45957555ed4a808cc7a
Syzbot reports a NULL dereference in ni_write_inode.
When creating a new inode, if allocation fails in mi_init function
(called in mi_format_new function), mi->mrec is set to NULL.
In the error path of this inode creation, mi->mrec is later
dereferenced in ni_write_inode.
Add a NULL check to prevent NULL dereference.
Link: https://syzkaller.appspot.com/bug?extid=f45957555ed4a808cc7a
Reported-and-tested-by: syzbot+f45957555ed4a808cc7a@syzkaller.appspotmail.com
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
---
fs/ntfs3/frecord.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 70a80f9412f7..e55bbd209ef8 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -3243,6 +3243,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
return 0;
}
+ if (!ni->mi.mrec)
+ goto out;
+
if (is_rec_inuse(ni->mi.mrec) &&
!(sbi->flags & NTFS_FLAGS_LOG_REPLAYING) && inode->i_nlink) {
bool modified = false;
--
2.37.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] fs/ntfs3: Fix NULL dereference in ni_write_inode
@ 2022-10-30 7:02 ` Abdun Nihaal
0 siblings, 0 replies; 4+ messages in thread
From: Abdun Nihaal @ 2022-10-30 7:02 UTC (permalink / raw)
To: almaz.alexandrovich
Cc: syzbot+f45957555ed4a808cc7a, linux-kernel, ntfs3, linux-kernel-mentees
Syzbot reports a NULL dereference in ni_write_inode.
When creating a new inode, if allocation fails in mi_init function
(called in mi_format_new function), mi->mrec is set to NULL.
In the error path of this inode creation, mi->mrec is later
dereferenced in ni_write_inode.
Add a NULL check to prevent NULL dereference.
Link: https://syzkaller.appspot.com/bug?extid=f45957555ed4a808cc7a
Reported-and-tested-by: syzbot+f45957555ed4a808cc7a@syzkaller.appspotmail.com
Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
---
fs/ntfs3/frecord.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
index 70a80f9412f7..e55bbd209ef8 100644
--- a/fs/ntfs3/frecord.c
+++ b/fs/ntfs3/frecord.c
@@ -3243,6 +3243,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
return 0;
}
+ if (!ni->mi.mrec)
+ goto out;
+
if (is_rec_inuse(ni->mi.mrec) &&
!(sbi->flags & NTFS_FLAGS_LOG_REPLAYING) && inode->i_nlink) {
bool modified = false;
--
2.37.3
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] fs/ntfs3: Fix NULL dereference in ni_write_inode
2022-10-30 7:02 ` Abdun Nihaal
@ 2022-12-30 7:22 ` Konstantin Komarov via Linux-kernel-mentees
-1 siblings, 0 replies; 4+ messages in thread
From: Konstantin Komarov @ 2022-12-30 7:22 UTC (permalink / raw)
To: Abdun Nihaal
Cc: ntfs3, linux-kernel, skhan, linux-kernel-mentees,
syzbot+f45957555ed4a808cc7a
On 30.10.2022 11:02, Abdun Nihaal wrote:
> Syzbot reports a NULL dereference in ni_write_inode.
> When creating a new inode, if allocation fails in mi_init function
> (called in mi_format_new function), mi->mrec is set to NULL.
> In the error path of this inode creation, mi->mrec is later
> dereferenced in ni_write_inode.
>
> Add a NULL check to prevent NULL dereference.
>
> Link: https://syzkaller.appspot.com/bug?extid=f45957555ed4a808cc7a
> Reported-and-tested-by: syzbot+f45957555ed4a808cc7a@syzkaller.appspotmail.com
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
> ---
> fs/ntfs3/frecord.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 70a80f9412f7..e55bbd209ef8 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -3243,6 +3243,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
> return 0;
> }
>
> + if (!ni->mi.mrec)
> + goto out;
> +
> if (is_rec_inuse(ni->mi.mrec) &&
> !(sbi->flags & NTFS_FLAGS_LOG_REPLAYING) && inode->i_nlink) {
> bool modified = false;
Thank you for your work, applied!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] fs/ntfs3: Fix NULL dereference in ni_write_inode
@ 2022-12-30 7:22 ` Konstantin Komarov via Linux-kernel-mentees
0 siblings, 0 replies; 4+ messages in thread
From: Konstantin Komarov via Linux-kernel-mentees @ 2022-12-30 7:22 UTC (permalink / raw)
To: Abdun Nihaal
Cc: syzbot+f45957555ed4a808cc7a, ntfs3, linux-kernel-mentees, linux-kernel
On 30.10.2022 11:02, Abdun Nihaal wrote:
> Syzbot reports a NULL dereference in ni_write_inode.
> When creating a new inode, if allocation fails in mi_init function
> (called in mi_format_new function), mi->mrec is set to NULL.
> In the error path of this inode creation, mi->mrec is later
> dereferenced in ni_write_inode.
>
> Add a NULL check to prevent NULL dereference.
>
> Link: https://syzkaller.appspot.com/bug?extid=f45957555ed4a808cc7a
> Reported-and-tested-by: syzbot+f45957555ed4a808cc7a@syzkaller.appspotmail.com
> Signed-off-by: Abdun Nihaal <abdun.nihaal@gmail.com>
> ---
> fs/ntfs3/frecord.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index 70a80f9412f7..e55bbd209ef8 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -3243,6 +3243,9 @@ int ni_write_inode(struct inode *inode, int sync, const char *hint)
> return 0;
> }
>
> + if (!ni->mi.mrec)
> + goto out;
> +
> if (is_rec_inuse(ni->mi.mrec) &&
> !(sbi->flags & NTFS_FLAGS_LOG_REPLAYING) && inode->i_nlink) {
> bool modified = false;
Thank you for your work, applied!
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-12-30 7:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-30 7:02 [PATCH] fs/ntfs3: Fix NULL dereference in ni_write_inode Abdun Nihaal
2022-10-30 7:02 ` Abdun Nihaal
2022-12-30 7:22 ` Konstantin Komarov
2022-12-30 7:22 ` Konstantin Komarov via Linux-kernel-mentees
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.