Chao Yu
312d272dc4
hfsplus: fix to avoid false alarm of circular locking
...
[ Upstream commit be4edd1642ee205ed7bbf66edc0453b1be1fb8d7 ]
Syzbot report potential ABBA deadlock as below:
loop0: detected capacity change from 0 to 1024
======================================================
WARNING: possible circular locking dependency detected
6.9.0-syzkaller-10323-g8f6a15f095a6 #0 Not tainted
------------------------------------------------------
syz-executor171/5344 is trying to acquire lock:
ffff88807cb980b0 (&tree->tree_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x811/0xb50 fs/hfsplus/extents.c:595
but task is already holding lock:
ffff88807a930108 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}, at: hfsplus_file_truncate+0x2da/0xb50 fs/hfsplus/extents.c:576
which lock already depends on the new lock.
the existing dependency chain (in reverse order) is:
-> #1 (&HFSPLUS_I(inode)->extents_lock){+.+.}-{3:3}:
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
__mutex_lock_common kernel/locking/mutex.c:608 [inline]
__mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
hfsplus_file_extend+0x21b/0x1b70 fs/hfsplus/extents.c:457
hfsplus_bmap_reserve+0x105/0x4e0 fs/hfsplus/btree.c:358
hfsplus_rename_cat+0x1d0/0x1050 fs/hfsplus/catalog.c:456
hfsplus_rename+0x12e/0x1c0 fs/hfsplus/dir.c:552
vfs_rename+0xbdb/0xf00 fs/namei.c:4887
do_renameat2+0xd94/0x13f0 fs/namei.c:5044
__do_sys_rename fs/namei.c:5091 [inline]
__se_sys_rename fs/namei.c:5089 [inline]
__x64_sys_rename+0x86/0xa0 fs/namei.c:5089
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
-> #0 (&tree->tree_lock){+.+.}-{3:3}:
check_prev_add kernel/locking/lockdep.c:3134 [inline]
check_prevs_add kernel/locking/lockdep.c:3253 [inline]
validate_chain+0x18cb/0x58e0 kernel/locking/lockdep.c:3869
__lock_acquire+0x1346/0x1fd0 kernel/locking/lockdep.c:5137
lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754
__mutex_lock_common kernel/locking/mutex.c:608 [inline]
__mutex_lock+0x136/0xd70 kernel/locking/mutex.c:752
hfsplus_file_truncate+0x811/0xb50 fs/hfsplus/extents.c:595
hfsplus_setattr+0x1ce/0x280 fs/hfsplus/inode.c:265
notify_change+0xb9d/0xe70 fs/attr.c:497
do_truncate+0x220/0x310 fs/open.c:65
handle_truncate fs/namei.c:3308 [inline]
do_open fs/namei.c:3654 [inline]
path_openat+0x2a3d/0x3280 fs/namei.c:3807
do_filp_open+0x235/0x490 fs/namei.c:3834
do_sys_openat2+0x13e/0x1d0 fs/open.c:1406
do_sys_open fs/open.c:1421 [inline]
__do_sys_creat fs/open.c:1497 [inline]
__se_sys_creat fs/open.c:1491 [inline]
__x64_sys_creat+0x123/0x170 fs/open.c:1491
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
other info that might help us debug this:
Possible unsafe locking scenario:
CPU0 CPU1
---- ----
lock(&HFSPLUS_I(inode)->extents_lock);
lock(&tree->tree_lock);
lock(&HFSPLUS_I(inode)->extents_lock);
lock(&tree->tree_lock);
This is a false alarm as tree_lock mutex are different, one is
from sbi->cat_tree, and another is from sbi->ext_tree:
Thread A Thread B
- hfsplus_rename
- hfsplus_rename_cat
- hfs_find_init
- mutext_lock(cat_tree->tree_lock)
- hfsplus_setattr
- hfsplus_file_truncate
- mutex_lock(hip->extents_lock)
- hfs_find_init
- mutext_lock(ext_tree->tree_lock)
- hfs_bmap_reserve
- hfsplus_file_extend
- mutex_lock(hip->extents_lock)
So, let's call mutex_lock_nested for tree_lock mutex lock, and pass
correct lock class for it.
Fixes: 31651c607151 ("hfsplus: avoid deadlock on file truncation")
Reported-by: syzbot+6030b3b1b9bf70e538c4@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-fsdevel/000000000000e37a4005ef129563@google.com
Cc: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Link: https://lore.kernel.org/r/20240607142304.455441-1-chao@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:59:11 +02:00
..
2024-05-29 09:25:15 -07:00
2024-03-12 20:32:19 -07:00
2024-02-26 11:36:28 +01:00
2024-07-02 21:23:00 +02:00
2024-01-11 20:11:35 -08:00
2024-07-11 20:10:55 -04:00
2024-03-12 20:32:19 -07:00
2024-03-12 20:32:19 -07:00
2024-07-12 12:08:42 -07:00
2024-07-05 18:40:40 +02:00
2024-05-25 14:23:58 -07:00
2024-03-12 20:32:19 -07:00
2024-05-03 02:36:51 -04:00
2024-05-19 09:21:03 -07:00
2024-05-28 14:32:42 +02:00
2023-12-28 04:57:57 -08:00
2024-04-23 16:08:55 -05:00
2024-05-13 14:14:05 -07:00
2024-04-13 10:33:02 +02:00
2024-02-27 11:21:33 +01:00
2024-06-30 10:54:28 +08:00
2024-04-25 21:59:59 +09:00
2024-01-23 10:58:56 -05:00
2024-05-03 11:50:28 +02:00
2024-07-24 15:54:05 +02:00
2024-05-20 13:23:43 -07:00
2024-04-25 21:07:02 -07:00
2024-03-26 09:04:53 +01:00
2024-05-23 12:04:36 -07:00
2024-05-21 09:51:42 -07:00
2023-12-29 11:58:34 -08:00
2024-08-03 08:59:11 +02:00
2023-12-21 12:51:00 -05:00
2024-03-12 20:32:19 -07:00
2024-05-19 09:21:03 -07:00
2024-06-05 17:27:03 +02:00
2024-05-09 18:09:57 +02:00
2024-05-21 09:51:42 -07:00
2024-05-25 13:23:42 -07:00
2024-07-27 11:40:32 +02:00
2024-05-04 19:02:39 +02:00
2024-05-06 09:07:20 -04:00
2024-07-10 07:15:36 +02:00
2024-07-11 09:03:28 -07:00
2024-06-24 20:52:11 -07:00
2024-06-28 09:32:33 -07:00
2024-07-03 22:40:38 -07:00
2024-05-20 12:43:58 -07:00
2024-07-27 11:40:32 +02:00
2024-07-27 11:40:32 +02:00
2024-03-26 09:04:54 +01:00
2024-05-14 17:44:14 -07:00
2024-06-14 10:30:40 +02:00
2024-06-24 20:52:09 -07:00
2024-03-09 12:33:22 -08:00
2024-03-12 20:32:19 -07:00
2024-03-26 09:04:53 +01:00
2024-04-12 14:52:29 +02:00
2024-04-25 20:56:25 -07:00
2024-05-21 08:34:51 -07:00
2024-03-27 13:17:15 +01:00
2024-07-24 15:54:06 +02:00
2024-05-19 14:02:03 -07:00
2024-04-23 13:27:43 +02:00
2024-02-27 11:21:31 +01:00
2024-05-23 09:31:50 -04:00
2024-03-21 15:09:29 -07:00
2024-04-23 15:37:02 +02:00
2024-03-12 20:32:19 -07:00
2024-05-10 04:34:52 +09:00
2024-04-03 16:06:39 +02:00
2024-05-03 08:30:58 -07:00
2024-06-26 14:29:25 +05:30
2024-04-10 07:23:47 +09:00
2024-05-21 13:11:44 -07:00
2024-04-26 10:33:05 +02:00
2024-03-12 20:03:34 -07:00
2024-05-02 20:35:57 +02:00
2024-04-24 15:55:28 -07:00
2024-05-19 14:02:03 -07:00
2023-10-30 19:28:19 -10:00
2024-05-21 09:51:42 -07:00
2023-11-02 20:53:31 -10:00
2024-05-23 12:04:36 -07:00
2024-04-25 20:56:20 -07:00
2024-07-11 09:03:28 -07:00
2024-04-11 10:21:24 +02:00
2024-02-08 10:12:26 +01:00
2024-05-05 14:00:48 -07:00
2024-05-19 09:21:03 -07:00
2024-05-10 08:26:31 +02:00
2024-04-05 15:53:47 +02:00
2024-03-12 20:03:34 -07:00
2024-05-30 09:11:47 +02:00
2024-02-02 13:11:50 +01:00
2024-04-05 15:53:45 +02:00
2024-03-15 09:00:09 -07:00
2024-05-02 20:35:57 +02:00
2024-05-13 06:58:35 +02:00
2024-03-14 17:43:30 -07:00
2024-04-17 13:49:44 +02:00
2024-07-27 11:40:36 +02:00
2024-03-11 10:21:06 -07:00
2024-02-27 11:21:31 +01:00
2024-02-08 10:12:37 +01:00
2023-11-18 14:56:16 +01:00
2024-02-06 14:31:05 +01:00
2024-06-18 16:26:09 +02:00
2024-02-07 21:16:29 +01:00
2024-03-13 12:53:53 -07:00
2024-07-01 09:22:08 -07:00
2024-05-21 08:08:00 -07:00
2024-02-02 13:11:49 +01:00
2023-11-18 14:56:16 +01:00
2024-03-12 20:03:34 -07:00
2023-11-18 14:56:16 +01:00
2024-05-21 13:11:44 -07:00
2023-12-12 16:20:02 +01:00
2024-04-15 14:54:13 -07:00
2024-02-20 09:23:52 +01:00
2024-05-02 16:28:20 +02:00
2024-05-24 13:34:07 +02:00
2024-04-15 16:03:25 -04:00
2024-03-26 09:01:18 +01:00
2024-06-18 16:20:47 +02:00
2023-12-28 04:57:57 -08:00
2024-04-10 16:23:02 -06:00
2024-07-03 22:40:36 -07:00
2024-02-15 23:43:47 -05:00