Fix socket read_iter/write_iter implementations to handle IOCB_NOWAIT; for simple reads IOCB_NOWAIT will be set if O_NONBLOCK was set. Signed-off-by: Stefan Bühler <source@xxxxxxxxxxxx> --- net/socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/socket.c b/net/socket.c index 8255f5bda0aa..1e2f6819ea2b 100644 --- a/net/socket.c +++ b/net/socket.c @@ -410,6 +410,7 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname) sock_release(sock); return file; } + file->f_mode |= FMODE_NOWAIT; sock->file = file; file->private_data = sock; @@ -954,7 +955,7 @@ static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to) .msg_iocb = iocb}; ssize_t res; - if (file->f_flags & O_NONBLOCK) + if (iocb->ki_flags & IOCB_NOWAIT) msg.msg_flags = MSG_DONTWAIT; if (iocb->ki_pos != 0) @@ -979,7 +980,7 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from) if (iocb->ki_pos != 0) return -ESPIPE; - if (file->f_flags & O_NONBLOCK) + if (iocb->ki_flags & IOCB_NOWAIT) msg.msg_flags = MSG_DONTWAIT; if (sock->type == SOCK_SEQPACKET) -- 2.20.1