From: Greg Kroah-Hartman <gregkh@linuxfoundation•org>
To: linux-kernel@vger•kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation•org>,
stable@vger•kernel.org, netdev@vger•kernel.org,
David Miller <davem@davemloft•net>, Jens Axboe <axboe@kernel•dk>,
Sasha Levin <sashal@kernel•org>
Subject: [PATCH 5.4 040/191] net: make socket read/write_iter() honor IOCB_NOWAIT
Date: Tue, 7 Jan 2020 21:52:40 +0100 [thread overview]
Message-ID: <20200107205335.139933986@linuxfoundation.org> (raw)
In-Reply-To: <20200107205332.984228665@linuxfoundation.org>
From: Jens Axboe <axboe@kernel•dk>
[ Upstream commit ebfcd8955c0b52eb793bcbc9e71140e3d0cdb228 ]
The socket read/write helpers only look at the file O_NONBLOCK. not
the iocb IOCB_NOWAIT flag. This breaks users like preadv2/pwritev2
and io_uring that rely on not having the file itself marked nonblocking,
but rather the iocb itself.
Cc: netdev@vger•kernel.org
Acked-by: David Miller <davem@davemloft•net>
Signed-off-by: Jens Axboe <axboe@kernel•dk>
Signed-off-by: Sasha Levin <sashal@kernel•org>
---
net/socket.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/socket.c b/net/socket.c
index d7a106028f0e..ca8de9e1582d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -955,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 (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT))
msg.msg_flags = MSG_DONTWAIT;
if (iocb->ki_pos != 0)
@@ -980,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 (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT))
msg.msg_flags = MSG_DONTWAIT;
if (sock->type == SOCK_SEQPACKET)
--
2.20.1
next parent reply other threads:[~2020-01-07 21:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20200107205332.984228665@linuxfoundation.org>
2020-01-07 20:52 ` Greg Kroah-Hartman [this message]
2020-01-07 20:53 ` [PATCH 5.4 076/191] MIPS: BPF: Disable MIPS32 eBPF JIT Greg Kroah-Hartman
2020-01-07 20:53 ` [PATCH 5.4 077/191] MIPS: BPF: eBPF JIT: check for MIPS ISA compliance in Kconfig Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200107205335.139933986@linuxfoundation.org \
--to=gregkh@linuxfoundation$(echo .)org \
--cc=axboe@kernel$(echo .)dk \
--cc=davem@davemloft$(echo .)net \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=sashal@kernel$(echo .)org \
--cc=stable@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox