From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D96C914A81 for ; Mon, 23 Oct 2023 11:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="KvtIflc6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 540A5C433C7; Mon, 23 Oct 2023 11:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1698059094; bh=tNa5ulcuJCNCWDgnf09L7f21PHbRIdVStDxa4So9FC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KvtIflc6o5EBfkDoi0CzkF5qx0UsCPbOq4okpOBETibBbmogKtH+eyybDy1ZLcSS1 umhl8A1/8bmuV1PiaFektTMa4P9Xx+4W6g9Kinubv8OqYIUTCEblZnw0hDNE2Hd8Xo GKnBQh0o/ElxymV1YCT0usQzi8emtfOQwooU0mf0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+e94d98936a0ed08bde43@syzkaller.appspotmail.com, Konstantin Komarov Subject: [PATCH 6.5 034/241] fs/ntfs3: fix deadlock in mark_as_free_ex Date: Mon, 23 Oct 2023 12:53:40 +0200 Message-ID: <20231023104834.756543232@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231023104833.832874523@linuxfoundation.org> References: <20231023104833.832874523@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Konstantin Komarov commit bfbe5b31caa74ab97f1784fe9ade5f45e0d3de91 upstream. Reported-by: syzbot+e94d98936a0ed08bde43@syzkaller.appspotmail.com Signed-off-by: Konstantin Komarov Signed-off-by: Greg Kroah-Hartman --- fs/ntfs3/fsntfs.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/fs/ntfs3/fsntfs.c +++ b/fs/ntfs3/fsntfs.c @@ -2461,10 +2461,12 @@ void mark_as_free_ex(struct ntfs_sb_info { CLST end, i, zone_len, zlen; struct wnd_bitmap *wnd = &sbi->used.bitmap; + bool dirty = false; down_write_nested(&wnd->rw_lock, BITMAP_MUTEX_CLUSTERS); if (!wnd_is_used(wnd, lcn, len)) { - ntfs_set_state(sbi, NTFS_DIRTY_ERROR); + /* mark volume as dirty out of wnd->rw_lock */ + dirty = true; end = lcn + len; len = 0; @@ -2518,6 +2520,8 @@ void mark_as_free_ex(struct ntfs_sb_info out: up_write(&wnd->rw_lock); + if (dirty) + ntfs_set_state(sbi, NTFS_DIRTY_ERROR); } /*