[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aWVJyRtk-7Wijd8J@yaupon>
Date: Mon, 12 Jan 2026 13:21:45 -0600
From: Tyler Hicks <code@...icks.com>
To: Thorsten Blum <thorsten.blum@...ux.dev>
Cc: Ard Biesheuvel <ardb@...nel.org>,
Zipeng Zhang <zhangzipeng0@...mail.com>,
Christian Brauner <brauner@...nel.org>,
Eric Biggers <ebiggers@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>, stable@...r.kernel.org,
ecryptfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ecryptfs: Add missing gotos in ecryptfs_read_metadata
On 2026-01-11 01:36:52, Thorsten Blum wrote:
> Add two missing goto statements to exit ecryptfs_read_metadata() when an
> error occurs.
>
> The first goto is required; otherwise ECRYPTFS_METADATA_IN_XATTR may be
> set when xattr metadata is enabled even though parsing the metadata
> failed. The second goto is not strictly necessary, but it makes the
> error path explicit instead of relying on falling through to 'out'.
Hey Thorsten - It seems like there's a bug here but I don't think this
is the actual bug. At the top of ecryptfs_read_metadata(), we call
ecryptfs_copy_mount_wide_flags_to_inode_flags() to copy the mount-wide
crypt_stat flags to the inode's crypt_stat flags. Therefore, the current
code is already redundant in setting ECRYPTFS_METADATA_IN_XATTR after
ecryptfs_read_headers_virt(). No matter if it succeeds or fails.
This logic is confusing but, IIRC, the goal is to handle files with
header metadata and files with xattr metadata within the same mount. I
think the real bug may be that we're not clearing the inode's
ECRYPTFS_METADATA_IN_XATTR flag when the mount crypt stat has the
ECRYPTFS_XATTR_METADATA_ENABLED flag set and
ecryptfs_read_headers_virt() returns success. I haven't looked at what
impact that has elsewhere in the code.
However, it has been a long time since I've looked at this code. I'd
like your thoughts. Thanks!
Tyler
>
> Cc: stable@...r.kernel.org
> Fixes: dd2a3b7ad98f ("[PATCH] eCryptfs: Generalize metadata read/write")
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
> fs/ecryptfs/crypto.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c
> index 260f8a4938b0..d49cdf7292ab 100644
> --- a/fs/ecryptfs/crypto.c
> +++ b/fs/ecryptfs/crypto.c
> @@ -1328,6 +1328,7 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
> "file xattr region either, inode %lu\n",
> ecryptfs_inode->i_ino);
> rc = -EINVAL;
> + goto out;
> }
> if (crypt_stat->mount_crypt_stat->flags
> & ECRYPTFS_XATTR_METADATA_ENABLED) {
> @@ -1340,6 +1341,7 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry)
> "this like an encrypted file, inode %lu\n",
> ecryptfs_inode->i_ino);
> rc = -EINVAL;
> + goto out;
> }
> }
> out:
> --
> Thorsten Blum <thorsten.blum@...ux.dev>
> GPG: 1D60 735E 8AEF 3BE4 73B6 9D84 7336 78FD 8DFE EAD4
>
Powered by blists - more mailing lists