mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 22:58:29 +00:00
io_uring: don't use poll handler if file can't be nonblocking read/written
There's no point in using the poll handler if we can't do a nonblocking IO attempt of the operation, since we'll need to go async anyway. In fact this is actively harmful, as reading from eg pipes won't return 0 to indicate EOF. Cc: stable@vger.kernel.org # v5.7+ Reported-by: Benedikt Ames <wisp3rwind@posteo.eu> Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
parent
6b7898eb18
commit
9dab14b818
1 changed files with 9 additions and 1 deletions
|
@ -4889,12 +4889,20 @@ static bool io_arm_poll_handler(struct io_kiocb *req)
|
||||||
struct async_poll *apoll;
|
struct async_poll *apoll;
|
||||||
struct io_poll_table ipt;
|
struct io_poll_table ipt;
|
||||||
__poll_t mask, ret;
|
__poll_t mask, ret;
|
||||||
|
int rw;
|
||||||
|
|
||||||
if (!req->file || !file_can_poll(req->file))
|
if (!req->file || !file_can_poll(req->file))
|
||||||
return false;
|
return false;
|
||||||
if (req->flags & REQ_F_POLLED)
|
if (req->flags & REQ_F_POLLED)
|
||||||
return false;
|
return false;
|
||||||
if (!def->pollin && !def->pollout)
|
if (def->pollin)
|
||||||
|
rw = READ;
|
||||||
|
else if (def->pollout)
|
||||||
|
rw = WRITE;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
/* if we can't nonblock try, then no point in arming a poll handler */
|
||||||
|
if (!io_file_supports_async(req->file, rw))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
|
apoll = kmalloc(sizeof(*apoll), GFP_ATOMIC);
|
||||||
|
|
Loading…
Add table
Reference in a new issue