Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp835041rwi; Wed, 19 Oct 2022 03:39:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM60lIl8PIXko2wAA/w02byQOLLXRqxDvURNeD2avOLACALDgtTRkJsHavKf5Ehe+gsXOXs7 X-Received: by 2002:a17:907:9493:b0:796:1166:70c4 with SMTP id dm19-20020a170907949300b00796116670c4mr57687ejc.59.1666175991850; Wed, 19 Oct 2022 03:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666175991; cv=none; d=google.com; s=arc-20160816; b=EOtAWm2cXmVQsVpa+PQvBS061o+x6efmhrrje7g5PSeuXQfS7NGu0qf5Uhpkkhz0Bn 701Znt+Xhktg39vyNnuoXD19O2jiRuFbIfsbMxpd6EKnn75BH12qCDyDui4JnwSg5mXy jqBKC6VI9LVJ48dPrqfdJ7ZQOFtTJlr9m70vLC+mkTNl0btqIUrhOFhAsIsGxvDUqqNn cBBuA9BdYhdXoZGyf8AVxE/fCe6cwcfg7lk4Ohalay0BxU3L+0ztsEatogIWB3cnZz5q ZJH/tKDJqsbJYQ6cttG5613b0wq6otQjBMxvwwAGJH9NmUJe0CIbT6gPt3QO5KfPI3fG aUtg== 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=yq4iV0RmamdtS+bAKzqVn+fZOy6Cp+dfvWLREcFnuoc=; b=vQvJG40w5xxb5kacOIuItpUqQwC0wo6EfszVwKIY7IsArtpqVMEoFlRe2qyGjjPL2u tdSX5uJTUgnXF0t7G4Ib6sb1pdnyxdK+CHa4A9eMUqf6/rblW4C3i3T/VT4Yyhumy6H1 luJyamD8FVb707CK6PlkntyfyWVxkuLw9/ziRsL9R9tkzidmuUf1OsQX/n1vLgZxEFaJ rQ5/cYzkK0zC+Fve7AR5PJ+a1v7PClVX4hzSch4LFVPNUgbcPMY0NzBV0usO8JpAQ4kH 8Jv3vDvBXyhd92TYpYSSasb55ORUEhXOfKJH1CIQniL7On7l759cr5hpX64hOaqUVUAl jt8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mRTqgi9z; 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 e3-20020a17090658c300b00730936657d1si14724006ejs.552.2022.10.19.03.39.25; Wed, 19 Oct 2022 03:39:51 -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=mRTqgi9z; 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 S231767AbiJSKhV (ORCPT + 99 others); Wed, 19 Oct 2022 06:37:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231510AbiJSKgp (ORCPT ); Wed, 19 Oct 2022 06:36:45 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 207D32DAAC; Wed, 19 Oct 2022 03:15:48 -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 sin.source.kernel.org (Postfix) with ESMTPS id 8987FCE20F8; Wed, 19 Oct 2022 09:15:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6B44C433C1; Wed, 19 Oct 2022 09:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170940; bh=MkIi4jrqmZHmgC/zrV72MkjhZQBFd9b63fKVqNoJHcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mRTqgi9zVuPXXuoCgdCdLQZpK72VcrAwJGYGea9HwBx5fUYw/pKyuja+E9WixwZyb HMpwCKgsXeDHfiWBJ5TpkTouOKuSXM6q8bqJbeVUc+ziwY24UthZTXMyZnKskXhh6p 1NzClprVuDFA3wQoXWFy+SnDhM90L289KniPIsYk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Pavel Begunkov , Jens Axboe Subject: [PATCH 6.0 844/862] io_uring/net: dont lose partial send_zc on fail Date: Wed, 19 Oct 2022 10:35:31 +0200 Message-Id: <20221019083327.183139680@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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: Pavel Begunkov [ upstream commit 5693bcce892d7b8b15a7a92b011d3d40a023b53c ] Partial zc send may end up in io_req_complete_failed(), which not only would return invalid result but also mask out the notification leading to lifetime issues. Cc: stable@vger.kernel.org Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/5673285b5e83e6ceca323727b4ddaa584b5cc91e.1663668091.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/net.c | 16 ++++++++++++++++ io_uring/net.h | 1 + io_uring/opdef.c | 1 + 3 files changed, 18 insertions(+) --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1093,6 +1093,22 @@ void io_sendrecv_fail(struct io_kiocb *r io_req_set_res(req, res, req->cqe.flags); } +void io_send_zc_fail(struct io_kiocb *req) +{ + struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg); + int res = req->cqe.res; + + if (req->flags & REQ_F_PARTIAL_IO) { + if (req->flags & REQ_F_NEED_CLEANUP) { + io_notif_flush(sr->notif); + sr->notif = NULL; + req->flags &= ~REQ_F_NEED_CLEANUP; + } + res = 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 = io_kiocb_to_cmd(req, struct io_accept); --- a/io_uring/net.h +++ b/io_uring/net.h @@ -58,6 +58,7 @@ int io_connect(struct io_kiocb *req, uns int io_sendzc(struct io_kiocb *req, unsigned int issue_flags); int io_sendzc_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe); void io_sendzc_cleanup(struct io_kiocb *req); +void io_send_zc_fail(struct io_kiocb *req); void io_netmsg_cache_free(struct io_cache_entry *entry); #else --- a/io_uring/opdef.c +++ b/io_uring/opdef.c @@ -494,6 +494,7 @@ const struct io_op_def io_op_defs[] = { .issue = io_sendzc, .prep_async = io_sendzc_prep_async, .cleanup = io_sendzc_cleanup, + .fail = io_send_zc_fail, #else .prep = io_eopnotsupp_prep, #endif