mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tuo Li <islituo@gmail.com>
To: anton@tuxera.com, linkinjeon@kernel.org
Cc: linux-ntfs-dev@lists.sourceforge.net,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	baijiaju1990@outlook.com
Subject: [BUG] ntfs: possible data races in ntfs_clear_extent_inode()
Date: Tue, 13 Jun 2023 12:34:30 +0800	[thread overview]
Message-ID: <0c336a41-54fb-2904-42e2-1d9ee3950b21@gmail.com> (raw)

Hello,

Our static analysis tool finds some possible data races in the NTFS file
system in Linux 6.4.0-rc6.

In most calling contexts, the variable ni->ext.base_ntfs_ino is accessed
with holding the lock ni->extent_lock. Here is an example:

   ntfs_extent_mft_record_free() --> Line 2773 in fs/ntfs/mtf.c
     mutex_lock(&ni->extent_lock); --> Line 2786 in fs/ntfs/mtf.c (Lock 
ni->extent_lock)
     base_ni = ni->ext.base_ntfs_ino; --> Line 2787 in fs/ntfs/mft.c 
(Access ni->ext.base_ntfs_ino)

However, in the following calling contexts:

   ntfs_evict_big_inode() --> Line 2247 in fs/ntfs/inode.c
      ntfs_clear_extent_inode() --> Line 2274 in fs/ntfs/inode.c
         if (!is_bad_inode(VFS_I(ni->ext.base_ntfs_ino))) --> Line 2224 
in fs/ntfs/inode.c (Access ni->ext.base_ntfs_ino)

   ntfs_evict_big_inode() --> Line 2247 in fs/ntfs/inode.c
     ni->ext.base_ntfs_ino = NULL; --> Line 2285 in fs/ntfs/inode.c 
(Access ni->ext.base_ntfs_ino)

the variable ni->ext.base_ntfs_ino is accessed without holding the lock
ni->extent_lock, and thus data races can occur.

I am not quite sure whether these possible data races are real and how 
to fix them if they are real.
Any feedback would be appreciated, thanks!

Reported-by: BassCheck <bass@buaa.edu.cn>

Best wishes,
Tuo Li

             reply	other threads:[~2023-06-13  4:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-13  4:34 Tuo Li [this message]
2023-06-13  8:57 ` Anton Altaparmakov

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=0c336a41-54fb-2904-42e2-1d9ee3950b21@gmail.com \
    --to=islituo@gmail.com \
    --cc=anton@tuxera.com \
    --cc=baijiaju1990@outlook.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-ntfs-dev@lists.sourceforge.net \
    /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

all inboxes | Powered by JetHome®