From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796512367; b=xP+souyPl+pMhExyQJyoIc9LoQNNhz4j40QK2Nmd0GBZHH/nmvaoygw5zBwNqR1v8EUg pge1j/BbQ385H4+pT1fCJwWx6UkzzH+aaCa+GDXR+Lur4I/Rplx5yveh0opM6FSyuTOL5 RinygOTHGfqjnB/uBvFtzQNUPQ9ZK9QOwq7LYH0DY8QZclfm6c2/YQbGH8oreINz6bwAm Kwf7gSA8jw6SRut8rD44TOQeXpVrbRuOGtUn82Pc/QxCIozw8c+TV9QjS6LRWiox8Kzdw SiEfc/GOHLw7ND0INm6LFHXyBylkXgxwEZhx0N7vM+nDzjivuwIhGH45V9tk24Su9kA== 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=SG0zwGe4NQNgeOnSP5tEgQ8IO2N6DMs2ExhWQ2wDI8BeDc7e84vw7dzh+/C1ewEHBp95 JepsrNoBiVYU4p75c5EWAeobWzEypr4ngDFZWydGt35bgZc2QBs4UNTl8KyF2Bo8y+HN8 WlnxUSqCVX9qRAuCTUdsnMR5T7vGMEJKoElXzP6o3bD2zKYCTvOefNL3wVwfl8y+7Nw3r bZeZlW7z1451+LOAK7i9ChlUlY8CcfY45GLi0rv0GPmSw2LrST3BZuztZrIrhgS+VisKD Mpe5VBBqHuttjv3iQsF2mlCA19L6UivO582BwS5EOalKHRHtMnvZir0Q4L5idQwVJwg== 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.53 Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) (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 AE421606A32F for ; Sat, 5 Dec 2026 23:12:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AE421606A32F 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-f53.google.com with SMTP id 46e09a7af769-845788309b4so953748a34.1 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=VOHPy7bRFlJrQPUoFKuDu0tF4njfk24OvB4HpGGCZ/cI5idzOUftrq9DQEIMw1ugvc UKOASisY94OpHKVfR2yYobYDhqJhyU+XWzAb9xLvAHitGYRr02X7twN4kyiHXza9WJ/i FhzmFzBKT0lMGEUGb1dlqwgSNCtFbfCwzXB7q1nI3P+Ho6wNgwOWEe9glLv0YWPAcDSP vd2SMafKZ42RhxnnwexkQBNop3A2efR3IZuFeeOQNxRJ1OtQz5MilCld2yBqdB0Mll/T CHV9mZD39icVQpOmVvqHvsrA41ytoXyDVH06YvyIr0Ty70ThhxW+wxfDDUsUVanG9pfV 1x4w== X-Gm-Message-State: APuU4Z/7Aju+zi3FMQZRMEmftOhtC9f9PM2IiyEGHzo57wtzkiIVo8r6 OQ1pUJzgWMDbTQ3P8fRA0YyAWlq/nf6rUdXEzKWVVam1lyVmlaBsnEVwczwlIvYDp1Q= X-Gm-Gg: AZFdTZfAqFHF6uxcmyMFub8jS3+14zEl1Q5oTSbVeeLDOkp1wYwr0lLSVdxNONcNcOT gmvVJGbmODig8ewzflqzIpDfndpwlD4EqSd94OOl1TMrrnwta+iSFDgbU9htqA4nKeBvB6mbq7c fbdHrSG+XdQ8m2mPjxNMOjfnRVPh7+aD1tcrNHnIsEGBeJAY1eeyMal7WMEICeP104tfGQDSMhy kDUpWWrzXmjjQGRZWyxKkR5r6XzPIbZBPBd8mf31GgAGZbhluT1gQMzagOMv0zehmqUz9a/QxP7 5oysLzcQMGLi1xT3kzhrP08y9KNJCPofhtbQWtvLu/wsGudz2XVuSrH6kZlTPYSOYZz6EsyLoS8 CneCqlbJXUz9e9b4VHdxGxjdUNWdXnfyvr0yUw0te6MLYWPnd9cmvXrM+W1zO9jOQgwpaqQt//X 6kC1466pv56iH/vBVHur/FYkAXuQaHKjhhNbyXiNboN0mOn6tYNA499bq2w66k7cshDNnCUXNeS Vsua+mV9t91TBG9at0cWQHswi7rB4Pis/IyVSjG/AJQgqbVwQmrp0zMqfdu3xUUpkLaf63t8oe/ csJ7aQAUFsB61zUUnzPQwfsqJ/ZtTADGyKq3VkL1s+GoCg0p7HHZzUAV+4c2sZAmLpdj1V8VeKP HD7ImRyHGqdvR58T791dcuS++omy3LvDU9qTRv3oKGBUnsLYpjnpX6N3j5A== 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: 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 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