Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp676102pxb; Tue, 5 Apr 2022 18:19:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/+J1VHOpfrwKxjQzTAvZVCWiS/OqlbLUZWUzO8Tza/D0Xc1jW/K4Pl+EUEoZO9JDq8L7t X-Received: by 2002:a05:6402:f1c:b0:41b:54d2:ef1b with SMTP id i28-20020a0564020f1c00b0041b54d2ef1bmr6238182eda.185.1649207969122; Tue, 05 Apr 2022 18:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649207969; cv=none; d=google.com; s=arc-20160816; b=1KuIf4bQvu8FkEA50l/OurgaqyluAlHAW7wkRPfQiINEMF8pCvD/GH/lZluud8Eu5C m4vS+lbSyIu8+u0Nc8K6d8+PeSKrdN40HO4A6IlC2AmpnwKYzKLY7C3D926lEGxSo0XW RJMVbWzT4k7a90KboyrKrrLOFSGB+giEPRZmVtr4cJfkcIgzMYgMXnCqESZ5T4WfN9Ax hIzy9jDe3nsp9BqFDS1Au+MuuPHaBvjzK2+LWGk7EPxyOcWlgbbF4CaVDmb43en3/FWp 2f51KTSlhD/CYbe6NJqhPr4SHk4j5LTzMd3ClMH53f6VgH5nC00XrIRvu9pLKt61TVrU WU2w== 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=p3o4XyfOAAWNfaLZz57h5NRa7E8wk4htTjr2AZ92cEs=; b=XiVJs/CV/PX7lwq35tQtM4RflxJ1py2Bz0opzVoe9Ad2RqU+XDVGLsK67Ts5wyu3cv 8QBR40e6b5k21zQKW6IdKiQwxRAJz9GpYDOuw+XU1j+FmPOBBwwk3lK1gX666EMOo8/f NKU+Sdl88JAJJIYViV3dnnGkcIDy/Oiz3vMuzVLWPNOFWpuk0Ybw2fJ3L9LgWKy60oFR u35HCZWV+z46hR8pqUm57/7qNv7i4yfaq1jYUFbnZ+j7n8CJWecD3hFoXF++7GtlJNdH 0AVMhMslr1IVmwlkE36ed9+BedsQLiWR+ltX2MKI7nUviI5hRPb/LvzvlumkQDCNCwg1 cEjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BcgIdu5q; 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 q7-20020a1709064cc700b006df76385e2dsi10454710ejt.717.2022.04.05.18.18.55; Tue, 05 Apr 2022 18:19:29 -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=BcgIdu5q; 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 S1359657AbiDEPMp (ORCPT + 99 others); Tue, 5 Apr 2022 11:12:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345636AbiDEJnl (ORCPT ); Tue, 5 Apr 2022 05:43:41 -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 9A447C4E1B; Tue, 5 Apr 2022 02:29:30 -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 58455616D2; Tue, 5 Apr 2022 09:29:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68486C385A0; Tue, 5 Apr 2022 09:29:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150962; bh=C89ZJw/w30s5nJwuI+SqP0Mv4XWo5ly++QaLGXUhdg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BcgIdu5qUXNH+AsFdw/QlP31raoyyh/D9+bw6SGV9YiJdHBNPwu00jcbP1ySPHBzp kGTDWiswpAYKZ343mdHXEx8Ahyc2gu/7VPZ5u0b9ahrf58B4xqSsPzJakf6mwQDhTn QlxQhmATDEdL26v4d3IDCxcfie7T0PEWPDv1kPNQ= 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.15 243/913] io_uring: terminate manual loop iterator loop correctly for non-vecs Date: Tue, 5 Apr 2022 09:21:45 +0200 Message-Id: <20220405070347.141374452@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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 70e85f64dc38..ec0b50940405 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3319,13 +3319,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