Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp815331pxb; Tue, 12 Apr 2022 14:13:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw02zs1LMYTze4bEbEWb4AMdi6/MzIzVEPgSut46Tw4hVebwt4/xpURQKWdz15xErrTn15p X-Received: by 2002:a63:2113:0:b0:399:2df0:ff07 with SMTP id h19-20020a632113000000b003992df0ff07mr31530065pgh.374.1649797984426; Tue, 12 Apr 2022 14:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649797984; cv=none; d=google.com; s=arc-20160816; b=lSbdCF665bpSM15LEojsuzJgKWBqUqC7k5P7dN1ra1k+diqQWFxNZO1PLcHOQAmWDX JIkb3LG9sYb3aR+IM0AWHzNEwF99WWriBsVTCuym5nZ9oGGCq5W99WWwPfqSzn8WAExo G935Y/+U6NdklmZ+ef9aSkU67WlmrWvhorKRz3CqV0oFne68KhUMeeUSGax+jam8WU9v a5yROvzMUhuoZy4/9vFa0DOFAj4vXCZoC2dRVqt9RvgvK7zxtN04p+Hz02HkESfbJ5Zu WhOOvB7CZG+1jfgtv972QnNOseWSNdCgdU/BHlm7vlPEoEilUFUHM6ISs0kLQ5foQ6Zc TdjA== 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=/xid/OpYx6XCeq/M4GKH/83yAYcqpeMppbcM1h1pC9A=; b=g7AG5dys+/wSmi3DucKhLWcbUfcj9sYys7zquWEXHDAhuXZdKkS/y7EprZqr4rb4Ws Fmv4R0Q/wHnNoGQKep2EcSfDjCVjJHaGl4iT1TAcjQPUinz7LLht/rQ5cPjbIQaIfgnc eVorViGzpgF0HT9xezhPGdLy/TAAo0RdY9q12v3YgCG3rymitWtgch7yRP5ehbccsmJ3 Msla/HqcsnK57LI+ViDwJ7NQuP9b4JgBMWDeueMKUVqLyZ7m/ZNdCIeOMBYW2XKe1EMv wnvkh8RlJHNY4VcUlzLTi+oHgDpwKajoYGV73hDDA3UUdoT5RO+6Bn9PkDbrMGvA5FYg 2wyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=dXr07BQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s142-20020a632c94000000b003816043f16fsi3787242pgs.868.2022.04.12.14.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 14:13:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=dXr07BQT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0B697E9979; Tue, 12 Apr 2022 13:28:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232531AbiDLQdj (ORCPT + 99 others); Tue, 12 Apr 2022 12:33:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357679AbiDLQd2 (ORCPT ); Tue, 12 Apr 2022 12:33:28 -0400 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E5105DE7F for ; Tue, 12 Apr 2022 09:31:00 -0700 (PDT) Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 23C0jrtJ032695 for ; Tue, 12 Apr 2022 09:31:00 -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=/xid/OpYx6XCeq/M4GKH/83yAYcqpeMppbcM1h1pC9A=; b=dXr07BQTNyBfiETeamRqkqnDYW/klgyTd7oLea0vjuEwKXNTTSMFlnPE2vP7dDwTqPJq WDE4a3R4OiM/fHOx3iHGWemGNKTQYnCEM9cr8oCRif4PCzsJT5Tej0qTUXQz01iJJrjm YgVIjnOd5rYrSzJaCopGwBuVuEtHQajhbZI= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3fcy5qv47u-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 12 Apr 2022 09:31:00 -0700 Received: from twshared41237.03.ash8.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::d) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Tue, 12 Apr 2022 09:30:58 -0700 Received: by devbig039.lla1.facebook.com (Postfix, from userid 572232) id 97FA07456064; Tue, 12 Apr 2022 09:30:47 -0700 (PDT) From: Dylan Yudaken To: CC: , , , , Dylan Yudaken Subject: [PATCH 1/4] io_uring: move io_uring_rsrc_update2 validation Date: Tue, 12 Apr 2022 09:30:39 -0700 Message-ID: <20220412163042.2788062-2-dylany@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220412163042.2788062-1-dylany@fb.com> References: <20220412163042.2788062-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: _UgUXIRDRhPiN_Z7ASiWaaonoD04hPtH X-Proofpoint-GUID: _UgUXIRDRhPiN_Z7ASiWaaonoD04hPtH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-12_06,2022-04-12_02,2022-02-23_01 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Move validation to be more consistently straight after copy_from_user. This is already done in io_register_rsrc_update and so this removes that redundant check. Signed-off-by: Dylan Yudaken --- fs/io_uring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 8a931eb8a3a6..58bfa71fe3b6 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -11398,8 +11398,6 @@ static int __io_register_rsrc_update(struct io_ri= ng_ctx *ctx, unsigned type, __u32 tmp; int err; =20 - if (up->resv) - return -EINVAL; if (check_add_overflow(up->offset, nr_args, &tmp)) return -EOVERFLOW; err =3D io_rsrc_node_switch_start(ctx); @@ -11425,6 +11423,8 @@ static int io_register_files_update(struct io_rin= g_ctx *ctx, void __user *arg, memset(&up, 0, sizeof(up)); if (copy_from_user(&up, arg, sizeof(struct io_uring_rsrc_update))) return -EFAULT; + if (up.resv) + return -EINVAL; return __io_register_rsrc_update(ctx, IORING_RSRC_FILE, &up, nr_args); } =20 --=20 2.30.2