From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.52 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512225; b=Fqzjizb9V5RD1ktc7Yyl/TE3bqwn3zEQdRN4RGpUVkDSVOQbu0l4RVipdMxST0vLptfl 8lCjBKIk1rg8pMESDDfDSpJMiQDDmsoDX/5uIkiYUDz4lu8mieDJ0u3tvLib97HjkKSQJ nchYIFlS1Oj/WzHvqoig0VE/q0cB0KD42GZhaN3nbyckkBzuK278jbSBjZalbLDbN1qqq bRjqP8MbiitR/s4PYT4min0Jw52mYZnVSuBLKn7V+o4i7BucICxjUV6ZkoXrzvKzZ89rL RyIyNNisdzypgPF+ZsL+aD4BZ7yCgdOVKStV8UbfKoaM95TpzAmXRY77g3SHb/BnLbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512225; 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=cKA/Q+KVUlIaC9YemGa08M3UG4IV/92qAMqmlaIv3S8=; b=cZaenR+5PJP7mgx2Ds6/szAvlV/6Qll6LVDICWgDE3YLKkA6bNFQ1n0JyZSI77v2hhMI AZluBpt0hf2dqPXy5XyL1dkhC3zpMLrPGDFc97RrAVb+KHl4CmmeEgrtCCUTy96RbqFcM 2Gi6qdHTUmFkwJp9vOdlLVWcr4nwotEOqI+ru6CWExHRccp4JtIV7FLmOa6Y739oLtJwx Yy1urw90rx0MtLBhyQ6FRNjcx8ztgT98uwgAHZK3Ct4M/KkdOaL+ppnIHGHOqNKZACGz6 nhCBxynIRuuO0XEsNWM1mL6dM/LtAAqxfOa5XOe/8rbgrYJI3dCW5u6OuQfanvP8ITw== 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=UapLtFdU; arc=none smtp.remote-ip=209.85.210.52 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 964A1606A32F for ; Sat, 5 Dec 2026 23:10:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 964A1606A32F 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=UapLtFdU Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-8633b750a12so1040113a34.2 for ; Sat, 05 Dec 2026 15:10:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512224; x=1797117024; 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=cKA/Q+KVUlIaC9YemGa08M3UG4IV/92qAMqmlaIv3S8=; b=UapLtFdUJ2Zbk4wA4dGVPYWtnsCQUCm61U9rkwPJ+JdcKsSn48/WXO/f+4XQEjhsDY a152T2cMmRkgJPXDB1tE0iUHYlNXi1/+DVHEzRXhl9EXf033nR+9K5aFqqzqybE1/28p 9SG5lVA49aUkskxzgJ7bch9GixSzaWEtVA6OOVkUxiT+9kvVGh7leo0efVCYQXu4MWof 7FC4msuPbYoP83UO5m6tWhoT+FDti+HUN3ArDMlvtCAYct2UMt85qBj1iBBejmuvezTf AG4f0WtzK3LDVaghFPagSbDP35y8zeNvnnHd+iuSnMqZT6GRBr+CoQi6dhSWlCM8mnbe gHSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512224; x=1797117024; 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=cKA/Q+KVUlIaC9YemGa08M3UG4IV/92qAMqmlaIv3S8=; b=HRUUCmAuinwmIge++mi4FoKubL+kzaencDTlMqmVV4g8DIVAF9NiJ5RvOIaIQ6pzqe wjGZKBmCAR54qh9Fi8ufNomhUoFgIi+SNUIx01bzYsl2J19ddYZWTd05v5bNgifmwF1U t/K6GinPO6XCyc8/YwT5uGo+LDwZeAEnIJD9GwnUwheJhPsO8C66rKiMOvEKiCrvUb/d uKByTuk9ncLlGSmkd54ve4QGcDNtR/KEbFUgguJuuqRj60px5ICuvZ1UNhoYKhOCCu3M 8GPnnF6KJv99nBobCod3Ada+V+B/HtfqD2qOG1Y6cAVsJum4EOERnYjzUh4f+XpI6YYz DDIw== X-Gm-Message-State: APuU4Z//q1F3UHXohrg71zKX3qWoMJzd5mdLMCf7YV+2BxSYZKInEhGK WhJDKJ0zO31jlhyJIo7kK37H1OqX3X08TNAEeOn/zDK9RMCavH3yz2RZK9UI2PEaLHc= X-Gm-Gg: AZFdTZfuxq9jsy4Sm7uAiwGbFfY5UZnyYaVa5rSOGUSxMSoo328QCcL3Bk2RhivGCEx VauIumQi7gt6fAm50nHXMlRNDphh8B4ZVfRSbODSpyCAPRgXHeZb7an0533D3K69tJ5P28jLWRE oby+yHd7gxzGTMZwB29Lr1xohFyCyxpgJLmjy1CJaRcV/fcGzRv1lSUsCLkkPC7yCphBrVQPDzD BOOQssbfbG8SL6cPnH1VmKrRTJ3IvEQ+pRs5RNZEBjhXGCiOeDZ3d2gUI1FDuqZqELu8b3wG36i QWbsaaYmNtjbuRS34b16twd0r4pvPNgjr5O+Jisyjz/9QBBUFHHydNRMmb/WiNqkoRosLTDNp3c 7VhgxWNNMORsFY2BxbTSSGV9ULYhI9Qz+/0vus7eRZUntWzm7wqpKyh8Ghk60eOxg2D4TAMs5hZ VgXDCkh4n1ySMOMry/Bn5ZEHoON/DCiatjr1NyciKx2FcY6yJt8//yN/lRtumc9a/1MY2TCJpEl SpirmKw9MYszWYz7hgZFhJU1uotEZLEXOombP0/krlLC2LpotjoiQp3RqT5pMmYGHrJMKECIoXg hutqNn8LzdIi0ogAc5cfKqCTp17WuHFmCwzE570yTcsuwnW91vII1neG+b6m/zn1jV0UfB4dIfv H4RQx3sMeaS5h5ij0NlYb6Fxcn4ars4esbYIzLVagNCcOGaPQzAOSRSvlGA== X-Received: by 2002:a05:6830:6412:b0:845:8d86:9f7a with SMTP id 46e09a7af769-863f898bf2amr6792385a34.10.1796512224590; Sat, 05 Dec 2026 15:10:24 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-863f8313082sm6309624a34.16.2026.12.05.15.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:10:23 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.1.y 5/9] io_uring/filetable: don't install O_PATH files Date: Sat, 5 Dec 2026 23:10:08 +0000 Message-ID: <20261205231012.3977993-6-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231012.3977993-1-axboe@kernel.dk> References: <20261205231012.3977993-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 6a4d0bece0c7..ada4b27baca3 100644 --- a/io_uring/filetable.c +++ b/io_uring/filetable.c @@ -74,6 +74,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