From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512324; b=URpRoQFq0SxCh7btwB0WRIWhd6mYxUAD0NSRuAwWsOP97rbF8YHR96ulYAatU8i7OhDu f7s0seA0FaRZHydDnKIe3khVJYmqu4dVhFb5MD9iUU4h1zqkMsVF+eR+02YymzZ2tdN4j nJSQs08FR2bzhq4ynSL8RbXq4n1PCtQy0ibIv3AME/K32qWM3mt6gxIoY/g/u1YDr2OHQ Ly12SSik3/isnzFpBNK/O7ZBGXuQJmBDMTmv0HHuOMEcwGTwY9qwtDFZt0rPV65WP/dUH 2AWKCCgDEqxNtJ1CWDnWXHthNUcoLDSueiTk1WMD6yQPhruxISMm7jUlODIF8KZpNyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512324; 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=lxSuNcH0ee5zx/3GnMdHNMyHcaDXLfvy2KkRtaiJKLA=; b=B/F0mQh97LUS9QFalD2pAyRpZYI/lrQul2nrbmshi/Sy8LqP0+N7UzEfGgsuBQHU+Lr8 MU711DireOoc2BRmnKR4zAc3isLDKe/NUTcL766CPdCDCE87eZ8XblxNr7EBuJFlFzMv/ 79ZVz+GCd9vhVJ/Oin9epAQXQfJ5cYw8v3yY0lwZEKCd6BJHe41IHz5XQCy74VbZN7vS2 rsEuLp9sTwWIpHc30WnPh1Q4tTxRY84Xq19ReAvuKRTPkGiYKH6rVhDR05FnJkZcMkRAP P5OTjk1Lxr9bZJXNvXmYzCCXSVN7TTmBc7oUjs8buLo1tE5uetDxCRunJoWnSANIcsA== 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=TjEhbH32; arc=none smtp.remote-ip=209.85.167.175 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) (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 98444606A330 for ; Sat, 5 Dec 2026 23:12:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98444606A330 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=TjEhbH32 Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-5722bc8ddc5so780571b6e.2 for ; Sat, 05 Dec 2026 15:12:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512323; x=1797117123; 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=lxSuNcH0ee5zx/3GnMdHNMyHcaDXLfvy2KkRtaiJKLA=; b=TjEhbH32NAM/YqGWm+wDLFsSJhgcio1uF/wGikw9ScZC7XLgYa5CHJu1DmFMpfrKbm QcSwAUEx5/0z/zIb4DzfRVKpoMulp/vt0G0GPJwyDOanB7VLDt7fhNZ94F1//JkMr3o6 4Q6LWYjvc1m7INvS6sZHksCsbXuXkawLJKiICoK0Z3wdWd8ELd8kuEosV3ev5oSGOZmK zXIFwxkeeRXRGBoailezlexRPT1/alJoRMANv6QLiNQsCYZzarw7Th3bff0iBt2Zslu+ lhQ92KehdD/wDON4c+Y8Zu9Z3J+7v6OWUffTvOPsPINBO3RV+OMldkPPGbq2GQ+OHV6A AuNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512323; x=1797117123; 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=lxSuNcH0ee5zx/3GnMdHNMyHcaDXLfvy2KkRtaiJKLA=; b=gMx35haBP29E9+XelxuSpv+tb8CaEGabqxg16Jqh2cz+zUE13EcwsRXNMzq+IITRty s5Ib8h1TdGGV7zTySRNy0+XDfkyfLJOhGJML3MzXhwknv6OcLzgPqlGZ3kFuxiePxku/ xjsq1AUMJc7FdM+YqJKrz4migPifKNHzFV4AkOSD8w0f8ZXywyn3QE13xKVaZNfAug5k 3BmlF1pAnVBjP1Go6DcGadg9u6o9i3zvqb4KSvMYMDEDPA4Y/lFtIcpppt5pVMu0WoQF Z1qxm+IcP72x35m8brtrycka4kMV2IH4jaJyRMiEGcM6e2/bI9WzctvGVFaI3oIkG7Xz ErDQ== X-Gm-Message-State: APuU4Z8z4RQHehWYcvdBOe+4reOYaHtODJLN6s84W3O/UInjqVfVWVCf Sc+qLYXL05WhgKQLW2ZZgKm8zyjw3dlEOViJMxdT0KBP/zmUF5nUKSBOdFWKCNoX2VE= X-Gm-Gg: AZFdTZeOF075Fe+igA2/oISiLPun9YP8+4BD0nSCyaKH1XBrCM6snWv3BV4tjVS9hp4 UqUzP9CcLpo46SsEPS8g+KiSovfBKbULr6gGoQy4pZH4PvY+HOY66HQnlgwWITsSJ6A5c+zRscR wi9q5jxIk0ZbYMo5ZtITI/FoWdv1XNgZscHxqzeg2sC3xkxNZpmntGH7JDXKRzqi4uofUQrKNaG hlN9dKRh3RRhXvO8zGUUunB2DOpI/3JmSUFngo+g1RlZKJahvz//foouUnoFvRmmN0xN7jySa3J +gG40cMZ4q/MYw5q/3+2+Kg9Kzz3lV85k/PUe5e2DJI1Lx/B+qFz21Y91f0WslNx0dhjpD8QsA2 7A69UDopXLUIsIzdkRM2W1P+NOkghnXohYPFWp4DwCKKRNChEhmFeCIGwqap9qZlcdI8sw14Ek7 oMS06oL3lK2Q+t1hN5OMETj1TLo87ZyaN1a5wXSN3gpTb69mlmxsCMKze6sKp0PBt4kSVovVDXS HYJ+borNYNh6T7qZOPhU+41C25HGgmmMF2auHAdP2dmBR2pStN+qHX2qoaXs5A0VYOL9zrNWLKS E3vJUg18I/uCrrM78dZoiiY2h+93umKzab5qm2iIFNY8uZ0BL4iC+5oV6DiwXQcr68R9RmYIU0B VZnKAjiL2ItsXdOtxFJaPhXMNyZ5ZAJ+sDe/ivB4mXUaUh+zz2HFobxxRvg== X-Received: by 2002:a05:6808:250e:b0:4f4:6421:5efe with SMTP id 5614622812f47-57f207e26a3mr5688595b6e.36.1796512323538; Sat, 05 Dec 2026 15:12:03 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57f1f6fe2ecsm4086916b6e.14.2026.12.05.15.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:12:03 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.18.y 07/14] io_uring/filetable: don't install O_PATH files Date: Sat, 5 Dec 2026 23:11:40 +0000 Message-ID: <20261205231147.4095031-8-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231147.4095031-1-axboe@kernel.dk> References: <20261205231147.4095031-1-axboe@kernel.dk> X-Mailing-List: io-uring@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 cb1838c9fc37..f547ab1193b1 100644 --- a/io_uring/filetable.c +++ b/io_uring/filetable.c @@ -67,6 +67,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_table.data.nr) return -ENXIO; if (slot_index >= ctx->file_table.data.nr) -- 2.55.0