Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4061202iog; Tue, 28 Jun 2022 08:14:15 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tIFyLpMgG2J28OwyJ5LWyNLEUVnwkRm7JZMUxYnmIvPTColysm1i49caGef+4zJwuhUnGH X-Received: by 2002:a17:90a:ca8b:b0:1ec:9afb:1a2d with SMTP id y11-20020a17090aca8b00b001ec9afb1a2dmr66152pjt.225.1656429254918; Tue, 28 Jun 2022 08:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656429254; cv=none; d=google.com; s=arc-20160816; b=zoqi461/W+np6rq+8k3zwlBsowyfrXk98J6ivFMLti6Uo5J+xbkdPiWEmXcm5Fy2Pm 6JikjU1Y8phHi1jz9XhCES8r/bomfvviPkpl1DwoU/Fm05attYOe4Oee0VLWURQfWXY8 Drd0tUy2OQfIt8y08wUg8hPJeUrRWUMYFY1aond9mI1NtwpQEIbkQi07GdAYlmDE9nZt X24N6lycfqQGTnAE/Is2qlztAGWFeQbA1j/TjKue50dasSbaQaGMkb38ajxEoDeFRKw2 JUoWYTE/AZcLWjjVb2vGVJzArkq15O6PmY+5BNtRXXygeLLAYtmvmdLi9Etr4DKug+n0 DrVQ== 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=/R5f40SX0myY+sLsV9T01ncFIwUnVx4ToYywqLxN6Ws=; b=ILe57+W6fKIAyJLeGDI5doMR7c8h7UuKHE187hKcoNGxlsZ4wpRkYJh5kXFJPfzdnd Am+wQyhyYZ4vEP65iU5SboJ4m+maB45YmnvTHvsYFZBsd76KyI6aGh/fJMqoOKP5j2Tl XXs4PbFmrNiWtJy2WW8rb2lbwp/095NkcCsj5ZE3lZJe5yTdyxBvVhDQJ+j2vXagEd7g Jo6DPTKC5SZlkahChmT+Thf2byHUvlxXG2D6t+Z8k0kOlzwyBvkBCv6FpZB63n2BJvya wH/rAcGYnQ7jCRyr0hPoGRrFEmL4zdKdpZiPfXxsD+A9MqrkIiYh6LuxDynDEW3o+n94 Y4fQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=nAmkmqYc; 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 h14-20020a170902ac8e00b00163eff0e71esi18146351plr.572.2022.06.28.08.13.54; Tue, 28 Jun 2022 08:14:14 -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=nAmkmqYc; 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 S1347671AbiF1PCs (ORCPT + 99 others); Tue, 28 Jun 2022 11:02:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347631AbiF1PCq (ORCPT ); Tue, 28 Jun 2022 11:02:46 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4053D33E3B for ; Tue, 28 Jun 2022 08:02:46 -0700 (PDT) Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25SBFqAN023892 for ; Tue, 28 Jun 2022 08:02:46 -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=/R5f40SX0myY+sLsV9T01ncFIwUnVx4ToYywqLxN6Ws=; b=nAmkmqYcEnu6uf8RChzrghN6IZgh+xpBiH/buD1YNVUMEa+yV/kZt21audq0wyzLI2Wa SA0G56fqKIuuDXji0ryQ8f3qg9zbr/mdZr9IhIXKNRj+Nuvsd16DBJ1u/9TDwlbUxlzZ Zs0yocp8KDIYQ6MXftU0nA52/ZvaUbkzA1Y= Received: from mail.thefacebook.com ([163.114.132.120]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3h00m4hcef-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 28 Jun 2022 08:02:45 -0700 Received: from twshared25107.07.ash9.facebook.com (2620:10d:c085:208::11) by mail.thefacebook.com (2620:10d:c085:21d::5) 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:44 -0700 Received: by devbig038.lla2.facebook.com (Postfix, from userid 572232) id 95F71244BBC5; Tue, 28 Jun 2022 08:02:37 -0700 (PDT) From: Dylan Yudaken To: Jens Axboe , Pavel Begunkov , CC: , , Dylan Yudaken Subject: [PATCH for-next 1/8] io_uring: allow 0 length for buffer select Date: Tue, 28 Jun 2022 08:02:21 -0700 Message-ID: <20220628150228.1379645-2-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: nCYkD1oo6UivWb4TbMBbILC_jGyXCyjH X-Proofpoint-GUID: nCYkD1oo6UivWb4TbMBbILC_jGyXCyjH 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 If user gives 0 for length, we can set it from the available buffer size. Signed-off-by: Dylan Yudaken --- io_uring/kbuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c index 8e4f1e8aaf4a..4ed5102461bf 100644 --- a/io_uring/kbuf.c +++ b/io_uring/kbuf.c @@ -115,7 +115,7 @@ static void __user *io_provided_buffer_select(struct = io_kiocb *req, size_t *len, =20 kbuf =3D list_first_entry(&bl->buf_list, struct io_buffer, list); list_del(&kbuf->list); - if (*len > kbuf->len) + if (*len =3D=3D 0 || *len > kbuf->len) *len =3D kbuf->len; req->flags |=3D REQ_F_BUFFER_SELECTED; req->kbuf =3D kbuf; @@ -145,7 +145,7 @@ static void __user *io_ring_buffer_select(struct io_k= iocb *req, size_t *len, buf =3D page_address(bl->buf_pages[index]); buf +=3D off; } - if (*len > buf->len) + if (*len =3D=3D 0 || *len > buf->len) *len =3D buf->len; req->flags |=3D REQ_F_BUFFER_RING; req->buf_list =3D bl; --=20 2.30.2