From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796379752; b=aGGoRz9ABgZqSgURVUShUc4KSS9fLyoBWKneLwo/wHYGXId7oZhjXDhE5sxcF/yWAx0W QuXWdCblznltO9KBDYhOKEs8trVa8LlFRPUJEhA4RKHOZjvTFuvsMfY5X4XGgqi8F3/YA qDv1ZZUr+aUUqA4rEYjeicKiffWFlsH2V3n7pUDb0o95fZb1hUGLTZLUFPD5vmot9Ez1T pNzh5em0hZ5GTghrtlwIosmOWpDlhIhYMkVcwWOj8fhXfcEaa8bGF0jqr+fZ6OSjlWl8E 5REiuc2eenDDgjjVBARkojToKXiGBLWvR0eWP0CY3aA1N2kUmkEeAdMpaz9UGVKULkQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379752; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=gAWBZ63bBfNSP6ewwpSNt8dnWolNjTGZd4ZIpl9Uanc=; b=2MWBDklL/GE/Q1MYWU/EGyXFedCOJzVBGedGMEqFbXLO38Omo5BPqhqCmGuabn4l3gxh icqWScPjf97gXbPPir+14Pjb6TbSk1EmFxAS/w0cDrSIPbVygzmK1ie9dwPif0n1sbJpW U5tJjsI35Zbb5JmE1z9liDONrlKKwuAwLSJNbZk6Hl0bIczcGUUhnroSMl0Re5jBJUZtQ 5ZTr05fiZPSHIPAHaDBZAE5AiCo7fU5587g8+1H5jZ/vWh7wqVDKEETKWXkf6PP59Fjod v+wCVadbHgT1aCYg5q0/9T1e8vgj6b1Mjr9SUmwT8aTqT9mJHLXUS1RIj/JMzopMK2Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=C67ulZs0; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF5B3606A32C; Fri, 4 Dec 2026 10:22:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=C67ulZs0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C3031F00897; Fri, 4 Dec 2026 10:22:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379751; bh=gAWBZ63bBfNSP6ewwpSNt8dnWolNjTGZd4ZIpl9Uanc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=C67ulZs0xBlDwTwapp2BAIr1KrVoUFAgZGEb9ox8z9knJ5+y5UPPXsnqzFiJWcmHz /XjWHquLHvCuT+xcQjA2haJBwtgs+ebUBJ3FDIKWe9xH3vgf5BzfgubBq8yZ/p9ZgA 2Ma+orZpBeX+EvPQvmEl3k9dCH2FA8z8RgAuspEA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuanfu Xie , Dominique Martinet , Sasha Levin Subject: [PATCH 6.6 0047/1167] 9p: do not store the create fid on special files Date: Fri, 4 Dec 2026 18:51:14 +0900 Message-ID: <20261204100703.290581094@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yuanfu Xie [ Upstream commit 56894cadf21c34abbba7f74b8f5d78dabf69dd39 ] v9fs_vfs_atomic_open_dotl() always stores the create fid in file->private_data after finish_open(). FIFO and device inodes already have type-specific file_operations that own that field. Overwriting it with the fid makes later read/write/close treat the p9_fid as a pipe_inode_info, which corrupts the fid and can use it after it has been clunked. The non-dotl atomic_open path does not assign the fid this way. Only attach the fid for regular files and directories. Special files do not need the create fid; leave it for the existing p9_fid_put() on the out path so it is clunked before return. KASAN report, linux-stable 4982d3552a3b: BUG: KASAN: slab-use-after-free in anon_pipe_prefill_and_lock+0x376/0x3f0 Read of size 4 at addr ffff88800ab30538 by task repro/1 Call Trace: anon_pipe_prefill_and_lock+0x376/0x3f0 anon_pipe_write+0x127/0x1600 fifo_pipe_write+0x24/0x300 vfs_write+0x659/0xd00 ksys_write+0x10f/0x200 do_syscall_64+0xdd/0x4a0 Fixes: 30d904947459 ("kill struct opendata") Signed-off-by: Yuanfu Xie Message-ID: <92377346-29E9-46D3-96F5-AABA8A64CD57@stu.pku.edu.cn> Signed-off-by: Dominique Martinet Signed-off-by: Sasha Levin --- fs/9p/vfs_inode_dotl.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index e3fb95d726946..b1254d7cb2ad9 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -333,16 +333,24 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, err = finish_open(file, dentry, generic_file_open); if (err) goto out; - file->private_data = ofid; + /* + * Special files have type-specific fops that own + * file->private_data. The create fid is unused + * there: leave it for p9_fid_put() on the out + * path so it is clunked before we return. + */ + if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) { + file->private_data = ofid; #ifdef CONFIG_9P_FSCACHE - if (v9ses->cache & CACHE_FSCACHE) { - struct v9fs_inode *v9inode = V9FS_I(inode); - fscache_use_cookie(v9fs_inode_cookie(v9inode), - file->f_mode & FMODE_WRITE); - } + if (v9ses->cache & CACHE_FSCACHE) { + struct v9fs_inode *v9inode = V9FS_I(inode); + fscache_use_cookie(v9fs_inode_cookie(v9inode), + file->f_mode & FMODE_WRITE); + } #endif - v9fs_fid_add_modes(ofid, v9ses->flags, v9ses->cache, flags); - v9fs_open_fid_add(inode, &ofid); + v9fs_fid_add_modes(ofid, v9ses->flags, v9ses->cache, flags); + v9fs_open_fid_add(inode, &ofid); + } file->f_mode |= FMODE_CREATED; out: p9_fid_put(dfid); -- 2.53.0