EcryptFS development
 help / color / mirror / Atom feed
From: Tyler Hicks <code@tyhicks.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.com>, Al Viro <viro@zeniv.linux.org.uk>,
	ecryptfs@vger.kernel.org, linux-ext4@vger.kernel.org,
	jfs-discussion@lists.sourceforge.net,
	linux-nilfs@vger.kernel.org, exfat@lists.linux.dev,
	linux-fsdevel@vger.kernel.org, ntfs@lists.linux.dev,
	ocfs2-devel@lists.linux.dev, linux-btrfs@vger.kernel.org,
	gfs2@lists.linux.dev, linux-efi@vger.kernel.org,
	linux-mtd@lists.infradead.org, linux-xfs@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH RFC 01/28] ecryptfs: don't leak the inode when a lookup can't open the lower file
Date: Tue, 13 Oct 2026 23:40:28 -0500	[thread overview]
Message-ID: <as8HvJJq-JP5-UCp@elm> (raw)
In-Reply-To: <20261012-work-fs-sb_rdonly-v1-1-60743a3dc326@kernel.org>

On 2026-10-12 12:20:46, Christian Brauner wrote:
> ecryptfs_lookup_interpose() opens the lower file of a regular file to
> read the size from the header. If that fails it calls make_bad_inode()
> and returns the error. A new inode is still I_NEW at that point and
> nothing ever unlocks or puts it, so it leaks together with the reference
> it holds on the lower inode. And an inode that was already in the cache
> gets marked bad for all its other users instead of just losing the
> reference this lookup took.
> 
> umount then complains:
> 
>   VFS: Busy inodes after unmount of ecryptfs (ecryptfs)
> 
> That's a WARN, or a BUG with CONFIG_BUG_ON_DATA_CORRUPTION. The lower
> filesystem reports the same when it is unmounted. Use iget_failed() for
> a new inode and iput() for one from the cache.
> 
> Reproducer, opening the lower file read-write fails on a read-only bind
> mount:
> 
>   sig=$(printf x | ecryptfs-add-passphrase - | sed -n 's/.*\[\(.*\)\].*/\1/p')
>   mount --bind -o ro /lower /lower
>   mount -i -t ecryptfs -o ecryptfs_sig=$sig,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough /lower /upper
>   cat /upper/f      # EROFS
>   umount /upper     # VFS: Busy inodes after unmount of ecryptfs
> 
> Fixes: 3b06b3ebf441 ("eCryptfs: Fix new inode race condition")
> Cc: stable@vger.kernel.org
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>

Thanks, Christian! I ran this through the regression tests in the
ecryptfs-utils project and everything passed. I also followed the steps
in your reproducer, with and without this change, and verified that it
fixes the intended issue.

  Acked-by: Tyler Hicks <code@tyhicks.com>

Tyler

> ---
>  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 525297c7ebd8..0d8452558a98 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
> 
> 

  reply	other threads:[~2026-10-14  4:40 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 10:20 [PATCH RFC 00/28] fs: don't set SB_RDONLY after filesystem errors Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 01/28] ecryptfs: don't leak the inode when a lookup can't open the lower file Christian Brauner
2026-10-14  4:40   ` Tyler Hicks [this message]
2026-10-12 10:20 ` [PATCH RFC 02/28] ecryptfs: fall back to a read-only " Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 03/28] ext2: don't set SB_RDONLY after filesystem errors Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 04/28] jfs: " Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 05/28] nilfs2: " Christian Brauner
2026-10-13 16:01   ` Ryusuke Konishi
2026-10-12 10:20 ` [PATCH RFC 06/28] fat: " Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 07/28] exfat: keep the current mount options on remount Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 08/28] exfat: don't set SB_RDONLY after filesystem errors Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 09/28] hfs: don't set SB_RDONLY after MDB write errors Christian Brauner
2026-10-12 22:57   ` [Jfs-discussion] " Viacheslav Dubeyko
2026-10-12 10:20 ` [PATCH RFC 10/28] hfsplus: don't set SB_RDONLY when creating the attributes tree Christian Brauner
2026-10-12 22:34   ` [Jfs-discussion] " Viacheslav Dubeyko
2026-10-12 10:20 ` [PATCH RFC 11/28] affs: don't set SB_RDONLY after filesystem errors Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 12/28] ufs: " Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 13/28] hpfs: " Christian Brauner
2026-10-12 10:20 ` [PATCH RFC 14/28] ntfs: " Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 15/28] ocfs2: keep options that can't change on remount Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 16/28] ocfs2: don't set SB_RDONLY after filesystem errors Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 17/28] zonefs: don't set SB_RDONLY after I/O errors Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 18/28] btrfs: check BTRFS_FS_STATE_RO instead of SB_RDONLY at runtime Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 19/28] btrfs: don't set SB_RDONLY after filesystem errors Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 20/28] gfs2: wait for a pending withdraw before remounting read-only Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 21/28] gfs2: don't set SB_RDONLY on withdraw Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 22/28] efivarfs: stop using SB_RDONLY for read-only efivar ops Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 23/28] ubifs: don't set SB_RDONLY after errors Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 24/28] selftests/filesystems: test filesystem errors while frozen Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 25/28] ext4: allow remounting read-only in the emergency state Christian Brauner
2026-10-12 16:38   ` Jan Kara
2026-10-12 10:21 ` [PATCH RFC 26/28] selftests/filesystems: test ext4 remounts " Christian Brauner
2026-10-12 10:21 ` [PATCH RFC 27/28] xfs: allow remounting read-only after a shutdown Christian Brauner
2026-10-13  7:38   ` Christoph Hellwig
2026-10-12 10:21 ` [PATCH RFC 28/28] selftests/filesystems: test xfs remounts " Christian Brauner
2026-10-13  7:40   ` Christoph Hellwig
2026-10-12 16:53 ` [PATCH RFC 00/28] fs: don't set SB_RDONLY after filesystem errors Jan Kara
2026-10-13 19:39   ` Christian Brauner
2026-10-14 10:04     ` Andreas Gruenbacher
2026-10-14 13:47       ` Jan Kara
2026-10-14 13:41     ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=as8HvJJq-JP5-UCp@elm \
    --to=code@tyhicks.com \
    --cc=brauner@kernel.org \
    --cc=ecryptfs@vger.kernel.org \
    --cc=exfat@lists.linux.dev \
    --cc=gfs2@lists.linux.dev \
    --cc=jack@suse.com \
    --cc=jfs-discussion@lists.sourceforge.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-nilfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ntfs@lists.linux.dev \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox