Re: [PATCH 2/2] vt: selection, push sel_lock up

From: Jiri Slaby
Date: Fri Feb 28 2020 - 07:59:44 EST


On 28. 02. 20, 13:03, Greg KH wrote:
> On Fri, Feb 28, 2020 at 12:54:06PM +0100, Jiri Slaby wrote:
>> sel_lock cannot nest in the console lock. Thanks to syzkaller, the
>> kernel states firmly:
>>
>>> WARNING: possible circular locking dependency detected
>>> 5.6.0-rc3-syzkaller #0 Not tainted
>>> ------------------------------------------------------
>>> syz-executor.4/20336 is trying to acquire lock:
>>> ffff8880a2e952a0 (&tty->termios_rwsem){++++}, at: tty_unthrottle+0x22/0x100 drivers/tty/tty_ioctl.c:136
...
>>> other info that might help us debug this:
>>>
>>> Chain exists of:
>>> &tty->termios_rwsem --> console_lock --> sel_lock
>>
>> Clearly. From the above, we have:
>> console_lock -> sel_lock
>> sel_lock -> termios_rwsem
>> termios_rwsem -> console_lock
>>
>> Fix this by reversing the console_lock -> sel_lock dependency in
>> ioctl(TIOCL_SETSEL). First, lock sel_lock, then console_lock.
>>
>> Signed-off-by: Jiri Slaby <jslaby@xxxxxxx>
>> Reported-by: syzbot+26183d9746e62da329b8@xxxxxxxxxxxxxxxxxxxxxxxxx
>> Fixes: 07e6124a1a46 ("vt: selection, close sel_buffer race")
>
> As 07e6124a1a46 was marked for stable, both of these should be as well,
> right?

Ah, yes. My bad again, sorry.

> And did you happen to test these two with the syzbot tool to see if it
> really did fix the report?

Nope, this syz* stuff is a black magic for me. How can I do that?

thanks,
--
js
suse labs