From nobody Sat Feb 7 15:34:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B5A2EC433FE for ; Sat, 22 Oct 2022 07:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230136AbiJVHeO (ORCPT ); Sat, 22 Oct 2022 03:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230043AbiJVHeG (ORCPT ); Sat, 22 Oct 2022 03:34:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C6240213451; Sat, 22 Oct 2022 00:34:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5F8D060ADB; Sat, 22 Oct 2022 07:34:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64B75C433D6; Sat, 22 Oct 2022 07:34:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424043; bh=FkjzUhUl5EbNNLaFPOUkRAlXaQ5oBJlhSD4w0qnx4nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VNj9T9DJX/oRugflZg0PUnUCHJ12fmEyIgVn0MTjRpSiPlnMsoGvZd4Apsbli2c0Y kegqB23mYak7/OwNA55BdFMlcsezvDMgBiBNXoq1qaH6+V7GAlLhFiNFB+spZ92yPv vzx5zW8hKtns8QZdmNvfNIyO61GqeL4mAvK+zrrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe , Beld Zhang Subject: [PATCH 5.19 011/717] io_uring/rw: fix unexpected link breakage Date: Sat, 22 Oct 2022 09:18:10 +0200 Message-Id: <20221022072417.091622636@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pavel Begunkov commit bf68b5b34311ee57ed40749a1257a30b46127556 upstream. req->cqe.res is set in io_read() to the amount of bytes left to be done, which is used to figure out whether to fail a read or not. However, io_read() may do another without returning, and we stash the previous value into ->bytes_done but forget to update cqe.res. Then we ask a read to do strictly less than cqe.res but expect the return to be exactly cqe.res. Fix the bug by updating cqe.res for retries. Cc: stable@vger.kernel.org Reported-and-Tested-by: Beld Zhang Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/3a1088440c7be98e5800267af922a67da0ef9f13.16= 64235732.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/io_uring.c | 1 + 1 file changed, 1 insertion(+) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -4215,6 +4215,7 @@ static int io_read(struct io_kiocb *req, return -EAGAIN; } =20 + req->cqe.res =3D iov_iter_count(&s->iter); /* * Now retry read with the IOCB_WAITQ parts set in the iocb. If * we get -EIOCBQUEUED, then we'll get a notification when the