public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: syzbot <syzbot+8df514c431bd240c5644@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Re: [syzbot] Re: [syzbot] [ntfs3?] possible deadlock in mark_as_free_ex (2)
Date: Fri, 13 Dec 2024 00:24:06 -0800	[thread overview]
Message-ID: <675bef26.050a0220.1a2d0d.0004.GAE@google.com> (raw)
In-Reply-To: <672dbff0.050a0220.69327.0002.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: Re: [syzbot] [ntfs3?] possible deadlock in mark_as_free_ex (2)
Author: lizhi.xu@windriver.com

reset the lock order for openat

#syz test

diff --git a/fs/ntfs3/run.c b/fs/ntfs3/run.c
index 6e86d6619..38ebd65f0 100644
--- a/fs/ntfs3/run.c
+++ b/fs/ntfs3/run.c
@@ -1096,9 +1096,17 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
 
 		/* Looks like volume is corrupted. */
 		ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
-
-		if (!down_write_trylock(&wnd->rw_lock))
+		struct rw_semaphore *lock =
+			is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
+					  NULL;
+		if (zone && lock)
+			down_read(lock);
+
+		if (!down_write_trylock(&wnd->rw_lock)) {
+			if (zone && lock)
+				up_read(lock);
 			continue;
+		}
 
 		if (zone) {
 			/*
@@ -1112,16 +1120,11 @@ int run_unpack_ex(struct runs_tree *run, struct ntfs_sb_info *sbi, CLST ino,
 		err = wnd_set_used_safe(wnd, lcn, len, &done);
 		if (zone) {
 			/* Restore zone. Lock mft run. */
-			struct rw_semaphore *lock =
-				is_mounted(sbi) ? &sbi->mft.ni->file.run_lock :
-						  NULL;
-			if (lock)
-				down_read(lock);
 			ntfs_refresh_zone(sbi);
-			if (lock)
-				up_read(lock);
 		}
 		up_write(&wnd->rw_lock);
+		if (zone && lock)
+			up_read(lock);
 		if (err)
 			return err;
 	}

  parent reply	other threads:[~2024-12-13  8:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08  7:38 [syzbot] [ntfs3?] possible deadlock in mark_as_free_ex (2) syzbot
2024-11-29  1:43 ` syzbot
2024-12-12  8:35 ` syzbot
2024-12-13  9:05   ` [PATCH] ntfs3: fix deadlock in mark_as_free_ex Lizhi Xu
2024-12-13  6:43 ` [syzbot] [ntfs3?] possible deadlock in mark_as_free_ex (2) syzbot
2024-12-13  8:24 ` syzbot [this message]
2026-01-17 12:45 ` syzbot

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=675bef26.050a0220.1a2d0d.0004.GAE@google.com \
    --to=syzbot+8df514c431bd240c5644@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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