Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3052725rwe; Mon, 29 Aug 2022 05:11:28 -0700 (PDT) X-Google-Smtp-Source: AA6agR5DaXx47mCqypHryKdDsp2MBBK0tUhYuQfh1gELBfQtR6lc/cxqOFCplJdLf7W4+X/GsRo5 X-Received: by 2002:a17:902:b484:b0:170:a2d8:80f6 with SMTP id y4-20020a170902b48400b00170a2d880f6mr16161951plr.97.1661775088114; Mon, 29 Aug 2022 05:11:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661775088; cv=none; d=google.com; s=arc-20160816; b=DHMWm9EZxisw4oN8IRfFvgnR/p9OT8jxskKYa25zeWSqy/zUw7MplEXKtGhvFlwGER dkVv314NnMMsh9pukmffufHl3+JjyKBmuJDIavK7w6XoEph8Tiyh2ftjPPCxeHkgOEHA Iz8RfkNpEsaDNfDitNX3QzE/jAGOfR7jNnBw+GMwsk0P5T+UtOsT7+ynTClYxa4k5Cs3 ppyNqq3nNmfPHNhzEpzBYmxqSTSYeDwvBRVTmEysT7SnJqMb3/zNsllhtvWfGJfUf274 wLu1jNnZ5ApX9Jf0DQ4e9e3+SnL7WBCX/TQxtlCry3ED8FIn2kE/MOgisEp3IA+PAoPz Ysjw== 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=dApoGXA6VEthBAK7mlavGQptci6jsaEXU4XvYancb8g=; b=Dv9U2WK+Di3QUlicPnuQ6M9hBbrW855vZGjzFpw/+O2EbdALWL24HvJlgJuSvx20Kr X5gERcjAHCykvRuK/P0sQov9rxZ3boAGYL7zZuRoVflCkKwyazvawVBgkisn/s9gQL4p ld0DbUy2tx0AudXZgHmuWnRtRZVkqQCrAfhEzrLo2hX5bwwFSmGZ+iCUHH5noQLz41AA YTrfKdOtOwtI9lkN0c02wT6LTZhM2ivkadr5Zr7Mtckl+39RXhzgki3ekPg+uZtU3/iM t39oAFwkbKThOK4S4rC+/XdXXLLwIAtcIt407dY+oQypZLWcbduDfF4GSpQwkrP/mDVf WBnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q4qCL+DJ; 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-20020a656214000000b0041d4865235esi1485799pgv.874.2022.08.29.05.11.08; Mon, 29 Aug 2022 05:11:28 -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=Q4qCL+DJ; 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 S232613AbiH2Lcv (ORCPT + 99 others); Mon, 29 Aug 2022 07:32:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232736AbiH2L3r (ORCPT ); Mon, 29 Aug 2022 07:29:47 -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 029DD6C743; Mon, 29 Aug 2022 04:18:20 -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 E8B05B80FC6; Mon, 29 Aug 2022 11:18:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 396F7C433C1; Mon, 29 Aug 2022 11:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661771893; bh=GuGLnIsnYWrNVKZYreFufFeWsFiv8joQyUvR0UrIA+Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q4qCL+DJiiOd+3mStyiE3ETOqgF2uyjgzQ8o8qozrGjFeeh/+X5KlE//yzSg6QlEx sjzf66os4cpOy3QbwKqm+fOjM7HSQNBLOox0kniLpxv+sK0yfw+wgupYSzlThU/MJ3 vWnRuueYsN4Djt/DgTnd+acNxPXbzr5aHPaTzKv0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe Subject: [PATCH 5.19 133/158] io_uring: fix issue with io_write() not always undoing sb_start_write() Date: Mon, 29 Aug 2022 12:59:43 +0200 Message-Id: <20220829105814.662247664@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220829105808.828227973@linuxfoundation.org> References: <20220829105808.828227973@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 --- io_uring/io_uring.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -4331,7 +4331,12 @@ done: copy_iov: iov_iter_restore(&s->iter, &s->iter_state); ret = io_setup_async_rw(req, iovec, s, 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() */