]>
Commit | Line | Data |
---|---|---|
0e88ec19 FE |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Dominique Martinet <dominique.martinet@atmark-techno.com> | |
3 | Date: Thu, 30 Jun 2022 10:01:37 +0900 | |
4 | Subject: [PATCH] io_uring: fix short read slow path | |
5 | ||
6 | sqeq.off here is the offset to read within the disk image, so obviously | |
7 | not 'nread' (the amount we just read), but as the author meant to write | |
8 | its current value incremented by the amount we just read. | |
9 | ||
10 | Normally recent versions of linux will not issue short reads, | |
11 | but it can happen so we should fix this. | |
12 | ||
13 | This lead to weird image corruptions when short read happened | |
14 | ||
15 | Fixes: 6663a0a33764 ("block/io_uring: implements interfaces for io_uring") | |
16 | Link: https://lkml.kernel.org/r/YrrFGO4A1jS0GI0G@atmark-techno.com | |
17 | Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com> | |
18 | Message-Id: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com> | |
19 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> | |
20 | Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> | |
21 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | |
22 | (cherry-picked from commit c06fc7ce147e57ab493bad9263f1601b8298484b) | |
23 | Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> | |
24 | --- | |
25 | block/io_uring.c | 4 ++-- | |
26 | 1 file changed, 2 insertions(+), 2 deletions(-) | |
27 | ||
28 | diff --git a/block/io_uring.c b/block/io_uring.c | |
29 | index 782afdb433..e451e55de0 100644 | |
30 | --- a/block/io_uring.c | |
31 | +++ b/block/io_uring.c | |
32 | @@ -89,7 +89,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb, | |
33 | trace_luring_resubmit_short_read(s, luringcb, nread); | |
34 | ||
35 | /* Update read position */ | |
36 | - luringcb->total_read = nread; | |
37 | + luringcb->total_read += nread; | |
38 | remaining = luringcb->qiov->size - luringcb->total_read; | |
39 | ||
40 | /* Shorten qiov */ | |
41 | @@ -103,7 +103,7 @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb, | |
42 | remaining); | |
43 | ||
44 | /* Update sqe */ | |
45 | - luringcb->sqeq.off = nread; | |
46 | + luringcb->sqeq.off += nread; | |
47 | luringcb->sqeq.addr = (__u64)(uintptr_t)luringcb->resubmit_qiov.iov; | |
48 | luringcb->sqeq.len = luringcb->resubmit_qiov.niov; | |
49 |