lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAG48ez1+4dbZ9Vi8N4NKCtGwuXErkUs6bC=8Pf+6jiZbxrwR7g@mail.gmail.com>
Date:   Mon, 21 Mar 2022 17:17:54 +0100
From:   Jann Horn <jannh@...gle.com>
To:     David Howells <dhowells@...hat.com>
Cc:     syzbot <syzbot+011e4ea1da6692cf881c@...kaller.appspotmail.com>,
        linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        syzkaller-bugs@...glegroups.com, viro@...iv.linux.org.uk
Subject: Re: [syzbot] possible deadlock in pipe_write

On Mon, Mar 21, 2022 at 5:03 PM David Howells <dhowells@...hat.com> wrote:
> Jann Horn <jannh@...gle.com> 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?

I think at least when you call splice() on two normal pipes from
userspace, it'll never go through this codepath for real pipes,
because pipe-to-pipe splicing is special-cased? And sendfile() bails
out in that case because pipes don't have a .splice_read() handler.

And with notification pipes, we don't take that special path in
splice(), and so we hit the lockdep warning. But I don't know whether
that makes it the fault of notification pipes...

Maybe it would be enough to just move the "if (pipe->watch_queue)"
check in pipe_write() up above the __pipe_lock(pipe)?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ