From nobody Wed Dec 17 21:46:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1657182227; cv=none; d=zohomail.com; s=zohoarc; b=gyP8DqvUp+eqXkzwS6KlE7ipg5x+sM1EWiQNq2lpv7tCtAD9Jk9IY3OuzuEwDQ0zSUBerE2LMqODM3fmCqWqNEaVAkXuB8YjBwnsbgY++jH83PEumm4g57pQkhphP/mZcdsBIhbDqHcVW58av3Nyc3OVggWih3DPrMrVkMnbFv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657182227; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=a93GsxKY0muqBL+LWACkxxKWKt6MOUdxYh8WkWccbl0=; b=HXq3oyVZlzorbczVFDZnMT3pQbwnQsKKNpHmQDOJiU2rba5lIf2m/BYmgx4IL+nSyvJcdV98jjW+HZ0zFSomux3hq7Qt/6cAzoQVD16VtTuJeq4CW7VioPVj62HIYm6QXxlhLaqhQVyzgTk1vG94MA5L3/7SdPzIdT/ljBfGR+I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1657182227075506.15405397985876; Thu, 7 Jul 2022 01:23:47 -0700 (PDT) Received: from localhost ([::1]:36356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o9MnZ-0001oE-RE for importer@patchew.org; Thu, 07 Jul 2022 04:23:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57446) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9Md8-00070r-5W for qemu-devel@nongnu.org; Thu, 07 Jul 2022 04:12:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o9Md6-0007mW-G6 for qemu-devel@nongnu.org; Thu, 07 Jul 2022 04:12:57 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-664-t9TKhChxPEWPLJRC6KU_5A-1; Thu, 07 Jul 2022 04:12:51 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1ACCF8339A4; Thu, 7 Jul 2022 08:12:51 +0000 (UTC) Received: from localhost (unknown [10.39.194.62]) by smtp.corp.redhat.com (Postfix) with ESMTP id A1453C27D9A; Thu, 7 Jul 2022 08:12:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1657181574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=a93GsxKY0muqBL+LWACkxxKWKt6MOUdxYh8WkWccbl0=; b=SSJusMyGe3fEyntP7IXAHs96Fb8m/pTXNJUjEP8h8AcsQsFhvps0eA10IFLfr/WL30PHbQ UXGwGHCJtmNoukVn6GeequV/DiTJY0HYtAVyme/WFWPVZJZxSzcpGzl7yuWlXOCMzUCMkt rb82+eYPYp7Py4WS9E7WdbQhNg0l9mQ= X-MC-Unique: t9TKhChxPEWPLJRC6KU_5A-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Cc: Julia Suvorova , qemu-block@nongnu.org, Stefano Garzarella , Hanna Reitz , Kevin Wolf , Aarushi Mehta , Stefan Hajnoczi , Richard Henderson , Dominique Martinet Subject: [PULL 1/2] io_uring: fix short read slow path Date: Thu, 7 Jul 2022 09:12:46 +0100 Message-Id: <20220707081247.1416955-2-stefanha@redhat.com> In-Reply-To: <20220707081247.1416955-1-stefanha@redhat.com> References: <20220707081247.1416955-1-stefanha@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=stefanha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1657182228945100001 Content-Type: text/plain; charset="utf-8" From: Dominique Martinet sqeq.off here is the offset to read within the disk image, so obviously not 'nread' (the amount we just read), but as the author meant to write its current value incremented by the amount we just read. Normally recent versions of linux will not issue short reads, but it can happen so we should fix this. This lead to weird image corruptions when short read happened Fixes: 6663a0a33764 ("block/io_uring: implements interfaces for io_uring") Link: https://lkml.kernel.org/r/YrrFGO4A1jS0GI0G@atmark-techno.com Signed-off-by: Dominique Martinet Message-Id: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com> Reviewed-by: Hanna Reitz Reviewed-by: Stefano Garzarella Signed-off-by: Stefan Hajnoczi --- block/io_uring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/io_uring.c b/block/io_uring.c index d48e472e74..b238661740 100644 --- a/block/io_uring.c +++ b/block/io_uring.c @@ -89,7 +89,7 @@ static void luring_resubmit_short_read(LuringState *s, Lu= ringAIOCB *luringcb, trace_luring_resubmit_short_read(s, luringcb, nread); =20 /* Update read position */ - luringcb->total_read =3D nread; + luringcb->total_read +=3D nread; remaining =3D luringcb->qiov->size - luringcb->total_read; =20 /* Shorten qiov */ @@ -103,7 +103,7 @@ static void luring_resubmit_short_read(LuringState *s, = LuringAIOCB *luringcb, remaining); =20 /* Update sqe */ - luringcb->sqeq.off =3D nread; + luringcb->sqeq.off +=3D nread; luringcb->sqeq.addr =3D (__u64)(uintptr_t)luringcb->resubmit_qiov.iov; luringcb->sqeq.len =3D luringcb->resubmit_qiov.niov; =20 --=20 2.36.1