From: Dan Carpenter <dan.carpenter@oracle.com> To: Jens Axboe <axboe@kernel.dk> Cc: Alexander Viro <viro@zeniv.linux.org.uk>, io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] io_uring: Fix error handling in __io_compat_recvmsg_copy_hdr() Date: Thu, 5 Mar 2020 23:05:44 +0300 [thread overview] Message-ID: <20200305200544.5wmrfo7hbfybp3w5@kili.mountain> (raw) 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 <dan.carpenter@oracle.com> --- 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
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com> To: Jens Axboe <axboe@kernel.dk> Cc: Alexander Viro <viro@zeniv.linux.org.uk>, io-uring@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] io_uring: Fix error handling in __io_compat_recvmsg_copy_hdr() Date: Thu, 05 Mar 2020 20:05:44 +0000 [thread overview] Message-ID: <20200305200544.5wmrfo7hbfybp3w5@kili.mountain> (raw) 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 <dan.carpenter@oracle.com> --- 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
next reply other threads:[~2020-03-05 20:06 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-03-05 20:05 Dan Carpenter [this message] 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 2020-03-06 1:55 ` Jens Axboe
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=20200305200544.5wmrfo7hbfybp3w5@kili.mountain \ --to=dan.carpenter@oracle.com \ --cc=axboe@kernel.dk \ --cc=io-uring@vger.kernel.org \ --cc=kernel-janitors@vger.kernel.org \ --cc=linux-fsdevel@vger.kernel.org \ --cc=viro@zeniv.linux.org.uk \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.