]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
io_uring: fix UAF due to missing POLLFREE handling
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 19 Sep 2022 17:58:00 +0000 (19:58 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 20 Sep 2022 09:08:28 +0000 (11:08 +0200)
commite52a6fd7d3038b7e0f36cda476e071156a800900
treee6460d15bc36b7f718166f6ff1e2af26e8b2cffe
parent1383e3574be006da992159f839826a8e1a5717fa
io_uring: fix UAF due to missing POLLFREE handling

[ upstream commmit 791f3465c4afde02d7f16cf7424ca87070b69396 ]

Fixes a problem described in 50252e4b5e989
("aio: fix use-after-free due to missing POLLFREE handling")
and copies the approach used there.

In short, we have to forcibly eject a poll entry when we meet POLLFREE.
We can't rely on io_poll_get_ownership() as can't wait for potentially
running tw handlers, so we use the fact that wqs are RCU freed. See
Eric's patch and comments for more details.

Reported-by: Eric Biggers <ebiggers@google.com>
Link: https://lore.kernel.org/r/20211209010455.42744-6-ebiggers@kernel.org
Reported-and-tested-by: syzbot+5426c7ed6868c705ca14@syzkaller.appspotmail.com
Fixes: 221c5eb233823 ("io_uring: add support for IORING_OP_POLL")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/4ed56b6f548f7ea337603a82315750449412748a.1642161259.git.asml.silence@gmail.com
[axboe: drop non-functional change from patch]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[pavel: backport]
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e9d7ca0c4640cbebe6840ee3bac66a25a9bacaf5 linux-5.15.y)
CVE-2022-3176
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/io_uring.c