From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: Jan Kara <jack@suse.cz>, linux-ext4@vger.kernel.org
Cc: syzbot+4fec412f59eba8c01b77@syzkaller.appspotmail.com
Subject: Re: [PATCH 2/2] ext2: Check block size validity during mount
Date: Wed, 1 Mar 2023 11:37:20 +0000 [thread overview]
Message-ID: <d2a5be55-4bcb-da7e-fae5-9cc598223b17@linaro.org> (raw)
In-Reply-To: <20230301111238.22856-2-jack@suse.cz>
Hi!
On 3/1/23 11:12, Jan Kara wrote:
> Check that log of block size stored in the superblock has sensible
> value. Otherwise the shift computing the block size can overflow leading
> to undefined behavior.
>
> Reported-by: syzbot+4fec412f59eba8c01b77@syzkaller.appspotmail.com
Would be helpful to also have:
LINK: https://syzkaller.appspot.com/bug?extid=4fec412f59eba8c01b77
a "Fixes:" tag and
Cc: stable@vger.kernel.org
Cheers,
ta
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/ext2/ext2.h | 1 +
> fs/ext2/super.c | 7 +++++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index 6c8e838bb278..8244366862e4 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -180,6 +180,7 @@ static inline struct ext2_sb_info *EXT2_SB(struct super_block *sb)
> #define EXT2_MIN_BLOCK_SIZE 1024
> #define EXT2_MAX_BLOCK_SIZE 65536
> #define EXT2_MIN_BLOCK_LOG_SIZE 10
> +#define EXT2_MAX_BLOCK_LOG_SIZE 16
> #define EXT2_BLOCK_SIZE(s) ((s)->s_blocksize)
> #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
> #define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_blocksize_bits)
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 69c88facfe90..f342f347a695 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -945,6 +945,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> goto failed_mount;
> }
>
> + if (le32_to_cpu(es->s_log_block_size) >
> + (EXT2_MAX_BLOCK_LOG_SIZE - BLOCK_SIZE_BITS)) {
> + ext2_msg(sb, KERN_ERR,
> + "Invalid log block size: %u",
> + le32_to_cpu(es->s_log_block_size));
> + goto failed_mount;
> + }
> blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
>
> if (test_opt(sb, DAX)) {
next prev parent reply other threads:[~2023-03-01 11:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-01 11:12 [PATCH 0/2] ext2: Refuse filesystems with invalid block size Jan Kara
2023-03-01 11:12 ` [PATCH 1/2] ext2: Correct maximum ext2 filesystem " Jan Kara
2023-03-01 11:12 ` [PATCH 2/2] ext2: Check block size validity during mount Jan Kara
2023-03-01 11:37 ` Tudor Ambarus [this message]
2023-03-01 13:05 ` Jan Kara
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=d2a5be55-4bcb-da7e-fae5-9cc598223b17@linaro.org \
--to=tudor.ambarus@linaro.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=syzbot+4fec412f59eba8c01b77@syzkaller.appspotmail.com \
/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