public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Tyler Hicks <code@tyhicks.com>
To: Thorsten Blum <thorsten.blum@linux.dev>
Cc: Ard Biesheuvel <ardb@kernel.org>,
	Zipeng Zhang <zhangzipeng0@foxmail.com>,
	Christian Brauner <brauner@kernel.org>,
	Eric Biggers <ebiggers@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org, ecryptfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ecryptfs: Add missing gotos in ecryptfs_read_metadata
Date: Mon, 12 Jan 2026 13:21:45 -0600	[thread overview]
Message-ID: <aWVJyRtk-7Wijd8J@yaupon> (raw)
In-Reply-To: <20260111003655.491722-1-thorsten.blum@linux.dev>

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@vger.kernel.org
> Fixes: dd2a3b7ad98f ("[PATCH] eCryptfs: Generalize metadata read/write")
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.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@linux.dev>
> GPG: 1D60 735E 8AEF 3BE4 73B6  9D84 7336 78FD 8DFE EAD4
> 

      parent reply	other threads:[~2026-01-12 19:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-11  0:36 [PATCH] ecryptfs: Add missing gotos in ecryptfs_read_metadata Thorsten Blum
2026-01-11  1:08 ` Al Viro
2026-01-11 12:28   ` Thorsten Blum
2026-01-12 19:23     ` Tyler Hicks
2026-01-12 19:21 ` Tyler Hicks [this message]

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=aWVJyRtk-7Wijd8J@yaupon \
    --to=code@tyhicks.com \
    --cc=akpm@linux-foundation.org \
    --cc=ardb@kernel.org \
    --cc=brauner@kernel.org \
    --cc=ebiggers@kernel.org \
    --cc=ecryptfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=thorsten.blum@linux.dev \
    --cc=zhangzipeng0@foxmail.com \
    /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