public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring: Fix error handling in __io_compat_recvmsg_copy_hdr()
@ 2020-03-05 20:05 Dan Carpenter
  2020-03-06  1:55 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-03-05 20:05 UTC (permalink / raw)
  To: Jens Axboe; +Cc: Alexander Viro, io-uring, linux-fsdevel, kernel-janitors

We need to check if __get_compat_msghdr() fails and return immediately
on error.  Also if compat_import_iovec() fails then we should return a
negative error code, but the current behavior is to just return
success.

Fixes: ede6c476b57d ("io_uring: add IOSQE_BUFFER_SELECT support for IORING_OP_RECVMSG")
Signed-off-by: Dan Carpenter <[email protected]>
---
 fs/io_uring.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index d7c42bd04c78..c1a59cde2d88 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3684,6 +3684,8 @@ static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req,
 	msg_compat = (struct compat_msghdr __user *) sr->msg;
 	ret = __get_compat_msghdr(&io->msg.msg, msg_compat, &io->msg.uaddr,
 					&ptr, &len);
+	if (ret)
+		return ret;
 
 	uiov = compat_ptr(ptr);
 	if (req->flags & REQ_F_BUFFER_SELECT) {
@@ -3703,8 +3705,8 @@ static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req,
 		ret = compat_import_iovec(READ, uiov, len, UIO_FASTIOV,
 						&io->msg.iov,
 						&io->msg.msg.msg_iter);
-		if (ret > 0)
-			ret = 0;
+		if (ret < 0)
+			return ret;
 	}
 
 	return 0;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] io_uring: Fix error handling in __io_compat_recvmsg_copy_hdr()
  2020-03-05 20:05 [PATCH] io_uring: Fix error handling in __io_compat_recvmsg_copy_hdr() Dan Carpenter
@ 2020-03-06  1:55 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2020-03-06  1:55 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Alexander Viro, io-uring, linux-fsdevel, kernel-janitors

On 3/5/20 1:05 PM, Dan Carpenter wrote:
> We need to check if __get_compat_msghdr() fails and return immediately
> on error.  Also if compat_import_iovec() fails then we should return a
> negative error code, but the current behavior is to just return
> success.

Thanks, that certainly looks better... Applied.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-06  1:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-05 20:05 [PATCH] io_uring: Fix error handling in __io_compat_recvmsg_copy_hdr() Dan Carpenter
2020-03-06  1:55 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox