From patchwork Sat Oct 22 07:18:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7133 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087148wrr; Sat, 22 Oct 2022 00:35:24 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UXNFNYIXzTixwvmGOFENISBgdf54LrdWtEWGL9ueB+WZJPKOhNMcYbHk4+03z1aEvV7Fi X-Received: by 2002:a17:907:3181:b0:787:d81c:a6ad with SMTP id xe1-20020a170907318100b00787d81ca6admr18985525ejb.769.1666424123956; Sat, 22 Oct 2022 00:35:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424123; cv=none; d=google.com; s=arc-20160816; b=I1efVaGo9ibUKveleXjirrrUWJCwIBGJr3kWKuje0G64/05tv1Is+NLBvnb78vO+tk 0fX5ALPltN3gOBBfHbbhXFKhS+sf5hy6jn+DN1o2axJCRhQVmR+ZqANeDQk/SP+7GVBa UhD0VHfSvzFOr4x0sUU4PhizOZ27nbcmT8bUGWkONWYQBpRGlbv3G3pZKiTQLU+K/SSP SC6BlVEQjiDL8uipqBjp9K3DuSC7fV4z1UqA5LKip8AZNfyTJWp0mK7l0k/b3UYlNf// nJVi4Qzav/KOttmimnncBZvWwchpY8crAVjUDyj9LYjfcPxN+fYE4NFuNbZHKCFaMkUN 3TtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Vi/mddzSzAydFbleTJOoNR0gJBqbz0lhusrF8lInsQ0=; b=fiWxEicU1Fo9EmILX+fge5uxosVJR+8C0MNHlZ5oz8Jkh4/Dp5LtfSmv3uv7FTSUAn DKVFdMfS/ogufa0HR5RoU65QU+KBWZJSZ+XwtlNDAijrAWy8woGXhmHFy8oBgaNeHmt+ TQFYSm1dp4C6Rgl/o6DQx/lTeKcrkOWy+0ku41o6jeiKG0vWCukbRNl4bwRg+VTPQLbW f670xB+9qTUNaTkNzYrK/QhEamE6Abt5trR9n58JzbLZMN71UQgw59oQippXSSX9sMaT WOVS6TPNXQgsR6QZyz4bv+my/GDMrOm67fmOHvl20z1fjq77a1atE6XjrN80tFjLBTSm rVGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VNj9T9DJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xc13-20020a170907074d00b007a0f4d6bf83si1099437ejb.305.2022.10.22.00.34.59; Sat, 22 Oct 2022 00:35:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VNj9T9DJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbiJVHeM (ORCPT + 99 others); Sat, 22 Oct 2022 03:34:12 -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 X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747372342595475721?= X-GMAIL-MSGID: =?utf-8?q?1747372342595475721?= 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.1664235732.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; } + req->cqe.res = 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