Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1391108ybj; Thu, 7 May 2020 23:42:39 -0700 (PDT) X-Google-Smtp-Source: APiQypITlTC74xTBjdWFoSyYqAVG12LC+HzEzhtQZa1VY3zX4krwqyn5osz7IpzleDPnF6EBccN8 X-Received: by 2002:a17:906:340a:: with SMTP id c10mr652319ejb.218.1588920159007; Thu, 07 May 2020 23:42:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588920158; cv=none; d=google.com; s=arc-20160816; b=Wx6jYnUmPBhzttye4oY4n3Vlhxin5Vpyka4AIOnhecMipj6utTKBvUK7kTz+f9dkOL hDUhB8EuAKM/TgVdBOEGAsNG8nh/jXtV3SuTDFC7+KcO0z327WIAM7MDUkXb5/ylEUE0 KOZ74yXGwbd4SZuhcTIGwesw8unVKt2oloWI4rAdA5XhdGhOuGKSrxe77VV3z8XlaOUe nz3dx2DLW9aW4WzpVp93CL/xvO32w781ZiqLsIeJ5cyPxm5lGMDryyaDFrR5l7tMuB+X 7LwxPugUZunuD/feipZpqh5KsH7qcP6xJiHDFHV9rKrp2CtfcO++BycLStMfkXeHAiNm v1bA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=MJ21v6P7KfptiwWt2W7IK6GlbXMwiyNzEJ5mamY4QmU=; b=eFuQ2Ht8cM27Y77OrlKLdYyNov+DQXKbOvDX9D1rTvn/FRgTCHW2yNOIJ85nTxJXp9 RYEiT1IoCy7Nj3evev4uuJNpsgpR/PrLZf9xZx2KV1adK/8BTte2cMinVJn8ODnUQlws yDyfYvUO559N8VfyDa6m+CAfru5r15tPQ67UUFLWYysM8peb0famWhI2CvOoT8yAY3Cz OkggO2TGHSvKNUl8l4kpsx40tDkt+8r0vpCON5eof4ZnqA5SE6W9crF6LMP7h1iP4WII C7nU+TSF/iU3ZNiTgaDKrFaC2rPBBgFx4OWThZ2HbA0Rcfjpn3ThLdXSuzNYQ7CVhH58 o2VA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cn25si385115edb.589.2020.05.07.23.42.16; Thu, 07 May 2020 23:42:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726930AbgEHGi4 (ORCPT + 99 others); Fri, 8 May 2020 02:38:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726863AbgEHGiz (ORCPT ); Fri, 8 May 2020 02:38:55 -0400 Received: from nibbler.cm4all.net (nibbler.cm4all.net [IPv6:2001:8d8:970:e500:82:165:145:151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CFE3C05BD09 for ; Thu, 7 May 2020 23:38:55 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by nibbler.cm4all.net (Postfix) with ESMTP id 485C3C02C8 for ; Fri, 8 May 2020 08:38:54 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at nibbler.cm4all.net Received: from nibbler.cm4all.net ([127.0.0.1]) by localhost (nibbler.cm4all.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id ye1n85vqRHGG for ; Fri, 8 May 2020 08:38:54 +0200 (CEST) Received: from zero.intern.cm-ag (zero.intern.cm-ag [172.30.16.10]) by nibbler.cm4all.net (Postfix) with SMTP id 25483C028D for ; Fri, 8 May 2020 08:38:54 +0200 (CEST) Received: (qmail 3876 invoked from network); 8 May 2020 09:55:13 +0200 Received: from unknown (HELO rabbit.intern.cm-ag) (172.30.3.1) by zero.intern.cm-ag with SMTP; 8 May 2020 09:55:13 +0200 Received: by rabbit.intern.cm-ag (Postfix, from userid 1023) id E9824461450; Fri, 8 May 2020 08:38:53 +0200 (CEST) From: Max Kellermann To: axboe@kernel.dk, linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Max Kellermann , stable@vger.kernel.org Subject: [PATCH v2 1/2] fs/io_uring: fix O_PATH fds in openat, openat2, statx Date: Fri, 8 May 2020 08:38:45 +0200 Message-Id: <20200508063846.21067-1-mk@cm4all.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an operation's flag `needs_file` is set, the function io_req_set_file() calls io_file_get() to obtain a `struct file*`. This fails for `O_PATH` file descriptors, because io_file_get() calls fget(), which rejects `O_PATH` file descriptors. To support `O_PATH`, fdget_raw() must be used (like path_init() in `fs/namei.c` does). This rejection causes io_req_set_file() to throw `-EBADF`. This breaks the operations `openat`, `openat2` and `statx`, where `O_PATH` file descriptors are commonly used. This could be solved by adding support for `O_PATH` file descriptors with another `io_op_def` flag, but since those three operations don't need the `struct file*` but operate directly on the numeric file descriptors, the best solution here is to simply remove `needs_file` (and the accompanying flag `fd_non_reg`). Signed-off-by: Max Kellermann Cc: stable@vger.kernel.org --- fs/io_uring.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index a46de2cfc28e..d24f8e33323c 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -693,8 +693,6 @@ static const struct io_op_def io_op_defs[] = { .needs_file = 1, }, [IORING_OP_OPENAT] = { - .needs_file = 1, - .fd_non_neg = 1, .file_table = 1, .needs_fs = 1, }, @@ -708,8 +706,6 @@ static const struct io_op_def io_op_defs[] = { }, [IORING_OP_STATX] = { .needs_mm = 1, - .needs_file = 1, - .fd_non_neg = 1, .needs_fs = 1, }, [IORING_OP_READ] = { @@ -739,8 +735,6 @@ static const struct io_op_def io_op_defs[] = { .unbound_nonreg_file = 1, }, [IORING_OP_OPENAT2] = { - .needs_file = 1, - .fd_non_neg = 1, .file_table = 1, .needs_fs = 1, }, -- 2.20.1