Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp397807iog; Thu, 30 Jun 2022 03:01:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tw/RmrCds2P0GPn4euZsUz4b9VlIg4DufMx4hfxQ9e5cGkZRtzTv11Tqt4PJUNL4W4ZOzO X-Received: by 2002:a63:6984:0:b0:40d:9ebe:5733 with SMTP id e126-20020a636984000000b0040d9ebe5733mr7043422pgc.170.1656583267863; Thu, 30 Jun 2022 03:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656583267; cv=none; d=google.com; s=arc-20160816; b=WtSiqvSJufmYLHFZVYK3hx/DlB583iyjbyp+T349hEpWqDZuG7jE4r0RsBtvLgQT4o 8IN0wthrcuARW72I8OEqvxPVDaUmd269pBb86bE3h5y6F8EiiGYgoCMA6cCkvPGVr29k mWbGS4UBXbdOxn7k6767qC8SI9Sn86fm1bEzv/FJnEQGSsWzIodq75jAji/2Q5bCPL4o ndnc3utYhj+kCBdwvpREN0zFbz9J0TKDVSxeQ8PG+vcFj3tmRAvLfFwvITEzr5jkIsHp qmmas/AX9Z7tUGi7TejU0SA1IfMlhy1WwSM08t46HQQY8xDXwuIcDgsnJaeQZ4uO6u6P lkaw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yNGWca9EZYptSu02EU61qEdS1WccUVHJPmvgfuLJvJI=; b=cgEkSLqzesg3QXGgAR538o2ychvruX0rs0fEYjYomBh9Kq33c0J1+e1xMGmCaHPjRV M7brme/QHhSrx4xQSQnNvHug8nGS5/RK5uh8xPwouBHaakk2kN6aWdeK72VHpmyGJ+vo 4BfELAjwgqyIqO8oWoRzohMiKzrN5EjvIiG4vReyaNO6Ma9YGRCwZIXgU2aBtFIyUBG3 7nDyZAiq8VpvtSXWPB7E+5/aKBEEwtTKXTuj/BLXIBJs00d/88Xet+05H+tu1uN+zdNC DI+8SyPVZ5xE6NIucBKtCYM+AP9MMo1Ge4uOf40QoyGhHurrwsJB19OGFsNLnS7/cO5O JPcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=TSljtTkc; 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=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f19-20020a17090aa79300b001ecbb77d9ebsi2187733pjq.16.2022.06.30.03.00.56; Thu, 30 Jun 2022 03:01:07 -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=@fb.com header.s=facebook header.b=TSljtTkc; 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=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233930AbiF3JSw (ORCPT + 99 others); Thu, 30 Jun 2022 05:18:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233757AbiF3JSO (ORCPT ); Thu, 30 Jun 2022 05:18:14 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13D492F021 for ; Thu, 30 Jun 2022 02:17:05 -0700 (PDT) Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25U0LXXi011939 for ; Thu, 30 Jun 2022 02:17:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=yNGWca9EZYptSu02EU61qEdS1WccUVHJPmvgfuLJvJI=; b=TSljtTkcvad2N/d3wiu+TNZNeKjk30v9g/O3LSbXK7QugXgu9b7nqgrlSlTP4DWmfbMJ 4a7DoE9qmq34HqR54x68n3JEQvJy6pQ7obYj9yoeIzVcq4b2KCzSNG3NbpLz/XtF/pgj v8m3HyGuFn6MNT7qWGwnGEnRedL62Gfkadw= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3h0rk5wwxr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 30 Jun 2022 02:17:04 -0700 Received: from twshared5640.09.ash9.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:21d::4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 30 Jun 2022 02:17:03 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 9A2E82599FD2; Thu, 30 Jun 2022 02:14:08 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , , Dylan Yudaken Subject: [PATCH v2 for-next 03/12] io_uring: allow iov_len = 0 for recvmsg and buffer select Date: Thu, 30 Jun 2022 02:12:22 -0700 Message-ID: <20220630091231.1456789-4-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630091231.1456789-1-dylany@fb.com> References: <20220630091231.1456789-1-dylany@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: 31uqydv_zjwpNQMbXoBh7abUl9Ux8gAj X-Proofpoint-GUID: 31uqydv_zjwpNQMbXoBh7abUl9Ux8gAj X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-30_05,2022-06-28_01,2022-06-22_01 X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, 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 When using BUFFER_SELECT there is no technical requirement that the user actually provides iov, and this removes one copy_from_user call. So allow iov_len to be 0. Signed-off-by: Dylan Yudaken --- io_uring/net.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/io_uring/net.c b/io_uring/net.c index 19a805c3814c..5e84f7ab92a3 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -300,12 +300,18 @@ static int __io_recvmsg_copy_hdr(struct io_kiocb *r= eq, return ret; =20 if (req->flags & REQ_F_BUFFER_SELECT) { - if (iov_len > 1) + if (iov_len =3D=3D 0) { + sr->len =3D iomsg->fast_iov[0].iov_len =3D 0; + iomsg->fast_iov[0].iov_base =3D NULL; + iomsg->free_iov =3D NULL; + } else if (iov_len > 1) { return -EINVAL; - if (copy_from_user(iomsg->fast_iov, uiov, sizeof(*uiov))) - return -EFAULT; - sr->len =3D iomsg->fast_iov[0].iov_len; - iomsg->free_iov =3D NULL; + } else { + if (copy_from_user(iomsg->fast_iov, uiov, sizeof(*uiov))) + return -EFAULT; + sr->len =3D iomsg->fast_iov[0].iov_len; + iomsg->free_iov =3D NULL; + } } else { iomsg->free_iov =3D iomsg->fast_iov; ret =3D __import_iovec(READ, uiov, iov_len, UIO_FASTIOV, --=20 2.30.2