From patchwork Wed Oct 19 08:21:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4495 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp202041wrs; Wed, 19 Oct 2022 01:39:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7vAjaxQYwsU4+QZp14Q3/wjuNC6kWBeQFXgYYCCK4A3frrz2q/UqGHUyqNKYVEHJepabw0 X-Received: by 2002:a05:6402:3408:b0:43c:2dd3:d86b with SMTP id k8-20020a056402340800b0043c2dd3d86bmr6420192edc.108.1666168785678; Wed, 19 Oct 2022 01:39:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666168785; cv=none; d=google.com; s=arc-20160816; b=ciZFZaOy3dLzRhs9c26pIF1UiNnIrp+e6k0pi2pVIz1IT4+jklikkri2XFk3eHj34g HI5/f9y1De5hBHLlIObUK/gbmKoZ1By1Xb2GSlfEV0d32nuiW9RVWR7+dhcLvMd3wbu9 Jkj4PGlKlGvx8xJ4Oh0bapX7aimKdquxjH6LRrszkfA3eAYciOB2UcxWOnikAvR/OuIc OjxoWRUFW4bMbUZwQG1b85Out20Vtm3qBxBhboyLQP0dwg3SzBDxeO4PPtnbCOL/Q8cz aKW1bYQ+Y09+w3JxHiLqi+ppEwOVREylGH5ZrR9jrBqEyGYyjtIm3IKIBTs+mhKZJ6pP +FIg== 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=E0r95wIv893gtz03d4t/36NTzh6TxpbQsyAIGqs+GAo=; b=cOXwnu5PRS4Zj5sKtTE1WqizVYzX3B7KIplUwAUFWwpHKnBtmKEif4q96NqZ7ALUYg uNuNfT7MQaS/flZbLChJEWH9LY/uxQhL5BYx37vjCo6xfEHKlTj5ZvvMIl8Ha/Zcl5bn OiLVoZZatH2N8pCCSEVPl5Y/FNl4vfHgmmS+ITGE5i7hbX7buh+k5jSMRms7B7kcI2sn YV7UaCZh62kZcitwf2ZKorlaVZR8HKMX41gOnvwRodDAszfBJUbC12k2vw0RTC7NMXqE QKHyE+eamP3jbEj+qFEieiTc68vM1OoSYjCshBgERnxXXGdI3zM6QCVem9rDBaM18EBV NfOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1bgSA8tT; 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 g23-20020a50ec17000000b00459102fa225si12313791edr.137.2022.10.19.01.39.21; Wed, 19 Oct 2022 01:39:45 -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=1bgSA8tT; 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 S230195AbiJSIjC (ORCPT + 99 others); Wed, 19 Oct 2022 04:39:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230121AbiJSIib (ORCPT ); Wed, 19 Oct 2022 04:38:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FFB37FE4D; Wed, 19 Oct 2022 01:38:00 -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 ams.source.kernel.org (Postfix) with ESMTPS id 10542B822CD; Wed, 19 Oct 2022 08:37:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 690DCC433D7; Wed, 19 Oct 2022 08:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168660; bh=34Gr3PfE7aGRPmCyYfGLKbsdztwJ8w1JB2Ilz19qWMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1bgSA8tT7zqZJR+VIjFxoLpTZeq0JOW/Szm+treDt8JLt0ss3Z68ELdX5AueIDRJh NxBmXZLedXFeDinkvQK0N3g0bro2Q9kHeu6oc3Lfc8zawqMxeU03e0+rt4nhxIz8FC IuAw65DHHZXDYs68vPbsVz4GgZLyFqoIXM54wC6E= 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 6.0 013/862] io_uring/rw: fix unexpected link breakage Date: Wed, 19 Oct 2022 10:21:40 +0200 Message-Id: <20221019083250.585656755@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104600590442277?= X-GMAIL-MSGID: =?utf-8?q?1747104600590442277?= 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/rw.c | 1 + 1 file changed, 1 insertion(+) --- a/io_uring/rw.c +++ b/io_uring/rw.c @@ -823,6 +823,7 @@ int io_read(struct io_kiocb *req, unsign 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