public inbox for ntfs3@lists.linux.dev
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>,
	syzbot+8c652f14a0fde76ff11d@syzkaller.appspotmail.com,
	Sasha Levin <sashal@kernel.org>,
	ntfs3@lists.linux.dev
Subject: [PATCH AUTOSEL 6.6 09/17] fs/ntfs3: Additional check in ntfs_file_release
Date: Sun, 13 Oct 2024 23:57:59 -0400	[thread overview]
Message-ID: <20241014035815.2247153-9-sashal@kernel.org> (raw)
In-Reply-To: <20241014035815.2247153-1-sashal@kernel.org>

From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>

[ Upstream commit 031d6f608290c847ba6378322d0986d08d1a645a ]

Reported-by: syzbot+8c652f14a0fde76ff11d@syzkaller.appspotmail.com
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/ntfs3/file.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index cd69cbd0aaae7..d05c433a55f35 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -1171,7 +1171,14 @@ static int ntfs_file_release(struct inode *inode, struct file *file)
 	/* If we are last writer on the inode, drop the block reservation. */
 	if (sbi->options->prealloc &&
 	    ((file->f_mode & FMODE_WRITE) &&
-	     atomic_read(&inode->i_writecount) == 1)) {
+	     atomic_read(&inode->i_writecount) == 1)
+	   /*
+	    * The only file when inode->i_fop = &ntfs_file_operations and
+	    * init_rwsem(&ni->file.run_lock) is not called explicitly is MFT.
+	    *
+	    * Add additional check here.
+	    */
+	    && inode->i_ino != MFT_REC_MFT) {
 		ni_lock(ni);
 		down_write(&ni->file.run_lock);
 
-- 
2.43.0


      parent reply	other threads:[~2024-10-14  3:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-14  3:57 [PATCH AUTOSEL 6.6 01/17] ntfs3: Add bounds checking to mi_enum_attr() Sasha Levin
2024-10-14  3:57 ` [PATCH AUTOSEL 6.6 02/17] fs/ntfs3: Check if more than chunk-size bytes are written Sasha Levin
2024-10-14  3:57 ` [PATCH AUTOSEL 6.6 03/17] fs/ntfs3: Fix warning possible deadlock in ntfs_set_state Sasha Levin
2024-10-14  3:57 ` [PATCH AUTOSEL 6.6 04/17] fs/ntfs3: Stale inode instead of bad Sasha Levin
2024-10-14  3:57 ` [PATCH AUTOSEL 6.6 05/17] fs/ntfs3: Add rough attr alloc_size check Sasha Levin
2024-10-14  3:57 ` [PATCH AUTOSEL 6.6 06/17] fs/ntfs3: Fix possible deadlock in mi_read Sasha Levin
2024-10-14  3:57 ` [PATCH AUTOSEL 6.6 07/17] fs/ntfs3: Additional check in ni_clear() Sasha Levin
2024-10-14  3:57 ` [PATCH AUTOSEL 6.6 08/17] fs/ntfs3: Fix general protection fault in run_is_mapped_full Sasha Levin
2024-10-14  3:57 ` Sasha Levin [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=20241014035815.2247153-9-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=almaz.alexandrovich@paragon-software.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+8c652f14a0fde76ff11d@syzkaller.appspotmail.com \
    /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