Re: [syzbot] possible deadlock in pipe_write

From: David Howells
Date: Mon Mar 21 2022 - 12:03:55 EST


Jann Horn <jannh@xxxxxxxxxx> wrote:

> The syz reproducer is:
>
> #{"threaded":true,"procs":1,"slowdown":1,"sandbox":"","close_fds":false}
> pipe(&(0x7f0000000240)={<r0=>0xffffffffffffffff, <r1=>0xffffffffffffffff})
> pipe2(&(0x7f00000001c0)={0xffffffffffffffff, <r2=>0xffffffffffffffff}, 0x80)
> splice(r0, 0x0, r2, 0x0, 0x1ff, 0x0)
> vmsplice(r1, &(0x7f00000006c0)=[{&(0x7f0000000080)="b5", 0x1}], 0x1, 0x0)
>
> That 0x80 is O_NOTIFICATION_PIPE (==O_EXCL).
>
> It looks like the bug is that when you try to splice between a normal
> pipe and a notification pipe, get_pipe_info(..., true) fails, so
> splice() falls back to treating the notification pipe like a normal
> pipe - so we end up in iter_file_splice_write(), which first locks the
> input pipe, then calls vfs_iter_write(), which locks the output pipe.
>
> I think this probably (?) can't actually lead to deadlocks, since
> you'd need another way to nest locking a normal pipe into locking a
> watch_queue pipe, but the lockdep annotations don't make that clear.

Is this then a bug/feature in iter_file_splice_write() rather than in the
watch queue code, per se?

David