syzbot


possible deadlock in process_measurement

Status: closed as invalid on 2019/07/15 16:35
Subsystems: lsm integrity
[Documentation on labels]
Reported-by: syzbot+5ab61747675a87ea359d@syzkaller.appspotmail.com
First crash: 2008d, last: 1773d
Discussions (2)
Title Replies (including bot) Last reply
possible deadlock in process_measurement 5 (7) 2019/07/15 16:34
Reminder: 2 open syzbot bugs in "security/integrity" subsystem 1 (1) 2019/07/09 19:15
Similar bugs (5)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream possible deadlock in process_measurement (2) integrity lsm C done done 56 1226d 1593d 15/26 fixed on 2021/01/06 01:14
upstream possible deadlock in process_measurement (3) overlayfs C error 223 162d 1068d 0/26 closed as dup on 2023/06/06 09:59
linux-4.19 possible deadlock in process_measurement 156 577d 1549d 0/1 auto-obsoleted due to no activity on 2023/01/11 22:20
linux-6.1 possible deadlock in process_measurement origin:lts-only C unreliable 8 146d 224d 0/3 upstream: reported C repro on 2023/09/02 00:54
linux-5.15 possible deadlock in process_measurement origin:lts-only C done 4 146d 221d 0/3 upstream: reported C repro on 2023/09/04 07:52

Sample crash report:
get_swap_device: Bad swap file entry 6000000000000001
get_swap_device: Bad swap file entry 6400000000000001
get_swap_device: Bad swap file entry 6800000000000001
get_swap_device: Bad swap file entry 6c00000000000001
get_swap_device: Bad swap file entry 7000000000000001
get_swap_device: Bad swap file entry 7400000000000001
======================================================
WARNING: possible circular locking dependency detected
5.2.0-rc2-next-20190531 #4 Not tainted
------------------------------------------------------
syz-executor395/17373 is trying to acquire lock:
000000003d1a4a53 (&sb->s_type->i_mutex_key#10){+.+.}, at: inode_lock include/linux/fs.h:778 [inline]
000000003d1a4a53 (&sb->s_type->i_mutex_key#10){+.+.}, at: process_measurement+0x15ae/0x15e0 security/integrity/ima/ima_main.c:228

but task is already holding lock:
00000000e0714fc5 (&mm->mmap_sem#2){++++}, at: do_mprotect_pkey+0x1f6/0xa30 mm/mprotect.c:485

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (&mm->mmap_sem#2){++++}:
       down_read+0x3f/0x1e0 kernel/locking/rwsem.c:24
       get_user_pages_unlocked+0xfc/0x4a0 mm/gup.c:1174
       __gup_longterm_unlocked mm/gup.c:2193 [inline]
       get_user_pages_fast+0x43f/0x530 mm/gup.c:2245
       iov_iter_get_pages+0x2c2/0xf80 lib/iov_iter.c:1287
       dio_refill_pages fs/direct-io.c:171 [inline]
       dio_get_page fs/direct-io.c:215 [inline]
       do_direct_IO fs/direct-io.c:983 [inline]
       do_blockdev_direct_IO+0x3f7b/0x8e00 fs/direct-io.c:1336
       __blockdev_direct_IO+0xa1/0xca fs/direct-io.c:1422
       ext4_direct_IO_write fs/ext4/inode.c:3782 [inline]
       ext4_direct_IO+0xaa7/0x1bb0 fs/ext4/inode.c:3909
       generic_file_direct_write+0x20a/0x4a0 mm/filemap.c:3110
       __generic_file_write_iter+0x2ee/0x630 mm/filemap.c:3293
       ext4_file_write_iter+0x332/0x1070 fs/ext4/file.c:266
       call_write_iter include/linux/fs.h:1870 [inline]
       new_sync_write+0x4d3/0x770 fs/read_write.c:483
       __vfs_write+0xe1/0x110 fs/read_write.c:496
       vfs_write+0x268/0x5d0 fs/read_write.c:558
       ksys_write+0x14f/0x290 fs/read_write.c:611
       __do_sys_write fs/read_write.c:623 [inline]
       __se_sys_write fs/read_write.c:620 [inline]
       __x64_sys_write+0x73/0xb0 fs/read_write.c:620
       do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&sb->s_type->i_mutex_key#10){+.+.}:
       lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4300
       down_write+0x38/0xa0 kernel/locking/rwsem.c:66
       inode_lock include/linux/fs.h:778 [inline]
       process_measurement+0x15ae/0x15e0 security/integrity/ima/ima_main.c:228
       ima_file_mmap+0x11a/0x130 security/integrity/ima/ima_main.c:370
       security_file_mprotect+0xd5/0x100 security/security.c:1430
       do_mprotect_pkey+0x537/0xa30 mm/mprotect.c:550
       __do_sys_pkey_mprotect mm/mprotect.c:590 [inline]
       __se_sys_pkey_mprotect mm/mprotect.c:587 [inline]
       __x64_sys_pkey_mprotect+0x97/0xf0 mm/mprotect.c:587
       do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&mm->mmap_sem#2);
                               lock(&sb->s_type->i_mutex_key#10);
                               lock(&mm->mmap_sem#2);
  lock(&sb->s_type->i_mutex_key#10);

 *** DEADLOCK ***

1 lock held by syz-executor395/17373:
 #0: 00000000e0714fc5 (&mm->mmap_sem#2){++++}, at: do_mprotect_pkey+0x1f6/0xa30 mm/mprotect.c:485

stack backtrace:
CPU: 1 PID: 17373 Comm: syz-executor395 Not tainted 5.2.0-rc2-next-20190531 #4
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 print_circular_bug.cold+0x1cc/0x28f kernel/locking/lockdep.c:1566
 check_prev_add kernel/locking/lockdep.c:2311 [inline]
 check_prevs_add kernel/locking/lockdep.c:2419 [inline]
 validate_chain kernel/locking/lockdep.c:2801 [inline]
 __lock_acquire+0x3755/0x5490 kernel/locking/lockdep.c:3790
 lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:4300
 down_write+0x38/0xa0 kernel/locking/rwsem.c:66
 inode_lock include/linux/fs.h:778 [inline]
 process_measurement+0x15ae/0x15e0 security/integrity/ima/ima_main.c:228
 ima_file_mmap+0x11a/0x130 security/integrity/ima/ima_main.c:370
 security_file_mprotect+0xd5/0x100 security/security.c:1430
 do_mprotect_pkey+0x537/0xa30 mm/mprotect.c:550
 __do_sys_pkey_mprotect mm/mprotect.c:590 [inline]
 __se_sys_pkey_mprotect mm/mprotect.c:587 [inline]
 __x64_sys_pkey_mprotect+0x97/0xf0 mm/mprotect.c:587
 do_syscall_64+0xfd/0x680 arch/x86/entry/common.c:301
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x440279
Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 fb 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffeec2f48d8 EFLAGS: 00000246 ORIG_RAX: 0000000000000149
RAX: ffffffffffffffda RBX: 00000000004002c8 RCX: 0000000000440279
RDX: 000000000000000

Crashes (51):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2019/06/03 16:34 linux-next 3c09c1950c84 63bf051f .config console log report syz C ci-upstream-linux-next-kasan-gce-root
2019/01/29 21:34 upstream 4aa9fc2a435a aa432daf .config console log report ci-upstream-kasan-gce-root
2019/01/13 22:11 upstream e1706720408e c3f3344c .config console log report ci-upstream-kasan-gce-root
2019/01/02 12:46 upstream 8e143b90e4d4 f0491811 .config console log report ci-upstream-kasan-gce-root
2019/01/01 13:05 upstream e1ef035d272e 3d85f48c .config console log report ci-upstream-kasan-gce-root
2018/12/30 13:11 upstream 195303136f19 9942de5f .config console log report ci-upstream-kasan-gce-root
2018/12/30 01:46 upstream 195303136f19 35e3f847 .config console log report ci-upstream-kasan-gce-root
2018/12/25 17:55 upstream 8fe28cb58bcb 8a41a0ad .config console log report ci-upstream-kasan-gce-root
2018/12/23 20:56 upstream 3c730b1041ae e3bd7ab8 .config console log report ci-upstream-kasan-gce-root
2018/12/16 21:56 upstream 6531e115b7ab def91db3 .config console log report ci-upstream-kasan-gce-root
2018/12/13 10:40 upstream f5d582777bcb f3d9d594 .config console log report ci-upstream-kasan-gce-root
2018/12/11 12:34 upstream f5d582777bcb 7795ae03 .config console log report ci-upstream-kasan-gce-root
2018/12/10 00:20 upstream 0844895a2e51 96cc4c50 .config console log report ci-upstream-kasan-gce-root
2018/12/08 11:36 upstream 5f179793f0a7 60562a1d .config console log report ci-upstream-kasan-gce-root
2018/10/14 09:10 upstream 3a27203102eb caf12900 .config console log report ci-upstream-kasan-gce-selinux-root
2018/10/13 18:19 upstream 7ec21823634d caf12900 .config console log report ci-upstream-kasan-gce-root
2018/10/13 18:05 upstream 7ec21823634d caf12900 .config console log report ci-upstream-kasan-gce-selinux-root
2018/10/13 04:39 upstream bab5c80b2110 caf12900 .config console log report ci-upstream-kasan-gce-selinux-root
2019/06/05 05:09 linux-next 56b697c6c13b bfb4a51e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/05 02:21 linux-next 56b697c6c13b bfb4a51e .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/05 01:15 linux-next 56b697c6c13b e41a20c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 18:16 linux-next 56b697c6c13b e41a20c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 15:51 linux-next 56b697c6c13b e41a20c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 12:26 linux-next 56b697c6c13b e41a20c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 11:54 linux-next 56b697c6c13b e41a20c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 11:38 linux-next 56b697c6c13b e41a20c5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 07:42 linux-next 56b697c6c13b ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 07:41 linux-next 56b697c6c13b ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 07:40 linux-next 56b697c6c13b ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 07:40 linux-next 56b697c6c13b ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 07:16 linux-next 56b697c6c13b ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 06:57 linux-next 56b697c6c13b ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/04 00:31 linux-next 3c09c1950c84 ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/03 23:55 linux-next 3c09c1950c84 ce07a7ae .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/03 19:09 linux-next 3c09c1950c84 63bf051f .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/03 17:19 linux-next 3c09c1950c84 63bf051f .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/03 14:20 linux-next 3c09c1950c84 63bf051f .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/03 12:48 linux-next 3c09c1950c84 63bf051f .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/03 12:33 linux-next 3c09c1950c84 63bf051f .config console log report ci-upstream-linux-next-kasan-gce-root
2019/06/01 00:13 linux-next 3c09c1950c84 53c81ea5 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/31 15:23 linux-next 3c09c1950c84 142ce681 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/31 13:13 linux-next 3c09c1950c84 142ce681 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/31 08:44 linux-next 3c09c1950c84 d9aaf3c2 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/05/31 07:33 linux-next 3c09c1950c84 d9aaf3c2 .config console log report ci-upstream-linux-next-kasan-gce-root
2019/02/08 06:49 linux-next 1bd831d68d55 aa4feb03 .config console log report ci-upstream-linux-next-kasan-gce-root
2018/12/06 23:24 linux-next 442b8cea2477 dcf836b1 .config console log report ci-upstream-linux-next-kasan-gce-root
* Struck through repros no longer work on HEAD.