2007-02-26 22:33:25

by Andreas Dilger

[permalink] [raw]
Subject: [PATCH] added sanity check for xattr validation

Ted,
the attached patch adds an extra validity test in check_ext_attr(). If
an attribute's e_value_size is zero the current code does not allocate
a region for it and as a result the e_value_offs value is not verified.
However, if e_value_offs is very large then the later call to
ext2fs_ext_attr_hash_entry() can dereference bad memory and crash e2fsck.

Signed-off-by: Andreas Dilger <[email protected]>
Signed-off-by: Jim Garlick <[email protected]>

=========================== e_value_offs.patch ============================

Index: e2fsprogs-1.39/e2fsck/pass1.c
===================================================================
--- e2fsprogs-1.39.orig/e2fsck/pass1.c 2007-02-10 15:43:36.000000000 +0530
+++ e2fsprogs-1.39/e2fsck/pass1.c 2007-02-10 15:45:36.000000000 +0530
@@ -1346,6 +1347,11 @@
if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx))
goto clear_extattr;
}
+ if (entry->e_value_offs + entry->e_value_size > fs->blocksize) {
+ if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx))
+ goto clear_extattr;
+ break;
+ }
if (entry->e_value_size &&
region_allocate(region, entry->e_value_offs,
EXT2_EXT_ATTR_SIZE(entry->e_value_size))) {
=========================== e_value_offs.patch ============================

Cheers, Andreas
--
Andreas Dilger
Principal Software Engineer
Cluster File Systems, Inc.


2007-06-21 20:50:56

by Eric Sandeen

[permalink] [raw]
Subject: Re: [PATCH] added sanity check for xattr validation

Andreas Dilger wrote:
> Ted,
> the attached patch adds an extra validity test in check_ext_attr(). If
> an attribute's e_value_size is zero the current code does not allocate
> a region for it and as a result the e_value_offs value is not verified.
> However, if e_value_offs is very large then the later call to
> ext2fs_ext_attr_hash_entry() can dereference bad memory and crash e2fsck.

Did this patch get lost? Don't see it in Hg...

Thanks,
-Eric

> Signed-off-by: Andreas Dilger <[email protected]>
> Signed-off-by: Jim Garlick <[email protected]>
>
> =========================== e_value_offs.patch ============================
>
> Index: e2fsprogs-1.39/e2fsck/pass1.c
> ===================================================================
> --- e2fsprogs-1.39.orig/e2fsck/pass1.c 2007-02-10 15:43:36.000000000 +0530
> +++ e2fsprogs-1.39/e2fsck/pass1.c 2007-02-10 15:45:36.000000000 +0530
> @@ -1346,6 +1347,11 @@
> if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx))
> goto clear_extattr;
> }
> + if (entry->e_value_offs + entry->e_value_size > fs->blocksize) {
> + if (fix_problem(ctx, PR_1_EA_BAD_VALUE, pctx))
> + goto clear_extattr;
> + break;
> + }
> if (entry->e_value_size &&
> region_allocate(region, entry->e_value_offs,
> EXT2_EXT_ATTR_SIZE(entry->e_value_size))) {
> =========================== e_value_offs.patch ============================
>
> Cheers, Andreas
> --
> Andreas Dilger
> Principal Software Engineer
> Cluster File Systems, Inc.
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2007-06-22 06:23:21

by Theodore Ts'o

[permalink] [raw]
Subject: Re: [PATCH] added sanity check for xattr validation

On Thu, Jun 21, 2007 at 03:50:37PM -0500, Eric Sandeen wrote:
> Andreas Dilger wrote:
> > Ted,
> > the attached patch adds an extra validity test in check_ext_attr(). If
> > an attribute's e_value_size is zero the current code does not allocate
> > a region for it and as a result the e_value_offs value is not verified.
> > However, if e_value_offs is very large then the later call to
> > ext2fs_ext_attr_hash_entry() can dereference bad memory and crash e2fsck.
>
> Did this patch get lost? Don't see it in Hg...

Thanks, I just committed it.

-Ted