io_uring: avoid null-ptr-deref in io_arm_poll_handler
authorFedor Pchelkin <pchelkin@ispras.ru>
Thu, 16 Mar 2023 18:56:16 +0000 (21:56 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:31:37 +0000 (13:31 +0100)
commitf4ba55411cc8ffa883df861ce79af4bd35885b11
tree485dd358bddc2e4710d37f1bb2b58078ed727f2c
parent6ab7d33617559cced63d467928f478ea5c459021
io_uring: avoid null-ptr-deref in io_arm_poll_handler

No upstream commit exists for this commit.

The issue was introduced with backporting upstream commit c16bda37594f
("io_uring/poll: allow some retries for poll triggering spuriously").

Memory allocation can possibly fail causing invalid pointer be
dereferenced just before comparing it to NULL value.

Move the pointer check in proper place (upstream has the similar location
of the check). In case the request has REQ_F_POLLED flag up, apoll can't
be NULL so no need to check there.

Found by Linux Verification Center (linuxtesting.org) with Syzkaller.

Signed-off-by: Fedor Pchelkin <pchelkin@ispras.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/io_uring.c