Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4092550iog; Tue, 28 Jun 2022 08:49:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t7mQpalEe1jON0N+KkXnQncYTOatL37900LhlbIw+OfD+1sm5Vf+n7JSHsZKOE5V+4kTT7 X-Received: by 2002:a62:d150:0:b0:525:84b6:9a18 with SMTP id t16-20020a62d150000000b0052584b69a18mr4192606pfl.42.1656431391698; Tue, 28 Jun 2022 08:49:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656431391; cv=none; d=google.com; s=arc-20160816; b=P1Sm8sbSgjlo7o4ciqF1b8DABCD1U4LgEJMnvIGKiT7KwDI/OlGGmUQqffl52x2DF3 7A9+oCRppV0TRF+jMdO5ZNJQWPNH+ctp03f9bOvVUTKjfIczdStawRfCmE6WdOjD3Jlv xFWEaKhNOrcstPCymlgpE1RLLJshA2kpYeY82Y1khCa3x6Mr4WHg8mYLTAXhYwFLMiVg GfI+y6wDRZ4ux8WggRvOoE35sQQDrET6MG1NBLp2kxqXlkrfCE/UUYOJ3vy6nHegt09R SzH/pLNnoyYzpHtmxQTb41GLdIm3SrIg7yKRogMRJ8/pNKusQf+OpQle2+Zi7bYNN67S IHAg== 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=nf47te++RAtypuqy/POfad/8Kqgt3L2xbPju8mS4Uu5kK49N39q5TtTd32Vwt8EU13 lu2Zjgxz6r3CvtOo1B0BPJ32dKnxe9rSTmDfAcSrlrZ5j5fslo09haQXDGiBBJWV59qe RYLWIfX0qO8AdpMEL1y+y9UMpMv+wDGNAFBrRxrzosbn2fhhqfcDXGHctPbmTHJ24k2i cj2ma6N10ScvumROj40RMCuoPEpOR69SPzMTe0hrmYjV5ZiCzO2c8Y2DWFDhlQ+gsEJ7 I7DoNbobGawfl4JnsQFEmUL39CodxgyCym5WAB3ZQAmyZ3suL9IYKQK7YvtmZnLvt204 LDFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=PT5C3RKF; 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 l62-20020a639141000000b0040dad0a8e65si14707251pge.509.2022.06.28.08.49.39; Tue, 28 Jun 2022 08:49: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=@fb.com header.s=facebook header.b=PT5C3RKF; 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 S1347735AbiF1PDO (ORCPT + 99 others); Tue, 28 Jun 2022 11:03:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347706AbiF1PDA (ORCPT ); Tue, 28 Jun 2022 11:03:00 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACE7F33E9F for ; Tue, 28 Jun 2022 08:02:59 -0700 (PDT) Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 25SEooR7009892 for ; Tue, 28 Jun 2022 08:02:59 -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=PT5C3RKF+bqqbTqcVYEy+XGiQto7YKGGtENqdyg9k/8eyAl4PcD5o1GLCI3d0bcHEiGn 2S4V14Zj70GmXEVnnKDXoePpJF1hxiaC41MDdzd+urLPeHgpg9mdocvLyPYhFJ2SKQtY RmiV/ABNzw4ABTJ42O156r6IXbKSk8MzWYI= Received: from mail.thefacebook.com ([163.114.132.120]) by m0001303.ppops.net (PPS) with ESMTPS id 3h03ru0386-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 28 Jun 2022 08:02:58 -0700 Received: from twshared25107.07.ash9.facebook.com (2620:10d:c085:208::f) by mail.thefacebook.com (2620:10d:c085:11d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Tue, 28 Jun 2022 08:02:55 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id DAC6E244BBD1; Tue, 28 Jun 2022 08:02:37 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , , Dylan Yudaken Subject: [PATCH for-next 3/8] io_uring: allow iov_len = 0 for recvmsg and buffer select Date: Tue, 28 Jun 2022 08:02:23 -0700 Message-ID: <20220628150228.1379645-4-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220628150228.1379645-1-dylany@fb.com> References: <20220628150228.1379645-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: J7gRIa8TQKOnCR6iuT1FTFS2UemQJt_p X-Proofpoint-GUID: J7gRIa8TQKOnCR6iuT1FTFS2UemQJt_p 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-28_08,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