linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: <ntfs3@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fs: ntfs3: Fix a possible null-pointer dereference in ni_clear()
Date: Mon, 8 May 2023 16:47:21 +0400	[thread overview]
Message-ID: <93d571a1-ca88-4824-01db-3b16973627e0@paragon-software.com> (raw)
In-Reply-To: <20230111085943.1127-1-baijiaju1990@gmail.com>

In a previous commit c1006bd13146, ni->mi.mrec in ni_write_inode()
> could be NULL, and thus a NULL check is added for this variable.
>
> However, in the same call stack, ni->mi.mrec can be also dereferenced
> in ni_clear():
>
> ntfs_evict_inode(inode)
>    ni_write_inode(inode, ...)
>      ni = ntfs_i(inode);
>      is_rec_inuse(ni->mi.mrec) -> Add a NULL check by previous commit
>    ni_clear(ntfs_i(inode))
>      is_rec_inuse(ni->mi.mrec) -> No check
>
> Thus, a possible null-pointer dereference may exist in ni_clear().
> To fix it, a NULL check is added in this function.
>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> ---
>   fs/ntfs3/frecord.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c
> index f1df52dfab74..046ec4179d75 100644
> --- a/fs/ntfs3/frecord.c
> +++ b/fs/ntfs3/frecord.c
> @@ -102,7 +102,7 @@ void ni_clear(struct ntfs_inode *ni)
>   {
>   	struct rb_node *node;
>   
> -	if (!ni->vfs_inode.i_nlink && is_rec_inuse(ni->mi.mrec))
> +	if (!ni->vfs_inode.i_nlink && ni->mi.mrec && is_rec_inuse(ni->mi.mrec))
>   		ni_delete_all(ni);
>   
>   	al_destroy(ni);

I apologize for the delayed response.

Thank you for your work, applied!


      reply	other threads:[~2023-05-08 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  8:59 [PATCH] fs: ntfs3: Fix a possible null-pointer dereference in ni_clear() Jia-Ju Bai
2023-05-08 12:47 ` Konstantin Komarov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=93d571a1-ca88-4824-01db-3b16973627e0@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=baijiaju1990@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).