public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Brian Norris <briannorris@chromium.org>
Cc: Theodore Ts'o <tytso@mit.edu>, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] lib/ext2fs: Validity checks for ext2fs_inode_scan_goto_blockgroup()
Date: Fri, 1 Dec 2023 08:24:10 -0800	[thread overview]
Message-ID: <20231201162410.GA36164@frogsfrogsfrogs> (raw)
In-Reply-To: <20231201000126.335263-1-briannorris@chromium.org>

On Thu, Nov 30, 2023 at 04:01:18PM -0800, Brian Norris wrote:
> We don't validate the 'group' argument, so it's easy to get underflows
> or crashes here.
> 
> This resolves issues seen in ureadahead, when it uses an old packfile
> (with mismatching group indices) with a new filesystem.

Say what now?  The boot time pre-caching thing Ubuntu used to have?
https://manpages.ubuntu.com/manpages/trusty/man8/ureadahead.8.html

--D

> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
> 
>  lib/ext2fs/inode.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
> index 957d5aa9f9d6..96d854b5fb69 100644
> --- a/lib/ext2fs/inode.c
> +++ b/lib/ext2fs/inode.c
> @@ -313,6 +313,9 @@ static errcode_t get_next_blockgroup(ext2_inode_scan scan)
>  errcode_t ext2fs_inode_scan_goto_blockgroup(ext2_inode_scan scan,
>  					    int	group)
>  {
> +	if (group <= 0 || group >= scan->fs->group_desc_count)
> +		return EXT2_ET_INVALID_ARGUMENT;
> +
>  	scan->current_group = group - 1;
>  	scan->groups_left = scan->fs->group_desc_count - group;
>  	scan->bad_block_ptr = 0;
> -- 
> 2.43.0.rc2.451.g8631bc7472-goog
> 
> 

  reply	other threads:[~2023-12-01 16:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01  0:01 [PATCH] lib/ext2fs: Validity checks for ext2fs_inode_scan_goto_blockgroup() Brian Norris
2023-12-01 16:24 ` Darrick J. Wong [this message]
2023-12-01 17:30   ` Brian Norris
2023-12-02 17:10     ` Darrick J. Wong

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=20231201162410.GA36164@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=briannorris@chromium.org \
    --cc=linux-ext4@vger.kernel.org \
    --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