From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512285; b=Gg/1iDTztR5ngje5/sqTMQNP5ciML4WioY5hFOXdhxpHlAocq/gl7j7H6295MiXmTEr6 n0Ga+DSPjq780hQjY02QglIS8Ar7H/wm/zppWcuIvtaYGdCdeu7H1qmV3DR7CxawwHlb3 +/rWU9wOdjIbPmnyK2AZLZtrIzJtebiEcC59JLuDzjXqRUTyQWfCB0j7zz9qJu61i65d+ aG++R/a1wijBPPM68faXcbajB7uWv8XPzgcAF5HrQDuvtewUq4zank6Xjs0RfE1FKp7KS fFD+lCr4S3cauWpTzKFMbHnooGqJIa37foo4d1M30c7z78iemVabXkQECmSEJTManAw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796512285; 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=WMjYj/MlgrOBtvw8uIYPaIjbAXmWi1qtl5kw0g3oJe4=; b=LEqioUdmWq+E5fHphuDu2dZXdqd30nH6mXMdM77P01L1LmXqY5YfRhuSYGkORO73CrA9 Dz+UNHtjbIaSXHE+6+dr6hMn4BgYdbt2uLV0m0lo59O15ZWeVQ2ujSJ6u4CL5SGpdvOUP OcRdpxqlvbd7D7ZU/OGjHHiXxi62S5EBL6Fkcn4sJuDIDupTBOlIZGCJTTi3h4eHJIjDF lo2iaganqjTvirNa35/Eqv49pOOPACwNE5617ch9FaPkiJkK3kNRbF/9MJ18+E6RNIqU4 TrvKgutj4CdxIIDNe8EK+zbXKxhuFVD1Q+ggbbGobvzB76ry8z2RpvCa/LuTh8oJFKw== 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=eUXzNPJh; arc=none smtp.remote-ip=209.85.210.44 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 96442606A330 for ; Sat, 5 Dec 2026 23:11:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96442606A330 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=eUXzNPJh Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-85a5455bd3cso1219921a34.3 for ; Sat, 05 Dec 2026 15:11:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.dk; s=google; t=1796512283; x=1797117083; 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=WMjYj/MlgrOBtvw8uIYPaIjbAXmWi1qtl5kw0g3oJe4=; b=eUXzNPJhR3zmyuVGaKuw8boIsiSSRyv0z/+QEcBDHRxHIxwFjkIzEWIr7rDNg6eK4b 43Izm5FucunWFjuUXTiky3jJHWt6rEY4KN3G5YnSVvPhwiUxPBYHv4wQK/W46wPedUFh VcKr/1p/Z3aLkhIh7kdOtZw3wwl770VMroge9Vcy8U12ZoeS63njVN/e0Y1ZlHRDujWB +CIiHM0Uo+RE8hg2dN5wzf/MJAbEmu8p+NfngSgekVRvDptuysKZSdfLcisPlT1ky75c qAEnzFW6K07etSI/zKVMTdp1EFKpNLVxGQjwmdqUXdfk92F/L1mzPhZ/KvSTGX+MWOkQ CTAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796512283; x=1797117083; 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=WMjYj/MlgrOBtvw8uIYPaIjbAXmWi1qtl5kw0g3oJe4=; b=PH4UEPj6eCONa4l/mJJKKn90Z6+zk3tySOFQYwH2I2+CarBO6lkGeFa+mgTqeNQV+k 4Amv9OAjHQjWnu67wCMZ4pXTPn4Xj4svhTtMIeCyUIczUxCvS95M4IPVovZZf+26yEgK S8U0yLu4IYEMgwsu+Ww0MgXE0SrgaXp/c5KvPrMuqawVJTk3Mhkpc0wJLvT+l1+q+hHX hWYcMZnsiRZ0sDwEwjN8ZBAfE/PzJxdxe8sSW9TynVx4GOBvqLGNMBww/ZTYXWhOgUIP 5NpwzG0CfC7wMS3EDR4BZ3Yk4UET4/NOQrsBp7hRnBT5d0XLt8pxpKq3Nl7HIxrUqZNV CUOQ== X-Gm-Message-State: APuU4Z+i+Cr4iGkpOZ4QQL4nBvTL2G48RDJrOkbwKABxgr/kgKLr58l2 GIVV8gjDhAT+2gIneiKxTuCIp8h7KRhPsuF7Cy/H2dHcDG8hBtNg+ib1DeHi2nfXEHrHAHh67On +JlxhjTk= X-Gm-Gg: AZFdTZcftR5fsUL10hlOWFimRGEz0XD5boYL5nyRv0VohcGqYWROzk88QeJ8lYdUa+K BAPF/sxN5fV2RhY+z84R0CjIwn0RSF2QOiyX3PYV4wKdxh9bgHsv/ud8Essgm/QcljBwtW3+BJG kkzU8EO3uFw1KCIDKisxsNC3bdcefrDG08bLej/Q+h4L4QVnC9RSSHvyMRCNHaDnbrrfjSrhhil q2aDJAHpbSw++ZAzIsTvwOyLi82XnEDpKZLqZeArnlJGfJq0gCJmHXQqCf3JFPx2HsDjfAbxQCA 9SoZi4h3iPnu3vuLf4VX12IYtljuEaDL4iMNDe26xjFeFlJSSXhcFSPjAVBeaq6IAK7m3SRsEh0 5iYDkUxHtNwEHF3TI+dQhvJMG6Oau5Iqwd4uWkXEvIuCRw/d0EPWbdEHpCL6jNp+CQP5oXiqDk7 NttFNQ+8kOAQwkweK+vG6Lb0BStNRRfoP91NqvuNEilXgbJaXFYWNAfIe6115D4i0g+T0uvFW/r 2kqpLbrdrEFaXpeYOuEW1LjWP0OlulpppqlHxXESjRB53rLZ7QRaVQUSC5ahBLaZImajRhKy10z M5k0tcGrwzRt/jk89Wcykcssp2CHEWQctKszKvV8ilDHr0qXbaHxujYU169fERJDEShEOS/FLkq zLfvIvtO+MaU7SeK8xBXXd6wABdOi5Jen+1yh X-Received: by 2002:a05:6808:159b:b0:576:1161:cfeb with SMTP id 5614622812f47-57f20876907mr6383507b6e.66.1796512283594; Sat, 05 Dec 2026 15:11:23 -0800 (PST) Received: from r7625 ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id 5614622812f47-57f1f65febbsm4163964b6e.6.2026.12.05.15.11.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Dec 2026 15:11:22 -0800 (PST) From: Jens Axboe To: stable@vger.kernel.org Cc: io-uring@vger.kernel.org, gregkh@linuxfoundation.org Subject: [PATCH 6.12.y 07/15] io_uring/filetable: don't install O_PATH files Date: Sat, 5 Dec 2026 23:10:59 +0000 Message-ID: <20261205231107.4023506-8-axboe@kernel.dk> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261205231107.4023506-1-axboe@kernel.dk> References: <20261205231107.4023506-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 72423e27e5e1..e68a6ddae682 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