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 X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D442C43216 for ; Thu, 29 Jul 2021 15:06:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75C4960EE6 for ; Thu, 29 Jul 2021 15:06:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237640AbhG2PGi (ORCPT ); Thu, 29 Jul 2021 11:06:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237703AbhG2PGh (ORCPT ); Thu, 29 Jul 2021 11:06:37 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C2B6C061765 for ; Thu, 29 Jul 2021 08:06:34 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id b7so7357079wri.8 for ; Thu, 29 Jul 2021 08:06:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=WZUSbbOF/FC2ouOE0MYWtzocErTrVoLjBs5Nsshkk3Y=; b=ZuytFk5/e52EBdDu4H7O95qXZnIwnNs8oos+cWZcvM5ma/gADe+l1w7zb6oCnBxiVh gHs/7p4Ta3vPtswrgYti83qBF1bXgFTEcZ+unMtQZxywgWuFv9wwHbdX3zXDa90Qy5uS m/tMzMF939PXkF8YglFHFsDVj/SWvc/nzUnVd2O+qKqJMfsYyXQi2e6Hm//GzxcYrZa6 ydzPyQqxy+2V4v6twU4MDrUraoFtIgZdNSOisD7Dt8jXpNtwe7t1ReY2olxzAcJG3ZdN 0sEdBNi4jPTs9QlhVC/PtCdfI1Zdz/Vsx4UAeEgkOgwS46mJSz/YlAS2nxwWX/5T1JjE lnzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WZUSbbOF/FC2ouOE0MYWtzocErTrVoLjBs5Nsshkk3Y=; b=mBU1Sgi0W27uKhaktNqS0UbCRpBZGrkZiA6eAGVovvslae51uoQ6yjA6r25L8ewCc8 8WmpcAE7Ttl73+dKLyFHMuPzR16o7Tdc5eZJMFRwhescMf3cK1RfQ9c+p3XMV3+UAnfQ eW7auHvbasounSoS4iC515Fv7I3VSUiwMq/cF2IRPE0Hcbq9MRP8qFt27e3t1biEhMzL 6JS5YoJqbeOmOGRG0S9Dk9AxzhtQGmMJ/CKyf25J1t7Ao28VhDuGY36Zj8Bb53EKXxoB IPO7OBnR+hCOxRDYWLdHGJPudzmKnPUe3hkneX9VjQlM/axNYQLhen+0NM6F4/W2rhEt 0HUw== X-Gm-Message-State: AOAM532CVnHAnggdwS74FkboT85saH2jiKBae6xABmPn98uE5hnoJNPv mrMpnKRYLS8rA09qJuZ/vaY= X-Google-Smtp-Source: ABdhPJwzwuooZrKzT9YZZpEHbX4MWP2Qe1NzIybPsqNzhtkDYtD+slziTNfgEOkBRCaefeRs8MTAog== X-Received: by 2002:a05:6000:10c6:: with SMTP id b6mr5512718wrx.110.1627571192936; Thu, 29 Jul 2021 08:06:32 -0700 (PDT) Received: from localhost.localdomain ([148.252.128.141]) by smtp.gmail.com with ESMTPSA id e6sm4764577wrg.18.2021.07.29.08.06.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 08:06:32 -0700 (PDT) From: Pavel Begunkov To: Jens Axboe , io-uring@vger.kernel.org Subject: [PATCH 11/23] io_uring: deduplicate open iopoll check Date: Thu, 29 Jul 2021 16:05:38 +0100 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org Move IORING_SETUP_IOPOLL check into __io_openat_prep(), so both openat and openat2 reuse it. Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 04b78b449e9d..2ee5ba115cfc 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3774,6 +3774,8 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe const char __user *fname; int ret; + if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) + return -EINVAL; if (unlikely(sqe->ioprio || sqe->buf_index)) return -EINVAL; if (unlikely(req->flags & REQ_F_FIXED_FILE)) @@ -3798,12 +3800,9 @@ static int __io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { - u64 flags, mode; + u64 mode = READ_ONCE(sqe->len); + u64 flags = READ_ONCE(sqe->open_flags); - if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) - return -EINVAL; - mode = READ_ONCE(sqe->len); - flags = READ_ONCE(sqe->open_flags); req->open.how = build_open_how(flags, mode); return __io_openat_prep(req, sqe); } @@ -3814,8 +3813,6 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) size_t len; int ret; - if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) - return -EINVAL; how = u64_to_user_ptr(READ_ONCE(sqe->addr2)); len = READ_ONCE(sqe->len); if (len < OPEN_HOW_SIZE_VER0) -- 2.32.0