From nobody Sat Oct 18 02:17:38 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DDDCC433FE for ; Wed, 19 Oct 2022 08:38:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230285AbiJSIin (ORCPT ); Wed, 19 Oct 2022 04:38:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbiJSIi3 (ORCPT ); Wed, 19 Oct 2022 04:38:29 -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 676997F0B1; Wed, 19 Oct 2022 01:37:39 -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 5A151617DE; Wed, 19 Oct 2022 08:37:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A1E9C433D7; Wed, 19 Oct 2022 08:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168657; bh=ZKHuwzbbayTKexEwFeJx2fK4RZ5sHCm4E9pO/aAbQDQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yu5oBujCCryBOT9R41A6v5vNPWc4HQoUeiZNS+P7H1jeX5JH6B701yucSLVxTDSoF ZwEq0E6+SIoMCBq6UMy7y94H1uwqL9fExVIeQu4QRs7nUvyCZOOoxhxcuZIq1Hky/J wgpabSTQqfhUz8IhYNBYBcQL3gpMZMKVEYCEg30g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Begunkov , Jens Axboe Subject: [PATCH 6.0 012/862] io_uring/net: dont lose partial send/recv on fail Date: Wed, 19 Oct 2022 10:21:39 +0200 Message-Id: <20221019083250.547079300@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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Pavel Begunkov commit 7e6b638ed501cced4e472298d6b08dd16346f3a6 upstream. Just as with rw, partial send/recv may end up in io_req_complete_failed() and loose the result, make sure we return the number of bytes processed. Cc: stable@vger.kernel.org Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/a4ff95897b5419356fca9ea55db91ac15b2975f9.16= 63668091.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/net.c | 10 ++++++++++ io_uring/net.h | 2 ++ io_uring/opdef.c | 4 ++++ 3 files changed, 16 insertions(+) --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1087,6 +1087,16 @@ int io_sendzc(struct io_kiocb *req, unsi return IOU_OK; } =20 +void io_sendrecv_fail(struct io_kiocb *req) +{ + struct io_sr_msg *sr =3D io_kiocb_to_cmd(req, struct io_sr_msg); + int res =3D req->cqe.res; + + if (req->flags & REQ_F_PARTIAL_IO) + res =3D sr->done_io; + io_req_set_res(req, res, req->cqe.flags); +} + int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { struct io_accept *accept =3D io_kiocb_to_cmd(req, struct io_accept); --- a/io_uring/net.h +++ b/io_uring/net.h @@ -43,6 +43,8 @@ int io_recvmsg_prep(struct io_kiocb *req int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags); int io_recv(struct io_kiocb *req, unsigned int issue_flags); =20 +void io_sendrecv_fail(struct io_kiocb *req); + int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); int io_accept(struct io_kiocb *req, unsigned int issue_flags); =20 --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -157,6 +157,7 @@ const struct io_op_def io_op_defs[] =3D { .issue =3D io_sendmsg, .prep_async =3D io_sendmsg_prep_async, .cleanup =3D io_sendmsg_recvmsg_cleanup, + .fail =3D io_sendrecv_fail, #else .prep =3D io_eopnotsupp_prep, #endif @@ -174,6 +175,7 @@ const struct io_op_def io_op_defs[] =3D { .issue =3D io_recvmsg, .prep_async =3D io_recvmsg_prep_async, .cleanup =3D io_sendmsg_recvmsg_cleanup, + .fail =3D io_sendrecv_fail, #else .prep =3D io_eopnotsupp_prep, #endif @@ -316,6 +318,7 @@ const struct io_op_def io_op_defs[] =3D { #if defined(CONFIG_NET) .prep =3D io_sendmsg_prep, .issue =3D io_send, + .fail =3D io_sendrecv_fail, #else .prep =3D io_eopnotsupp_prep, #endif @@ -331,6 +334,7 @@ const struct io_op_def io_op_defs[] =3D { #if defined(CONFIG_NET) .prep =3D io_recvmsg_prep, .issue =3D io_recv, + .fail =3D io_sendrecv_fail, #else .prep =3D io_eopnotsupp_prep, #endif