From: Lukas Czerner <lczerner@redhat.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: "Ext4 Developers List" <linux-ext4@vger.kernel.org>,
"Nils Bars" <nils.bars@rub.de>,
"Moritz Schlögel" <moritz.schloegel@rub.de>,
"Nico Schiller" <nico.schiller@rub.de>
Subject: Re: [PATCH 2/7] e2fsck: fix potential out-of-bounds read in inc_ea_inode_refs()
Date: Tue, 7 Jun 2022 15:30:52 +0200 [thread overview]
Message-ID: <20220607133052.vyao56ajey57a2ih@fedora> (raw)
In-Reply-To: <20220607042444.1798015-3-tytso@mit.edu>
On Tue, Jun 07, 2022 at 12:24:39AM -0400, Theodore Ts'o wrote:
> If there isn't enough space for a full extended attribute entry,
> inc_ea_inode_refs() might end up reading beyond the allocated memory
> buffer.
Looks good.
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
>
> Reported-by: Nils Bars <nils.bars@rub.de>
> Reported-by: Moritz Schlögel <moritz.schloegel@rub.de>
> Reported-by: Nico Schiller <nico.schiller@rub.de>
> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
> ---
> e2fsck/pass1.c | 13 ++++++++-----
> 1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
> index dde862a8..2a17bb8a 100644
> --- a/e2fsck/pass1.c
> +++ b/e2fsck/pass1.c
> @@ -389,13 +389,13 @@ static problem_t check_large_ea_inode(e2fsck_t ctx,
> static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx,
> struct ext2_ext_attr_entry *first, void *end)
> {
> - struct ext2_ext_attr_entry *entry;
> + struct ext2_ext_attr_entry *entry = first;
> + struct ext2_ext_attr_entry *np = EXT2_EXT_ATTR_NEXT(entry);
>
> - for (entry = first;
> - (void *)entry < end && !EXT2_EXT_IS_LAST_ENTRY(entry);
> - entry = EXT2_EXT_ATTR_NEXT(entry)) {
> + while ((void *) entry < end && (void *) np < end &&
> + !EXT2_EXT_IS_LAST_ENTRY(entry)) {
> if (!entry->e_value_inum)
> - continue;
> + goto next;
> if (!ctx->ea_inode_refs) {
> pctx->errcode = ea_refcount_create(0,
> &ctx->ea_inode_refs);
> @@ -408,6 +408,9 @@ static void inc_ea_inode_refs(e2fsck_t ctx, struct problem_context *pctx,
> }
> ea_refcount_increment(ctx->ea_inode_refs, entry->e_value_inum,
> 0);
> + next:
> + entry = np;
> + np = EXT2_EXT_ATTR_NEXT(entry);
> }
> }
>
> --
> 2.31.0
>
next prev parent reply other threads:[~2022-06-07 13:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-07 4:24 [PATCH 0/7] Fix various bugs found via a fuzzing campaign Theodore Ts'o
2022-06-07 4:24 ` [PATCH 1/7] e2fsck: sanity check the journal inode number Theodore Ts'o
2022-06-07 13:12 ` Lukas Czerner
2022-06-07 4:24 ` [PATCH 2/7] e2fsck: fix potential out-of-bounds read in inc_ea_inode_refs() Theodore Ts'o
2022-06-07 13:30 ` Lukas Czerner [this message]
2022-06-07 4:24 ` [PATCH 3/7] libext2fs: add check for too-short directory blocks Theodore Ts'o
2022-06-07 13:31 ` Lukas Czerner
2022-06-07 4:24 ` [PATCH 4/7] e2fsck: check for xattr value size integer wraparound Theodore Ts'o
2022-06-07 13:33 ` Lukas Czerner
2022-06-07 4:24 ` [PATCH 5/7] e2fsck: avoid out-of-bounds write for very deep extent trees Theodore Ts'o
2022-06-07 13:53 ` Lukas Czerner
2022-06-07 4:24 ` [PATCH 6/7] libext2fs: check for cyclic loops in the extent tree Theodore Ts'o
2022-06-07 14:11 ` Lukas Czerner
2022-06-07 4:24 ` [PATCH 7/7] libext2fs: check for invalid blocks in ext2fs_punch_blocks() Theodore Ts'o
2022-06-07 14:22 ` Lukas Czerner
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=20220607133052.vyao56ajey57a2ih@fedora \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=moritz.schloegel@rub.de \
--cc=nico.schiller@rub.de \
--cc=nils.bars@rub.de \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).