From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 ACD54353EF7; Sat, 12 Sep 2026 10:10:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789207840; cv=none; b=SuDT2nPduEB7tNQwcdZrNZrDn5BoPB47DcOWV6n2PJWT37cmzcQDAs43kc1mrojqr6FKpzbtWE3Ls5QDiaVlwNAssvBCBJpCJDEaA9m81fNUFrZo9pe+03JPe7fI8/gBjsXLxAlhNnpEYVJ59T0jgdQskb2Jzp78lO1dthfmGG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789207840; c=relaxed/simple; bh=5rooJEnVBYrQBtJ3+xce7NbnkKJ3BcuuACZ5tGfQeKQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=akcBPhzoBFzKbY97H9Kj5SlI/jDQnpOvWuL8HwSNqFjZKn8YwXLRZ6NIpYyURWVbE4CK3VHyo8BLGuydGtTZLd/IkwRmozgR2dI0xbCl1BimXgYYfxaVPt5H7QnWzqvbXZGa8wkuN3CUxfwDxTqMfIUJj0q9nLXAxZWrqO8nCLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=E1H9UzDD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="E1H9UzDD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6AF001F000FF; Sat, 12 Sep 2026 10:10:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789207839; bh=V/j0mGnp+avHkA3JWa0Tp25abzpv0wSd8Nrhi/uiBok=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=E1H9UzDDRQVlsMTBSojWZ2lu4bbJ3uix9h0sMrfWAcdoGfKYGyXHtn889VGfvu0hb ZQLUHe1afZhiJ4K9BnynPH7dFZ82JIhb06zqI2lK7jAOM9hT7CF9FCftNdzHid2YgQ 6OqD6rW6XKzBw98GDRvSNar7HvfYqFYJd+JMMe2k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+212e8f62790f8e0bc63b@syzkaller.appspotmail.com, Yun Zhou , Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 6.18 0494/1518] ext4: fix circular lock dependency in ext4_ext_migrate Date: Sat, 12 Sep 2026 08:44:23 +0200 Message-ID: <20260912065634.620818523@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065623.398859879@linuxfoundation.org> References: <20260912065623.398859879@linuxfoundation.org> User-Agent: quilt/0.69 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yun Zhou [ Upstream commit a897682793eba5de51ee6f3152760374afa629cf ] Move iput(tmp_inode) after ext4_writepages_up_write() to avoid a circular lock dependency between s_writepages_rwsem and sb_internal (freeze protection). The deadlock scenario: CPU0 (EXT4_IOC_MIGRATE) CPU1 (orphan cleanup during mount) ---- ---- ext4_ext_migrate() ext4_writepages_down_write() s_writepages_rwsem (write) ext4_evict_inode() sb_start_intwrite() [sb_internal] ... ext4_writepages() s_writepages_rwsem (read) [BLOCKED] iput(tmp_inode) ext4_evict_inode() sb_start_intwrite() [BLOCKED] The tmp_inode is a temporary inode with nlink=0 created solely for building the extent tree. Its eviction does not require s_writepages_rwsem protection, so deferring iput() until after releasing the rwsem is safe. Reported-by: syzbot+212e8f62790f8e0bc63b@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=212e8f62790f8e0bc63b Fixes: cb85f4d23f79 ("ext4: fix race between writepages and enabling EXT4_EXTENTS_FL") Signed-off-by: Yun Zhou Reviewed-by: Jan Kara Link: https://patch.msgid.link/20260612005330.1930804-1-yun.zhou@windriver.com Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin --- fs/ext4/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c index 1b0dfd963d3f0..84e3b703ab463 100644 --- a/fs/ext4/migrate.c +++ b/fs/ext4/migrate.c @@ -458,6 +458,7 @@ int ext4_ext_migrate(struct inode *inode) if (IS_ERR(tmp_inode)) { retval = PTR_ERR(tmp_inode); ext4_journal_stop(handle); + tmp_inode = NULL; goto out_unlock; } /* @@ -585,9 +586,9 @@ int ext4_ext_migrate(struct inode *inode) ext4_journal_stop(handle); out_tmp_inode: unlock_new_inode(tmp_inode); - iput(tmp_inode); out_unlock: ext4_writepages_up_write(inode->i_sb, alloc_ctx); + iput(tmp_inode); return retval; } -- 2.53.0