lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <v4ylesmu73htrqf6voqz2r7yw5ngwoasamlgfpi7fjbbbjzh6a@h46y5uvefkvo>
Date: Thu, 24 Oct 2024 07:23:02 -0400
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Gianfranco Trad <gianf.trad@...il.com>
Cc: linux-bcachefs@...r.kernel.org, linux-kernel@...r.kernel.org, 
	skhan@...uxfoundation.org, syzbot+089fad5a3a5e77825426@...kaller.appspotmail.com
Subject: Re: [PATCH] bcachefs: Fix invalid shift in validate_sb_layout()

On Wed, Oct 23, 2024 at 11:30:44PM +0200, Gianfranco Trad wrote:
> Add check on layout->sb_max_size_bits against BCH_SB_LAYOUT_SIZE_BITS_MAX
> to prevent UBSAN shift-out-of-bounds in validate_sb_layout().
> 
> Reported-by: syzbot+089fad5a3a5e77825426@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=089fad5a3a5e77825426
> Fixes: 03ef80b469d5 ("bcachefs: Ignore unknown mount options")
> Tested-by: syzbot+089fad5a3a5e77825426@...kaller.appspotmail.com
> Signed-off-by: Gianfranco Trad <gianf.trad@...il.com>

looks correct, applied

> ---
>  fs/bcachefs/errcode.h  | 1 +
>  fs/bcachefs/super-io.c | 5 +++++
>  2 files changed, 6 insertions(+)
> 
> diff --git a/fs/bcachefs/errcode.h b/fs/bcachefs/errcode.h
> index 649263516ab1..b6cbd716000b 100644
> --- a/fs/bcachefs/errcode.h
> +++ b/fs/bcachefs/errcode.h
> @@ -222,6 +222,7 @@
>  	x(BCH_ERR_invalid_sb_layout,	invalid_sb_layout_type)			\
>  	x(BCH_ERR_invalid_sb_layout,	invalid_sb_layout_nr_superblocks)	\
>  	x(BCH_ERR_invalid_sb_layout,	invalid_sb_layout_superblocks_overlap)	\
> +	x(BCH_ERR_invalid_sb_layout,    invalid_sb_layout_sb_max_size_bits)     \
>  	x(BCH_ERR_invalid_sb,		invalid_sb_members_missing)		\
>  	x(BCH_ERR_invalid_sb,		invalid_sb_members)			\
>  	x(BCH_ERR_invalid_sb,		invalid_sb_disk_groups)			\
> diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
> index ce7410d72089..44d0ac9b00dd 100644
> --- a/fs/bcachefs/super-io.c
> +++ b/fs/bcachefs/super-io.c
> @@ -287,6 +287,11 @@ static int validate_sb_layout(struct bch_sb_layout *layout, struct printbuf *out
>  		return -BCH_ERR_invalid_sb_layout_nr_superblocks;
>  	}
>  
> +	if (layout->sb_max_size_bits > BCH_SB_LAYOUT_SIZE_BITS_MAX) {
> +		prt_printf(out, "Invalid superblock layout: max_size_bits too high");
> +		return -BCH_ERR_invalid_sb_layout_sb_max_size_bits;
> +	}
> +
>  	max_sectors = 1 << layout->sb_max_size_bits;
>  
>  	prev_offset = le64_to_cpu(layout->sb_offset[0]);
> -- 
> 2.43.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ