[IMA] Re: possible deadlock in get_user_pages_unlocked (2)

From: Eric Biggers
Date: Mon Jun 10 2019 - 15:10:51 EST


On Tue, Jun 04, 2019 at 06:16:00PM -0700, syzbot wrote:
> syzbot has bisected this bug to:
>
> commit 69d61f577d147b396be0991b2ac6f65057f7d445
> Author: Mimi Zohar <zohar@xxxxxxxxxxxxx>
> Date: Wed Apr 3 21:47:46 2019 +0000
>
> ima: verify mprotect change is consistent with mmap policy
>
> bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1055a2f2a00000
> start commit: 56b697c6 Add linux-next specific files for 20190604
> git tree: linux-next
> final crash: https://syzkaller.appspot.com/x/report.txt?x=1255a2f2a00000
> console output: https://syzkaller.appspot.com/x/log.txt?x=1455a2f2a00000
> kernel config: https://syzkaller.appspot.com/x/.config?x=4248d6bc70076f7d
> dashboard link: https://syzkaller.appspot.com/bug?extid=e1374b2ec8f6a25ab2e5
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=165757eea00000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=10dd3e86a00000
>
> Reported-by: syzbot+e1374b2ec8f6a25ab2e5@xxxxxxxxxxxxxxxxxxxxxxxxx
> Fixes: 69d61f577d14 ("ima: verify mprotect change is consistent with mmap
> policy")
>
> For information about bisection process see: https://goo.gl/tpsmEJ#bisection
>

Hi Mimi, it seems your change to call ima_file_mmap() from
security_file_mprotect() violates the locking order by taking i_rwsem while
mmap_sem is held.

- Eric