Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3038359rwe; Mon, 29 Aug 2022 05:00:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR6kcqwr0RQWPTyCD8Iam1y0+wfijk1jlFUtFxaeXlm9oOhSLwhdIgQZHlkLK6tkrGod02E/ X-Received: by 2002:a63:c141:0:b0:429:fadb:7138 with SMTP id p1-20020a63c141000000b00429fadb7138mr13348911pgi.563.1661774430798; Mon, 29 Aug 2022 05:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661774430; cv=none; d=google.com; s=arc-20160816; b=ezqhVZdQQOKzL12oENzkcGgC4+J1cfBl9MnyqiVCjkCP7Rz3Jd1uRkTMSBhgMybxMb OwZXz0Jj0DmBWUf8yLWnAv+ww/lFq0iBr/TScNpj4/3kwXKKz6doHnjGPVEvTYZ7SPch 7SGlJz+C4w1VahOhh0n/SCQp7kWM3vK62jXcdxzbvERAfV4xG+Yfg8kpLsJZ/OqMBfZh baOwekCUs+aLBpoK7x99dyXmp7NGeU5tn0eYjNBZxbw/pcT55xQ+TPquqrw5Gt8BZURT gqaItSG45qvqtIStyMTu06vIRdRj9rQI9Uy7AEb9cuONKQAU7eHJch7BLcwnusWy93qx SFSg== 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=bGY9Ni/Jx4QvLPf+TKB+0dAafxRKI+oW76s9blYXlHM=; b=xA7YsD9xDsFJogH7o9V2ukk1FxoShWAkQVOrSfhEzYqF93T9GZwi+t40dWLmzCk+1M 0Gg20jV2kdmSsyTtqU5bzWI0mScazzWVUIyF1p4U9sPaufjaOvE7giowjgEuNZTKeDu3 S2gr98bUMz/+YpTqhCiqXdDWQ5LkgLM7T77KDAXra3VhhN2jiGizYQoaxV0AVhq3f8MU YChRyXStTGGBS14CQHELQPNdgtn11uol3N6sm/BlFEj38gRpg6EVS60/Bl0UC5p5tqRx CJXyQZ0FzuSDj0dS9M823qulTfuGHHNOKMVzS9IpFwbF3xqhlteyfQv1zDEiIBxLmQnr a+CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="cdyENni/"; 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 n16-20020a170903111000b001712e1efa90si9516004plh.22.2022.08.29.05.00.18; Mon, 29 Aug 2022 05:00:30 -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="cdyENni/"; 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 S231668AbiH2LUu (ORCPT + 99 others); Mon, 29 Aug 2022 07:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbiH2LTT (ORCPT ); Mon, 29 Aug 2022 07:19:19 -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 6E77D6E2D7; Mon, 29 Aug 2022 04:13:08 -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 E7AE661218; Mon, 29 Aug 2022 11:12:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEE80C433C1; Mon, 29 Aug 2022 11:12:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771579; bh=TMBHeboNLghMKzgaVvpn1uXQcBQMa8rbthZ+e+ZXWwE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cdyENni/YVu3wYKJV0qO5Ici0WPwilyPWRx+/7fvBhxQDnBOKyMXYXFsE+GZBe5RS r5aPHsSHtE9HIeX58HQNm8eQpP6dO2djnbEacUURVQVwbzLkQSv5UsyuJY+sGCj5ZJ yB0sxCaBTnLqYgt82/RiXrKjqfLVbEr9JackhqOQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.15 118/136] io_uring: fix issue with io_write() not always undoing sb_start_write() Date: Mon, 29 Aug 2022 12:59:45 +0200 Message-Id: <20220829105809.534834253@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105804.609007228@linuxfoundation.org> References: <20220829105804.609007228@linuxfoundation.org> User-Agent: quilt/0.67 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 commit e053aaf4da56cbf0afb33a0fda4a62188e2c0637 upstream. This is actually an older issue, but we never used to hit the -EAGAIN path before having done sb_start_write(). Make sure that we always call kiocb_end_write() if we need to retry the write, so that we keep the calls to sb_start_write() etc balanced. Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- fs/io_uring.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3720,7 +3720,12 @@ done: copy_iov: iov_iter_restore(iter, state); ret = io_setup_async_rw(req, iovec, inline_vecs, iter, false); - return ret ?: -EAGAIN; + if (!ret) { + if (kiocb->ki_flags & IOCB_WRITE) + kiocb_end_write(req); + return -EAGAIN; + } + return ret; } out_free: /* it's reportedly faster than delegating the null check to kfree() */