Skip to content
Snippets Groups Projects
  1. Feb 01, 2024
    • Jens Axboe's avatar
      io_uring/net: fix sr->len for IORING_OP_RECV with MSG_WAITALL and buffers · 72bd8025
      Jens Axboe authored
      
      If we use IORING_OP_RECV with provided buffers and pass in '0' as the
      length of the request, the length is retrieved from the selected buffer.
      If MSG_WAITALL is also set and we get a short receive, then we may hit
      the retry path which decrements sr->len and increments the buffer for
      a retry. However, the length is still zero at this point, which means
      that sr->len now becomes huge and import_ubuf() will cap it to
      MAX_RW_COUNT and subsequently return -EFAULT for the range as a whole.
      
      Fix this by always assigning sr->len once the buffer has been selected.
      
      Cc: stable@vger.kernel.org
      Fixes: 7ba89d2a ("io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly")
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      72bd8025
  2. Jan 29, 2024
    • Jens Axboe's avatar
      io_uring/net: limit inline multishot retries · 76b367a2
      Jens Axboe authored
      If we have multiple clients and some/all are flooding the receives to
      such an extent that we can retry a LOT handling multishot receives, then
      we can be starving some clients and hence serving traffic in an
      imbalanced fashion.
      
      Limit multishot retry attempts to some arbitrary value, whose only
      purpose serves to ensure that we don't keep serving a single connection
      for way too long. We default to 32 retries, which should be more than
      enough to provide fairness, yet not so small that we'll spend too much
      time requeuing rather than handling traffic.
      
      Cc: stable@vger.kernel.org
      Depends-on: 704ea888 ("io_uring/poll: add requeue return code from poll multishot handling")
      Depends-on: 1e5d765a82f ("io_uring/net: un-indent mshot retry path in io_recv_finish()")
      Depends-on: e84b01a8 ("io_uring/poll: move poll execution helpers higher up")
      Fixes: b3fdea6e ("io_uring: multishot recv")
      Fixes: 9bb66906 ("io_uring: support multishot in recvmsg")
      Link: https://github.com/axboe/liburing/issues/1043
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      76b367a2
    • Jens Axboe's avatar
      io_uring/net: un-indent mshot retry path in io_recv_finish() · 91e5d765
      Jens Axboe authored
      
      In preparation for putting some retry logic in there, have the done
      path just skip straight to the end rather than have too much nesting
      in here.
      
      No functional changes in this patch.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      91e5d765
  3. Nov 03, 2023
    • Jens Axboe's avatar
      io_uring/net: ensure socket is marked connected on connect retry · f8f9ab2d
      Jens Axboe authored
      io_uring does non-blocking connection attempts, which can yield some
      unexpected results if a connect request is re-attempted by an an
      application. This is equivalent to the following sync syscall sequence:
      
      sock = socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, IPPROTO_TCP);
      connect(sock, &addr, sizeof(addr);
      
      ret == -1 and errno == EINPROGRESS expected here. Now poll for POLLOUT
      on sock, and when that returns, we expect the socket to be connected.
      But if we follow that procedure with:
      
      connect(sock, &addr, sizeof(addr));
      
      you'd expect ret == -1 and errno == EISCONN here, but you actually get
      ret == 0. If we attempt the connection one more time, then we get EISCON
      as expected.
      
      io_uring used to do this, but turns out that bluetooth fails with EBADFD
      if you attempt to re-connect. Also looks like EISCONN _could_ occur with
      this sequence.
      
      Retain the ->in_progress logic, but work-around a potential EISCONN or
      EBADFD error and only in those cases look at the sock_error(). This
      should work in general and avoid the odd sequence of a repeated connect
      request returning success when the socket is already connected.
      
      This is all a side effect of the socket state being in a CONNECTING
      state when we get EINPROGRESS, and only a re-connect or other related
      operation will turn that into CONNECTED.
      
      Cc: stable@vger.kernel.org
      Fixes: 3fb1bd68 ("io_uring/net: handle -EINPROGRESS correct for IORING_OP_CONNECT")
      Link: https://github.com/axboe/liburing/issues/980
      
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      f8f9ab2d
  4. Sep 14, 2023
  5. Aug 11, 2023
  6. Jun 27, 2023
  7. Jun 21, 2023
  8. Jun 14, 2023
  9. Jun 07, 2023
  10. May 24, 2023
  11. May 17, 2023
  12. Mar 30, 2023
    • Jens Axboe's avatar
      iov_iter: add iter_iovec() helper · de4f5fed
      Jens Axboe authored
      
      This returns a pointer to the current iovec entry in the iterator. Only
      useful with ITER_IOVEC right now, but it prepares us to treat ITER_UBUF
      and ITER_IOVEC identically for the first segment.
      
      Rename struct iov_iter->iov to iov_iter->__iov to find any potentially
      troublesome spots, and also to prevent anyone from adding new code that
      accesses iter->iov directly.
      
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      de4f5fed
  13. Mar 21, 2023
  14. Feb 24, 2023
  15. Jan 29, 2023
  16. Jan 23, 2023
    • Jens Axboe's avatar
      io_uring/net: cache provided buffer group value for multishot receives · b00c51ef
      Jens Axboe authored
      
      If we're using ring provided buffers with multishot receive, and we end
      up doing an io-wq based issue at some points that also needs to select
      a buffer, we'll lose the initially assigned buffer group as
      io_ring_buffer_select() correctly clears the buffer group list as the
      issue isn't serialized by the ctx uring_lock. This is fine for normal
      receives as the request puts the buffer and finishes, but for multishot,
      we will re-arm and do further receives. On the next trigger for this
      multishot receive, the receive will try and pick from a buffer group
      whose value is the same as the buffer ID of the las receive. That is
      obviously incorrect, and will result in a premature -ENOUFS error for
      the receive even if we had available buffers in the correct group.
      
      Cache the buffer group value at prep time, so we can restore it for
      future receives. This only needs doing for the above mentioned case, but
      just do it by default to keep it easier to read.
      
      Cc: stable@vger.kernel.org
      Fixes: b3fdea6e ("io_uring: multishot recv")
      Fixes: 9bb66906 ("io_uring: support multishot in recvmsg")
      Cc: Dylan Yudaken <dylany@meta.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      b00c51ef
  17. Jan 09, 2023
  18. Dec 19, 2022
  19. Dec 07, 2022
  20. Nov 25, 2022
  21. Nov 21, 2022
  22. Nov 17, 2022
  23. Oct 22, 2022
Loading