From: Brian Norris <briannorris@chromium.org>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, Brian Norris <briannorris@chromium.org>
Subject: [PATCH] lib/ext2fs: Validity checks for ext2fs_inode_scan_goto_blockgroup()
Date: Thu, 30 Nov 2023 16:01:18 -0800 [thread overview]
Message-ID: <20231201000126.335263-1-briannorris@chromium.org> (raw)
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.
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
next reply other threads:[~2023-12-01 0:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-01 0:01 Brian Norris [this message]
2023-12-01 16:24 ` [PATCH] lib/ext2fs: Validity checks for ext2fs_inode_scan_goto_blockgroup() Darrick J. Wong
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=20231201000126.335263-1-briannorris@chromium.org \
--to=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