From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=89.108.82.222 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796132160; b=tBsFIC+adClKz4Z5rlPNQMhtHjVsvBTYfRrTyTQFaqpFukkn887VO5XIOFih8FxzTJ2L CTN6fNCVeh5H8rlNZfCuLD2q52nrufOLxFfoVvgo+qKmHiMzF/mVbU9QqaRiPetf4cmLK QfLtyC1YoNc7HxGeCi7JACupvkPQJ+SuwwZ6IUo1MGY9Wb88YszwphuzBBEIIVbHqB3FE UlJ2FqWKaPVb9xes/Rw5+7K7XB2grQIUiaBvHSkPYt66BzFqaZ8ckckLGQutIJP5MviDh 2ti8Hd+Mp6BuWUi1UMzK3QzqDklkhoVQpPZ1rERGtxF9bng856Srx7Cp1vrrpMMKR1A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796132160; h=DMARC-Filter:DKIM-Signature:Received:Message-ID:From:Date:Subject:To: Cc; bh=IQaimoZpQGvNUc5e6erNbY50pbEWpDOhA4y4r7vamhc=; b=V6gLz0hy0GFYwBlA9dnf2UO8f5URjglHc0FN/gk98rzKg4vIH2t+APJV+4Fna0R9asjT fPLfrKNiNZGF8BckXa/ubVvKX0BcKUL8/msOYnuHpAAJf7HdgtHHMFaB811CIoJlem1nG 26gqyxtVLHKOCPG1frJCngLl8SxBPHGnnxRLBlfHa4xycWPIuTJIFgAdAoCQIcd6mMwFI YphIVaplNNtrP8NzMyH6F8cQoT2GcaCHvIT9Jd2lMJu8c0Ir52P9SK6NjxAMRaq4MIH2U 1oHF8TQ/sTG93lQN24rrYAEqC0F0r+KtAjCb81csu0Q3e57vdyWB8sVTEbw9CGueDnw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=massivetech.ru; spf=pass smtp.mailfrom=massivetech.ru; dkim=pass header.d=massivetech.ru header.i=@massivetech.ru header.a=rsa-sha256 header.s=dkim header.b=kvNi+tHE; arc=none smtp.remote-ip=89.108.82.222 Received: from mail.shopvds.ru (mail.shopvds.ru [89.108.82.222]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 001F2606A33A; Tue, 1 Dec 2026 13:35:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 001F2606A33A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=massivetech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=massivetech.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=massivetech.ru header.i=@massivetech.ru header.a=rsa-sha256 header.s=dkim header.b=kvNi+tHE DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=massivetech.ru; s=dkim; h=Cc:To:Subject:Date:From:Message-ID:Sender: Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=IQaimoZpQGvNUc5e6erNbY50pbEWpDOhA4y4r7vamhc=; b=kvNi+tHEnuWia8ACZBFQOrKFGY ZYFA51wqSd8HCN8uFiYebS7z2X6XWK1tPB413XLVcOa1rMbbI1reLntcQF2kJ33M73sRXzAB1PCDe +648oLv97ypHMCA76Ff/nYAwiBZ0caFdd3FhGaZ6Z5iCRidprY/M3TiFG3IrqS7jBqJi5NQR+SByp +tSiER7RylVbkvAJhEJNrkosvduJNQPfU47NZu+1TI3McmWUYGhwDpfyPqVPJP2e/JZup55QCd+1u mimDHQ+QaRFghotXDrAz+8mbxO+0vHMsj/52tgIatpGvILu8HGrp3Vmgr+ORezOO33PFChU5dv7Cg FA6vxz+g==; Received: from root by panel.shopvds.ru with local (Exim 4.97) (envelope-from ) id 1xYO0Q-0000000FxHh-10jR; Tue, 01 Dec 2026 16:34:50 +0300 Message-ID: From: Konstantin Adzer Date: Tue, 1 Dec 2026 16:34:50 +0300 Subject: [PATCH 0/3] fs: return ERR_PTR() from iget_locked() and friends To: Alexander Viro , Christian Brauner Cc: Jonathan Corbet , Shuah Khan , Randy Dunlap , Dan Williams , Vishal Verma , Dave Jiang , Alison Schofield , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , David Sterba , David Howells , Marc Dionne , Luis de Bethencourt , Salah Triki , Chris Mason , Ilya Dryomov , Alex Markuze , Xiubo Li , Viacheslav Dubeyko , Jan Harkes , coda@cs.cmu.edu, Nicolas Pitre , Tyler Hicks , Gao Xiang , Chao Yu , Yue Hu , Jingbo Xu , Sandeep Dhavale , Hongbo Li , Chunhai Guo , Jan Kara , "Theodore Ts'o" , Andreas Dilger , Baokun Li , Ojaswin Mujoo , "Ritesh Harjani (IBM)" , Zhang Yi , Jaegeuk Kim , Miklos Szeredi , Andreas Gruenbacher , John Paul Adrian Glaubitz , Yangtao Li , Richard Weinberger , Anton Ivanov , Johannes Berg , Mikulas Patocka , David Woodhouse , Dave Kleikamp , Greg Kroah-Hartman , Tejun Heo , Trond Myklebust , Anna Schumaker , Ryusuke Konishi , Namjae Jeon , Hyunchul Lee , Konstantin Komarov , Mark Fasheh , Joel Becker , Joseph Qi , Heming Zhao , Mike Marshall , Martin Brandenburg , Amir Goldstein , Anders Larsen , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Bharath SM , Phillip Lougher , Zhihao Cheng , Jori Koolstra , Damien Le Moal , Naohiro Aota , Johannes Thumshirn , Johannes Weiner , "Michal Koutný" , linux-doc@vger.kernel.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, v9fs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org, linux-btrfs@vger.kernel.org, ceph-devel@vger.kernel.org, codalist@coda.cs.cmu.edu, ecryptfs@vger.kernel.org, linux-erofs@lists.ozlabs.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, fuse-devel@lists.linux.dev, gfs2@lists.linux.dev, linux-um@lists.infradead.org, linux-mtd@lists.infradead.org, jfs-discussion@lists.sourceforge.net, driver-core@lists.linux.dev, linux-nfs@vger.kernel.org, linux-nilfs@vger.kernel.org, ntfs@lists.linux.dev, ntfs3@lists.linux.dev, ocfs2-devel@lists.linux.dev, devel@lists.orangefs.org, linux-unionfs@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, cgroups@vger.kernel.org X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list iget_locked(), iget5_locked(), iget5_locked_rcu() and inode_insert5() return NULL for a failed allocation and also for an inode under creation, which find_inode() and find_inode_fast() report as -ESTALE. Callers read NULL as -ENOMEM. As reported in [1], open_by_handle_at() on ext4 then fails with ENOMEM, and nfsd returns a jukebox/DELAY error, for the handle of a deleted inode whose number is being reused. Following the discussion in [2], this series makes the helpers return ERR_PTR(). Patches 1 and 2 make fuse_iget() and hfs_iget() return ERR_PTR(), so that patch 3 can convert the four helpers and all their callers at once. Testing: - The reproducer below, in virtme-ng (x86_64 defconfig, 4 CPUs, ext4 on a loop device, 10 seconds): one process creates and unlinks a file in a loop, the other calls open_by_handle_at() with the handle of an earlier, deleted file of that name. vfs.all at 84fb6f8a1ba9: ESTALE 2312698 ENOMEM 637252 with this series: ESTALE 3394396 ENOMEM 0 dmesg has no messages from the test in either run. - allmodconfig x86_64 builds of every directory the series touches, with all three patches and with patches 1-2 only; ARCH=um for hostfs; sparc64 for openpromfs. No new warnings. checkpatch --strict reports no errors. - Not done: run-time tests of filesystems other than ext4 and of the changed error paths in the callers. The series was written with Claude Code (claude-opus-5-5). I asked it to find out why open_by_handle_at() returns ENOMEM to our file scanner and to fix the cause in the kernel. It traced the error to iget_locked(), wrote the reproducer, the patches, their changelogs and this letter, and ran the builds and the tests above. [1] https://lore.kernel.org/179612584364.3457081.15142720814992093613@massivetech.ru [2] https://lore.kernel.org/all/20261201-advent-fahrkarte-zierlich-b5b73df9e312@brauner/ Reproducer, run as root: ./iget-repro #define _GNU_SOURCE #include #include #include #include #include #include #include #include int main(int argc, char **argv) { long estale = 0, enomem = 0, other = 0, opened = 0; struct file_handle *fh; int mount_id, mfd, fd; time_t end; pid_t pid; if (argc != 3) { fprintf(stderr, "usage: %s DIR SECONDS\n", argv[0]); return 2; } if (chdir(argv[1])) return perror("chdir"), 1; fh = malloc(sizeof(*fh) + MAX_HANDLE_SZ); fh->handle_bytes = MAX_HANDLE_SZ; fd = open("f", O_CREAT | O_EXCL | O_WRONLY, 0600); if (fd < 0 || name_to_handle_at(AT_FDCWD, "f", fh, &mount_id, 0)) return perror("name_to_handle_at"), 1; close(fd); unlink("f"); mfd = open(".", O_RDONLY | O_DIRECTORY); pid = fork(); if (!pid) { for (;;) { fd = open("f", O_CREAT | O_EXCL | O_WRONLY, 0600); if (fd >= 0) close(fd); unlink("f"); } } end = time(NULL) + atoi(argv[2]); while (time(NULL) < end) { fd = open_by_handle_at(mfd, fh, O_RDONLY); if (fd >= 0) { opened++; close(fd); } else if (errno == ESTALE) { estale++; } else if (errno == ENOMEM) { enomem++; } else { other++; } } kill(pid, SIGKILL); waitpid(pid, NULL, 0); printf("ESTALE %ld ENOMEM %ld other %ld opened %ld\n", estale, enomem, other, opened); return enomem != 0; } Konstantin Adzer (3): fuse: return ERR_PTR() from fuse_iget() hfs: return ERR_PTR() from hfs_iget() fs: return ERR_PTR() from iget_locked() and friends Documentation/filesystems/porting.rst | 9 ++ drivers/dax/super.c | 8 +- fs/9p/vfs_inode.c | 4 +- fs/9p/vfs_inode_dotl.c | 4 +- fs/affs/inode.c | 4 +- fs/afs/dynroot.c | 14 +-- fs/afs/inode.c | 12 +-- fs/befs/linuxvfs.c | 4 +- fs/btrfs/inode.c | 12 +-- fs/ceph/inode.c | 4 +- fs/coda/cnode.c | 4 +- fs/cramfs/inode.c | 4 +- fs/ecryptfs/inode.c | 4 +- fs/erofs/inode.c | 4 +- fs/erofs/ishare.c | 6 +- fs/ext2/inode.c | 4 +- fs/ext4/inode.c | 4 +- fs/f2fs/inode.c | 4 +- fs/fuse/dir.c | 13 +-- fs/fuse/inode.c | 16 ++-- fs/fuse/readdir.c | 4 +- fs/gfs2/inode.c | 4 +- fs/hfs/btree.c | 2 +- fs/hfs/dir.c | 2 - fs/hfs/inode.c | 8 +- fs/hfs/super.c | 4 +- fs/hfsplus/super.c | 4 +- fs/hostfs/hostfs_kern.c | 4 +- fs/hpfs/dir.c | 3 +- fs/hpfs/inode.c | 2 +- fs/hpfs/super.c | 2 +- fs/inode.c | 126 +++++++++++++++----------- fs/isofs/inode.c | 4 +- fs/jffs2/fs.c | 4 +- fs/jfs/inode.c | 4 +- fs/kernfs/inode.c | 8 +- fs/kernfs/mount.c | 4 +- fs/minix/inode.c | 4 +- fs/nfs/inode.c | 4 +- fs/nilfs2/cpfile.c | 4 +- fs/nilfs2/dat.c | 4 +- fs/nilfs2/ifile.c | 4 +- fs/nilfs2/inode.c | 16 ++-- fs/nilfs2/sufile.c | 4 +- fs/ntfs/inode.c | 12 +-- fs/ntfs3/inode.c | 4 +- fs/ocfs2/inode.c | 3 +- fs/openpromfs/inode.c | 5 +- fs/orangefs/inode.c | 4 +- fs/overlayfs/inode.c | 10 +- fs/qnx4/inode.c | 4 +- fs/qnx6/inode.c | 4 +- fs/romfs/super.c | 4 +- fs/smb/client/file.c | 5 +- fs/smb/client/inode.c | 12 ++- fs/smb/client/readdir.c | 2 - fs/squashfs/inode.c | 4 +- fs/ubifs/super.c | 4 +- fs/udf/inode.c | 4 +- fs/ufs/inode.c | 4 +- fs/vboxsf/super.c | 4 +- fs/zonefs/super.c | 8 +- include/linux/kernfs.h | 2 +- kernel/cgroup/cgroup.c | 4 +- 64 files changed, 251 insertions(+), 219 deletions(-) base-commit: 84fb6f8a1ba91eee3ffe6aa519686fce851a0e42 -- 2.56.1