From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.41 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512367; b=Wcc3pdSJVnQGCAAXlUZIBrv1wW1gy7mkUZMsDL6xmzNM4vwj2/ds1hI7/oAQRgH3ISf5 oCvW8yX+yc5x7gNpR40MjmuGvzAxZMMXaGg9L8aCG4zsuvaSp4UWMpg3tjjHkPOY5lLDc oHjK4D2tfiS7MAAJCEJNumjzlhqNkbsyhaAvs53m22+KsO/rJoe6VBvKDwkCp/1SrBWkA l+6EP1a/ZRhPGd0u0eVX1YiH65zD6vQZpvqww5qbfPrlu6FWCQiuuRzM/y18tiD9Mw/48 tJsynAmCafLzff2G6DBJ7K7M/o3CQ62k6ym5PQfukN4do1BxtFEjlfH6ODI7eUsn/jA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512367; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=Nl+PTtfpuMiOkRdFiF6tfuZjwBAJCtwWOv/r+WWqIRU=; b=ITiide+lAQBpnbzC5WRad99AMpjGEZ3Xt5MLn9eFm8GRBR9GHs0lOukec7lb6FVlMpnA X/l4wBUdbfcQIVhaUqu/4icj58hV9/JqHe8gK7n59VxiAkiYjx0DZnFI4JgniIQeYtDAB j3oRDlAWIwFjmzdk0Cuoi+XUsiZmy01x/Qegrdt9+v1YJXif0nAzhlJG+X4RwSIf6epou UV67mrqLu9Yev/qbUogYLDk6UGryxehI0Vg14nc8DUjRCvKQQ+SbIvm3aKuaXwQe+gFnl EgNJ1/RmFMZN13WYahU92TJhsNKjO2Lf4UWarXo3UcmXvtKyCUeBQTh7aRG+Xkoybbg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=bSbdad2m; arc=none smtp.remote-ip=209.85.210.41 Received: from mail-ot1-f41.google.com (mail-ot1-f41.google.com [209.85.210.41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9507606A330 for ; Sat, 5 Dec 2026 23:12:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B9507606A330 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.dk header.i=@kernel.dk header.a=rsa-sha256 header.s=google header.b=bSbdad2m Received: by mail-ot1-f41.google.com with SMTP id 46e09a7af769-8633b750a12so1040653a34.2 for ; Sat, 05 Dec 2026 15:12:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512366; x=1797117166; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Nl+PTtfpuMiOkRdFiF6tfuZjwBAJCtwWOv/r+WWqIRU=; b=bSbdad2mesJ2UPb8dbfD2zhWokmxAngdzjeAu5M/H4+GPTtntvcItwImUQvmL1JNXH PBfq2OtGhPhopIoMS2lAcPdFSlz/jSGsX9Z6n95IUjGlJampeJrcIO6fXUrm+L2B8Sm9 DOP1pkRZDIuhdJuok99VN0bNV3A9h8BP79LEFEyz2JmStpohS309NiESAXtK43PZvWOh ZCnXfkYAXR1iHuR3GzMNGbkr8XblW1IaZV/p9z3AdFgUgvQKylpBw/H1jx9Dghn3XiVY a6sA9yuqEh3eCqGt9QAdp5Mui7DTmwqHKrXpkEhXnTq3DrXit4hIQQsgcs3tROIBGJsx UvUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512366; x=1797117166; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Nl+PTtfpuMiOkRdFiF6tfuZjwBAJCtwWOv/r+WWqIRU=; b=PetdGRORkGf8/SclWvqMxhUhtNruHge6LEmchwFmRo43GixcojnKaMNTfZ2d4GUJT7 foZzWA2g1BoPile4puZwG9doODUZY4cRFzWS9f5tV4xF360g1wltvhQKIK7E49gym56M xvxCl9AF3LFlKs/G/hFc6SzGWZJj8XofuAqA/AEhYgypeGs807jcPtZPg84DMM/FVy+r 6m6EMUkjylGy04l91TRlA9XnYlhzZVukTgR+ZmLA2R7ldFXgfeNSraE3NDZG7Dv4esGA KMroO//pVaw/YmHE2Kt86u4MdcRa7flA2ZY9/+QzdivrqbtQ/yjLKwwb/+P/JFM1wYYk YdsQ== X-Gm-Message-State: APuU4Z8hoywgx4uwVYc5Iq1Tcmmi9KBygVyMh7yOxRUMwZNxxQ3v8eWT lbk+VU0jwLXIdaEcX6YKlljNQf934PZ8QIx+qj2nvw2mY02ak4zin/jNamlsg2QIFdaT1acZaxG /3uCyDB8= X-Gm-Gg: AZFdTZfESTklio9leEupc9KXfqA0HKOEKMBchezUvJB6uPE72wiXDqFPic4JZYVh4Jt VzWba4sJ9h72mnFOMNbnxYMhqG/Gk8KG7wpyaokgwvV4KmWxQUeLPPfozCoJ34z5ZvuIBVcQqEV RXA/LyI8aNAM28w0RATYCKRyGLf1W90ByO/6Gr+K8VCiDEhE0FH4uyL6LEzmuE6rVzpu2lDjFBG o4ALOKx4gg78++Y18+6SMvQwj4w62/H8rHBb/qC7FPvt20mIr5NnusL/StzjvlSTOSoFP+vPnPr K+5xiZLEibAGF4JKxTLFKCkau0EFzE1MAZ0pEs0vEKBdkzWjsWFz4YVLmyQT48wZFUcR/1khQuF vyyueYNfPpx4v9lETrwsos1jFxMHsgKk88iCc1vl8T6CXjfzAeM1mHmk6lMoalsbhRJk04l/+sP MUV0lWYGjGtqZhulbSH0ena3Y3mlhFL/xW3MufZRD7xiv8dH4co1rYfPFsAVMEbJ8DOeL/4tasD sdr5VTBhI7L3xbbvI4phpGdNPbUTmnfErCJxmK8aiR7t/CuiNgDRWaMT/TrTtZgOWcIHDqyHc4A 78wzdGWYRYXtnx6gZ3W6e/+GSKMp9GuzM1wqBg90nmOXYcxYxguwbHKVMownxBbyA3UwZcSsjRG gA/8CeJ+xthk+gmq9jJL7Ub5pQ5ZZze68rz2g+LCXDeb4+B50lqOLhwsriA== X-Received: by 2002:a05:6830:34aa:b0:862:b085:cc2e with SMTP id 46e09a7af769-863f89e1807mr7370065a34.25.1796512365660; Sat, 05 Dec 2026 15:12:45 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f7dd42a8sm6279788a34.0.2026.12.05.15.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:12:44 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.6.y 06/13] io_uring/filetable: don't install O_PATH files Date: Sat, 5 Dec 2026 23:12:26 +0000 Message-ID: <20261205231233.4140988-7-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231233.4140988-1-axboe@kernel.dk> References: <20261205231233.4140988-1-axboe@kernel.dk> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Chris Mason Commit e49d115878796b7b7f77f821d67b7b2f7ccaf400 upstream. IORING_OP_FADVISE with POSIX_FADV_WILLNEED on a fixed file that was opened with O_PATH can dereference a NULL pointer in the readahead code of the filesystem. The opcode handlers are written like the system calls that they mirror, which get their file from fdget() and so never see an O_PATH file. io_uring has to keep that true for req->file. io_file_get_normal() does, with fget(). io_file_get_fixed() checks nothing, so a fixed file table must never hold an O_PATH file. The register and update paths take their files from fget(). But a direct open, IORING_OP_OPENAT or IORING_OP_OPENAT2 with sqe->file_index set, installs the file that do_file_open() returns, and io_install_fixed_file() refuses nothing but io_uring files. With O_PATH, do_dentry_open() returns before it calls ->open(), so file->private_data stays NULL. generic_fadvise() has no check of its own and starts readahead with that file, and fuse_send_readpages(), for one, dereferences file->private_data. The fix used here is to refuse O_PATH files in io_install_fixed_file() as well, so that a direct open gives what an open followed by a register gives. A direct open with O_PATH now fails with -EBADF. Until now the slot could be turned into a descriptor with IORING_OP_FIXED_FD_INSTALL, passed to another ring with IORING_MSG_SEND_FD, and used with IORING_OP_FGETXATTR and IORING_OP_FSETXATTR. No program that does so is known, and a fixed file can't serve as the directory of a lookup. Fixes: b9445598d8c6 ("io_uring: openat directly into fixed fd table") Signed-off-by: Chris Mason Signed-off-by: Jens Axboe --- io_uring/filetable.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/io_uring/filetable.c b/io_uring/filetable.c index aa9f0abcd8ee..802a45c6ee74 100644 --- a/io_uring/filetable.c +++ b/io_uring/filetable.c @@ -73,6 +73,9 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file, if (io_is_uring_fops(file)) return -EBADF; + /* Registered files come from fget(), which refuses these too */ + if (file->f_mode & FMODE_PATH) + return -EBADF; if (!ctx->file_data) return -ENXIO; if (slot_index >= ctx->nr_user_files) -- 2.55.0