On Sat, Jul 15, 2023 at 01:20:23PM +0800, Weichao Guo wrote:
> As the fscrypt context has two versions now, this patch adds the
> support of fscrypt_context_v2 for print_xattr_entry.
> 
> Signed-off-by: Weichao Guo <[email protected]>
> Signed-off-by: Sheng Yong <[email protected]>
> ---
>  fsck/mount.c | 48 ++++++++++++++++++++++++++++++----------------
>  fsck/xattr.h | 54 +++++++++++++++++++++++++++++++++++++++++++---------
>  2 files changed, 77 insertions(+), 25 deletions(-)
> 
> diff --git a/fsck/mount.c b/fsck/mount.c
> index df0314d..1900b84 100644
> --- a/fsck/mount.c
> +++ b/fsck/mount.c
> @@ -194,7 +194,7 @@ static void print_xattr_entry(const struct 
> f2fs_xattr_entry *ent)
>  {
>       const u8 *value = (const u8 *)&ent->e_name[ent->e_name_len];
>       const int size = le16_to_cpu(ent->e_value_size);
> -     const struct fscrypt_context *ctx;
> +     const union fscrypt_context *ctx;
>       int i;
>  
>       MSG(0, "\nxattr: e_name_index:%d e_name:", ent->e_name_index);
> @@ -211,22 +211,38 @@ static void print_xattr_entry(const struct 
> f2fs_xattr_entry *ent)
>               return;
>  #endif
>       case F2FS_XATTR_INDEX_ENCRYPTION:
> -             ctx = (const struct fscrypt_context *)value;
> -             if (size != sizeof(*ctx) ||
> -                 ctx->format != FS_ENCRYPTION_CONTEXT_FORMAT_V1)
> +             ctx = (const union fscrypt_context *)value;
> +             if (size != fscrypt_context_size(ctx))
>                       break;

As I mentioned on v2, if size == 0, this will read past the end of the xattr
value.

- Eric


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to