* [PATCH v2] e2fsck: Fix access after free for dx_db structure
@ 2017-11-04 17:22 Artem Blagodarenko
2017-11-06 5:49 ` Andreas Dilger
0 siblings, 1 reply; 3+ messages in thread
From: Artem Blagodarenko @ 2017-11-04 17:22 UTC (permalink / raw)
To: linux-ext4; +Cc: adilger.kernel
dx_db structure is freed after fixing of PR_2_HTREE_BAD_ROOT
problem. Next code block use this structure to unerstand if leaf
is beeng processed.
If dx_db is freed, then root block is being processed and if_leaf
need to be set to 0.
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
---
e2fsck/pass2.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index 09c16179..1b0504c8 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -1095,7 +1095,7 @@ inline_read_fail:
fix_problem(ctx, PR_2_HTREE_BAD_ROOT, &cd->pctx)) {
clear_htree(ctx, ino);
dx_dir->numblocks = 0;
- dx_db = 0;
+ dx_db = NULL;
}
dx_dir->hashversion = root->hash_version;
if ((dx_dir->hashversion <= EXT2_HASH_TEA) &&
@@ -1107,9 +1107,10 @@ inline_read_fail:
(ext2fs_dirent_name_len(dirent) == 0) &&
(ext2fs_le16_to_cpu(limit->limit) ==
((fs->blocksize - (8 + dx_csum_size)) /
- sizeof(struct ext2_dx_entry))))
+ sizeof(struct ext2_dx_entry)))) {
dx_db->type = DX_DIRBLOCK_NODE;
- is_leaf = (dx_db->type == DX_DIRBLOCK_LEAF);
+ }
+ is_leaf = dx_db ? (dx_db->type == DX_DIRBLOCK_LEAF) : 0;
}
out_htree:
--
2.13.5 (Apple Git-94)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] e2fsck: Fix access after free for dx_db structure
2017-11-04 17:22 [PATCH v2] e2fsck: Fix access after free for dx_db structure Artem Blagodarenko
@ 2017-11-06 5:49 ` Andreas Dilger
2017-12-05 3:11 ` Theodore Ts'o
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Dilger @ 2017-11-06 5:49 UTC (permalink / raw)
To: Artem Blagodarenko; +Cc: linux-ext4
[-- Attachment #1: Type: text/plain, Size: 1535 bytes --]
On Nov 4, 2017, at 11:22 AM, Artem Blagodarenko <artem.blagodarenko@gmail.com> wrote:
>
> dx_db structure is freed after fixing of PR_2_HTREE_BAD_ROOT
> problem. Next code block use this structure to unerstand if leaf
> is beeng processed.
>
> If dx_db is freed, then root block is being processed and if_leaf
> need to be set to 0.
>
> Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
> ---
> e2fsck/pass2.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
> index 09c16179..1b0504c8 100644
> --- a/e2fsck/pass2.c
> +++ b/e2fsck/pass2.c
> @@ -1095,7 +1095,7 @@ inline_read_fail:
> fix_problem(ctx, PR_2_HTREE_BAD_ROOT, &cd->pctx)) {
> clear_htree(ctx, ino);
> dx_dir->numblocks = 0;
> - dx_db = 0;
> + dx_db = NULL;
> }
> dx_dir->hashversion = root->hash_version;
> if ((dx_dir->hashversion <= EXT2_HASH_TEA) &&
> @@ -1107,9 +1107,10 @@ inline_read_fail:
> (ext2fs_dirent_name_len(dirent) == 0) &&
> (ext2fs_le16_to_cpu(limit->limit) ==
> ((fs->blocksize - (8 + dx_csum_size)) /
> - sizeof(struct ext2_dx_entry))))
> + sizeof(struct ext2_dx_entry)))) {
> dx_db->type = DX_DIRBLOCK_NODE;
> - is_leaf = (dx_db->type == DX_DIRBLOCK_LEAF);
> + }
> + is_leaf = dx_db ? (dx_db->type == DX_DIRBLOCK_LEAF) : 0;
> }
> out_htree:
>
> --
> 2.13.5 (Apple Git-94)
>
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] e2fsck: Fix access after free for dx_db structure
2017-11-06 5:49 ` Andreas Dilger
@ 2017-12-05 3:11 ` Theodore Ts'o
0 siblings, 0 replies; 3+ messages in thread
From: Theodore Ts'o @ 2017-12-05 3:11 UTC (permalink / raw)
To: Andreas Dilger; +Cc: Artem Blagodarenko, linux-ext4
On Sun, Nov 05, 2017 at 10:49:55PM -0700, Andreas Dilger wrote:
> On Nov 4, 2017, at 11:22 AM, Artem Blagodarenko <artem.blagodarenko@gmail.com> wrote:
> >
> > dx_db structure is freed after fixing of PR_2_HTREE_BAD_ROOT
> > problem. Next code block use this structure to unerstand if leaf
> > is beeng processed.
> >
> > If dx_db is freed, then root block is being processed and if_leaf
> > need to be set to 0.
> >
> > Signed-off-by: Artem Blagodarenko <artem.blagodarenko@gmail.com>
>
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Thanks, applied.
- Ted
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-05 3:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-04 17:22 [PATCH v2] e2fsck: Fix access after free for dx_db structure Artem Blagodarenko
2017-11-06 5:49 ` Andreas Dilger
2017-12-05 3:11 ` Theodore Ts'o
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.