Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp663796pxb; Tue, 5 Apr 2022 17:51:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxR7gLX9RAx03If5n2WioyLkKyvJQOTfkv8VmtcNX7p9iva9sFIakFgt7+UqR15y0EI1DFU X-Received: by 2002:a17:907:7d8a:b0:6e7:eb3a:eaea with SMTP id oz10-20020a1709077d8a00b006e7eb3aeaeamr683163ejc.276.1649206305505; Tue, 05 Apr 2022 17:51:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649206305; cv=none; d=google.com; s=arc-20160816; b=eWkIfW4Tx0/HtM5ap5HmPigJZ9JJP5srFxn2PB9sVWLquvzvOThIj4bhyavm1SLGxh 8UU9DMK1MZMAGXDf9sydvYaQxf1E3Mrc5opWUMIrMJhyOvYkncHw9t8pMp5tOZiZsH+b JgyqKjA7nD0UNuDM6M/svSa3o5SiIW3eHtcRCCLT6DaaB3h1MjzikQy3DmEKNybRLruK 3qGJQgfEzSXN17B/mnhEPVOAPofeNPb1t+bbtWZ1JZom45609stVq9TGXa9RrWaqQszk DvM8TGVEwVfgMr8NyylBBoVLfS+bGSVBxL1zGrIaSRqA1YftHFuY8tzYaQPQebkYli6U hlEA== 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=PaohyG6wC++4SODi/c2VsnPDHyRV980+wubRc1zc/uo=; b=FCst+4YoFSemrykZfZiqXMU9Ptw2Gaq90kPfrbFhvJ/V6id/XbUrDSzaDhC0hNpas/ 1/jbzY/vvCh4vsE9HMGxeLjBadepZC363UqRbtUo+2exCX7AtXxMWkhUfvGnHxlCkIhl sW7h0Q3ERf0iTZFrcimfkijntIZ2g/5dws6fc14KRfo2+IWWNee7yT8GbdpYtWOuTKoR hb2aHXlB7D1urQgNNg2E+DrFwBaH6r6MjgzcaTieWhw/DEhs1WV3F7Or6rK2zBWwWjKB vL62N3cCPkXrCjFZontETtFRmJS9zQxZV5jKbrARutv6r+cQ51JiovcA6unjSHCDiJfe FeLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=F9bWElkz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d20-20020a17090648d400b006df76385e53si9778771ejt.755.2022.04.05.17.51.15; Tue, 05 Apr 2022 17:51: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=F9bWElkz; 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 S1356493AbiDEMJ5 (ORCPT + 99 others); Tue, 5 Apr 2022 08:09:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244720AbiDEIwf (ORCPT ); Tue, 5 Apr 2022 04:52:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05B6B1A3A6; Tue, 5 Apr 2022 01:42:44 -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 950BD61003; Tue, 5 Apr 2022 08:42:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A698DC385A1; Tue, 5 Apr 2022 08:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649148163; bh=XEw2Y6drUkp+hZx/0W0mg8thTAFr3EsviwmUE3IGpIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F9bWElkzEQeMk6AibRF/05XJnJFIEKXilf07fnOCq9jFztc0/+pDbqQF/W8RcOaGn 5OdoSlzEwAU1N8mYYgzaw+dp2DRqrmoad3OwgoesRxhua6NeTnUVUuMrkDkciRz6Hx gtztgUpT8/fackQEYl2aiDleGXIL7/0NGZBm3AMY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joel Jaeschke , Jens Axboe , Sasha Levin Subject: [PATCH 5.16 0256/1017] io_uring: terminate manual loop iterator loop correctly for non-vecs Date: Tue, 5 Apr 2022 09:19:29 +0200 Message-Id: <20220405070401.862362471@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 From: Jens Axboe [ Upstream commit 5e929367468c8f97cd1ffb0417316cecfebef94b ] The fix for not advancing the iterator if we're using fixed buffers is broken in that it can hit a condition where we don't terminate the loop. This results in io-wq looping forever, asking to read (or write) 0 bytes for every subsequent loop. Reported-by: Joel Jaeschke Link: https://github.com/axboe/liburing/issues/549 Fixes: 16c8d2df7ec0 ("io_uring: ensure symmetry in handling iter types in loop_rw_iter()") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 974f6fb327e7..2d25c51b8a5d 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3350,13 +3350,15 @@ static ssize_t loop_rw_iter(int rw, struct io_kiocb *req, struct iov_iter *iter) ret = nr; break; } + ret += nr; if (!iov_iter_is_bvec(iter)) { iov_iter_advance(iter, nr); } else { - req->rw.len -= nr; req->rw.addr += nr; + req->rw.len -= nr; + if (!req->rw.len) + break; } - ret += nr; if (nr != iovec.iov_len) break; } -- 2.34.1