No description
Find a file
Stefan Metzmacher fc2491562a io_uring/net: fix fast_iov assignment in io_setup_async_msg()
commit 3e4cb6ebbb upstream.

I hit a very bad problem during my tests of SENDMSG_ZC.
BUG(); in first_iovec_segment() triggered very easily.
The problem was io_setup_async_msg() in the partial retry case,
which seems to happen more often with _ZC.

iov_iter_iovec_advance() may change i->iov in order to have i->iov_offset
being only relative to the first element.

Which means kmsg->msg.msg_iter.iov is no longer the
same as kmsg->fast_iov.

But this would rewind the copy to be the start of
async_msg->fast_iov, which means the internal
state of sync_msg->msg.msg_iter is inconsitent.

I tested with 5 vectors with length like this 4, 0, 64, 20, 8388608
and got a short writes with:
- ret=2675244 min_ret=8388692 => remaining 5713448 sr->done_io=2675244
- ret=-EAGAIN => io_uring_poll_arm
- ret=4911225 min_ret=5713448 => remaining 802223  sr->done_io=7586469
- ret=-EAGAIN => io_uring_poll_arm
- ret=802223  min_ret=802223  => res=8388692

While this was easily triggered with SENDMSG_ZC (queued for 6.1),
it was a potential problem starting with 7ba89d2af1
in 5.18 for IORING_OP_RECVMSG.
And also with 4c3c09439c in 5.19
for IORING_OP_SENDMSG.

However 257e84a537 introduced the critical
code into io_setup_async_msg() in 5.11.

Fixes: 7ba89d2af1 ("io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly")
Fixes: 257e84a537 ("io_uring: refactor sendmsg/recvmsg iov managing")
Cc: stable@vger.kernel.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/b2e7be246e2fb173520862b0c7098e55767567a2.1664436949.git.metze@samba.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-24 07:20:01 +01:00
arch x86/fpu: Use _Alignof to avoid undefined behavior in TYPE_ALIGN 2023-01-24 07:20:01 +01:00
block blk-mq: fix possible memleak when register 'hctx' failed 2023-01-14 10:16:19 +01:00
certs
crypto crypto: tcrypt - Fix multibuffer skcipher speed test mem leak 2023-01-14 10:15:50 +01:00
Documentation dt-bindings: phy: g12a-usb3-pcie-phy: fix compatible string documentation 2023-01-24 07:20:00 +01:00
drivers Revert "drm/amdgpu: make display pinning more flexible (v2)" 2023-01-24 07:20:01 +01:00
fs cifs: do not include page data when checking signature 2023-01-24 07:19:59 +01:00
include tracing: Use alignof__(struct {type b;}) instead of offsetof() 2023-01-24 07:20:01 +01:00
init
io_uring io_uring/net: fix fast_iov assignment in io_setup_async_msg() 2023-01-24 07:20:01 +01:00
ipc
kernel prlimit: do_prlimit needs to have a speculation check 2023-01-24 07:19:58 +01:00
lib mm/highmem: Lift memcpy_[to|from]_page to core 2023-01-14 10:16:42 +01:00
LICENSES
mm mm: Always release pages to the buddy allocator in memblock_free_late(). 2023-01-18 11:44:59 +01:00
net wifi: mac80211: sdata can be NULL during AMPDU start 2023-01-24 07:19:56 +01:00
samples samples: vfio-mdev: Fix missing pci_disable_device() in mdpy_fb_probe() 2023-01-14 10:16:01 +01:00
scripts
security device_cgroup: Roll back to original exceptions after copy failure 2023-01-14 10:16:36 +01:00
sound ALSA: hda/realtek - Turn on power early 2023-01-24 07:19:56 +01:00
tools tools/virtio: initialize spinlocks in vring_test.c 2023-01-24 07:19:55 +01:00
usr
virt
.clang-format
.cocciconfig
.get_maintainer.ignore
.gitattributes
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile Linux 5.10.164 2023-01-18 11:45:02 +01:00
README

Linux kernel
============

There are several guides for kernel developers and users. These guides can
be rendered in a number of formats, like HTML and PDF. Please read
Documentation/admin-guide/README.rst first.

In order to build the documentation, use ``make htmldocs`` or
``make pdfdocs``.  The formatted documentation can also be read online at:

    https://www.kernel.org/doc/html/latest/

There are various text files in the Documentation/ subdirectory,
several of them using the Restructured Text markup notation.

Please read the Documentation/process/changes.rst file, as it contains the
requirements for building and running the kernel, and information about
the problems which may result by upgrading your kernel.