Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp982583ybj; Thu, 7 May 2020 11:59:37 -0700 (PDT) X-Google-Smtp-Source: APiQypKVJOTyEakhF9KNP8YYQCd+eb+pVXW8EAiqOZHiNY8mz8KbYun026FDs2n3PjmhbzeV7kNt X-Received: by 2002:a50:a883:: with SMTP id k3mr13180640edc.198.1588877977793; Thu, 07 May 2020 11:59:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588877977; cv=none; d=google.com; s=arc-20160816; b=FCUR3oG1UyevgQtSppp0p4UlTvxJ5CdYbvRi6Knj5Zbjn7ocp0DpMniVCUces0p6KN MJ44dAy7vbf+PFWxtRCoULatj4o7dmG66vDRMB/oSWolMU7NGZimAaguqGPSdQNjr3Hv C2gtlU7JSN4y6xfLc2r2FRcVHtLr9w/CoXyEA49oxY6D6eKHpdXwkpEJK9s7nLmiCuoI iTEoAnGd+vgJvgKN7jjvEXgKOCC6cpN+HOSdt4Mlm3OwVTLOrqZ/JLjnToEzOdmVye0u iSSxjepHKxeUF9wd8ke8WVKg2o72p/Fc/H0smfCkozRu1QY3LInwE0o5D7oBfojwCCZs AYzw== 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=Yv8Y5FfGVXHtx/Zh/erf96ogwH76zp3uWVud6IQI6Is=; b=Dglby7En3dpYC+pLpUSYSQRzo843W3RVNWmytITmDJdgGxNSXZoylSPVSKgVlCGJYY lLT3DUnmsd5Hx+jf1A7lY/24FLYK+X6sRpiQ23/Ut+xPqj5ugROmlHjWWPAiryng3bkY wb0l60x4vr9DlQdZ3k1UgD/0sjSeQXWX3XB2CKrAYG1/RlKVybg0vztzvreNgbK3j2DM DuCx9SGt21TfNKEYd9uaAxL09gC/O308jp70RKHQZiTRDNgQvPnFqCza2TUlGnD4rfCu 5i4e76RnFXB0FAB1cK379bBoS32gyYBu2WEik3qF3uTQhZQSZerYQYWLO4agA2gUp96P 91pw== 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 c16si3521307edw.172.2020.05.07.11.59.14; Thu, 07 May 2020 11:59:37 -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 S1728371AbgEGS5r (ORCPT + 99 others); Thu, 7 May 2020 14:57:47 -0400 Received: from nibbler.cm4all.net ([82.165.145.151]:58141 "EHLO nibbler.cm4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbgEGS5r (ORCPT ); Thu, 7 May 2020 14:57:47 -0400 Received: from localhost (localhost [127.0.0.1]) by nibbler.cm4all.net (Postfix) with ESMTP id 29BB8C022B for ; Thu, 7 May 2020 20:57:42 +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 tok-DwvzUYyB for ; Thu, 7 May 2020 20:57:42 +0200 (CEST) Received: from zero.intern.cm-ag (zero.intern.cm-ag [172.30.16.10]) by nibbler.cm4all.net (Postfix) with SMTP id 08E05C0213 for ; Thu, 7 May 2020 20:57:42 +0200 (CEST) Received: (qmail 2040 invoked from network); 7 May 2020 22:13:59 +0200 Received: from unknown (HELO rabbit.intern.cm-ag) (172.30.3.1) by zero.intern.cm-ag with SMTP; 7 May 2020 22:13:59 +0200 Received: by rabbit.intern.cm-ag (Postfix, from userid 1023) id D022A461450; Thu, 7 May 2020 20:57:41 +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] fs/io_uring: fix O_PATH fds in openat, openat2, statx Date: Thu, 7 May 2020 20:57:25 +0200 Message-Id: <20200507185725.15840-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 those have no `struct file*`, causing io_req_set_file() to throw `-EBADF`. This breaks the operations `openat`, `openat2` and `statx`, where `O_PATH` file descriptors are commonly used. The solution is to simply remove `needs_file` (and the accompanying flag `fd_non_reg`). This flag was never needed because those operations use numeric file descriptor and don't use the `struct file*` obtained by io_req_set_file(). 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