[PATCH v2 01/34] ecryptfs: don't leak the inode when a lookup can't open the lower file
Christian Brauner
brauner at kernel.org
Thu Oct 29 09:06:52 PDT 2026
ecryptfs_lookup_interpose() opens the lower file of a regular file to
read the size from the header. If that fails it marks the inode bad and
returns, but a new inode is still I_NEW and nobody ever unlocks or puts
it. So it leaks together with its lower inode, a concurrent lookup
through another hard link waits for it forever and umount complains
about busy inodes. The lower open fails e.g. with ETXTBSY while the
lower file is executed. A cached inode is marked bad for all its other
users instead.
Use iget_failed() for a new inode and iput() for a cached one.
Fixes: 3b06b3ebf441 ("eCryptfs: Fix new inode race condition")
Cc: stable at vger.kernel.org
Reported-by: Farhad Alemi <farhad.alemi at berkeley.edu>
Closes: https://lore.kernel.org/r/CA+0ovCgYP920GT68hAJK6Trjyv1kGv2dZAuem4LEunycQ=POww@mail.gmail.com
Acked-by: Tyler Hicks <code at tyhicks.com>
Signed-off-by: Christian Brauner (Amutable) <brauner at kernel.org>
---
fs/ecryptfs/inode.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 48e520960d66..3a966348a578 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -362,7 +362,10 @@ static struct dentry *ecryptfs_lookup_interpose(struct dentry *dentry,
if (S_ISREG(inode->i_mode)) {
rc = ecryptfs_i_size_read(dentry, inode);
if (rc) {
- make_bad_inode(inode);
+ if (inode_state_read_once(inode) & I_NEW)
+ iget_failed(inode);
+ else
+ iput(inode);
return ERR_PTR(rc);
}
}
--
2.53.0
More information about the linux-mtd
mailing list