]> git.baikalelectronics.ru Git - kernel.git/commit
pipe: Remove assertion from pipe_poll()
authorDavid Howells <dhowells@redhat.com>
Thu, 5 Dec 2019 22:30:30 +0000 (22:30 +0000)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 5 Dec 2019 23:33:50 +0000 (15:33 -0800)
commitb81a1d16b11c5cc3c2ece195268a64a0b81eadb6
tree2b51d3882e2b1a9126e37725a6e1525f5a763e00
parentd60a149eff51c94dc01efd5cb75b3274afdb6e47
pipe: Remove assertion from pipe_poll()

An assertion check was added to pipe_poll() to make sure that the ring
occupancy isn't seen to overflow the ring size.  However, since no locks
are held when the three values are read, it is possible for F_SETPIPE_SZ
to intervene and muck up the calculation, thereby causing the oops.

Fix this by simply removing the assertion and accepting that the
calculation might be approximate.

Note that the previous code also had a similar issue, though there was
no assertion check, since the occupancy counter and the ring size were
not read with a lock held, so it's possible that the poll check might
have malfunctioned then too.

Also wake up all the waiters so that they can reissue their checks if
there was a competing read or write.

Fixes: eb9e4cb12ab3 ("pipe: Use head and tail pointers for the ring, not cursor and length")
Reported-by: syzbot+d37abaade33a934f16f2@syzkaller.appspotmail.com
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/pipe.c