From mboxrd@z Thu Jan 1 00:00:00 1970 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 498DCC6FD1D for ; Mon, 20 Mar 2023 15:36:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233018AbjCTPgl (ORCPT ); Mon, 20 Mar 2023 11:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233037AbjCTPgQ (ORCPT ); Mon, 20 Mar 2023 11:36:16 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B472E37B76 for ; Mon, 20 Mar 2023 08:28:21 -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 16D4BB80EC5 for ; Mon, 20 Mar 2023 15:28:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6699CC433EF; Mon, 20 Mar 2023 15:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1679326090; bh=XEIL89TGnfcFjyp706sAMEL4q4pULuaGN8w/nvuROlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bHewd3RF53WRe4+A7TOeFlrSs5DiG+q80xYxZmmrwTqaIip5vhrmgt+NNph27qe6m gngbmnPpL/WjLYWwkZUMPXQk8/u2CTpTnG4+6i62gGePHC8wi2rcXg8hdojNhY/oal 60UoSapuBy+S0ceXJHYe5nv3jlOJQjKnM2SlLh2Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Pavel Begunkov , Jens Axboe Subject: [PATCH 6.1 198/198] io_uring/msg_ring: let target know allocated index Date: Mon, 20 Mar 2023 15:55:36 +0100 Message-Id: <20230320145515.762603682@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230320145507.420176832@linuxfoundation.org> References: <20230320145507.420176832@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Pavel Begunkov commit 5da28edd7bd5518f97175ecea77615bb729a7a28 upstream. msg_ring requests transferring files support auto index selection via IORING_FILE_INDEX_ALLOC, however they don't return the selected index to the target ring and there is no other good way for the userspace to know where is the receieved file. Return the index for allocated slots and 0 otherwise, which is consistent with other fixed file installing requests. Cc: stable@vger.kernel.org # v6.0+ Fixes: e6130eba8a848 ("io_uring: add support for passing fixed file descriptors") Signed-off-by: Pavel Begunkov Link: https://github.com/axboe/liburing/issues/809 Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/msg_ring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/io_uring/msg_ring.c +++ b/io_uring/msg_ring.c @@ -84,6 +84,8 @@ static int io_msg_send_fd(struct io_kioc struct file *src_file; int ret; + if (msg->len) + return -EINVAL; if (target_ctx == ctx) return -EINVAL; if (target_ctx->flags & IORING_SETUP_R_DISABLED) @@ -120,7 +122,7 @@ static int io_msg_send_fd(struct io_kioc * completes with -EOVERFLOW, then the sender must ensure that a * later IORING_OP_MSG_RING delivers the message. */ - if (!io_post_aux_cqe(target_ctx, msg->user_data, msg->len, 0, true)) + if (!io_post_aux_cqe(target_ctx, msg->user_data, ret, 0, true)) ret = -EOVERFLOW; out_unlock: io_double_unlock_ctx(ctx, target_ctx, issue_flags);