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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <cfcd3737-3b03-87fe-39e8-566e545cab3a@huawei.com>
Date:   Wed, 3 Jul 2019 10:07:11 +0800
From:   Chao Yu <yuchao0@...wei.com>
To:     Ocean Chen <oceanchen@...gle.com>, <jaegeuk@...nel.org>,
        <linux-f2fs-devel@...ts.sourceforge.net>,
        <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] f2fs: avoid out-of-range memory access

Hi Ocean,

If filesystem is corrupted, it should fail mount due to below check in
f2fs_sanity_check_ckpt(), so we are safe in read_compacted_summaries() to access
entries[0,blk_off], right?

	for (i = 0; i < NR_CURSEG_DATA_TYPE; i++) {
		if (le32_to_cpu(ckpt->cur_data_segno[i]) >= main_segs ||
			le16_to_cpu(ckpt->cur_data_blkoff[i]) >= blocks_per_seg)
			return 1;

Thanks,

On 2019/7/2 16:05, Ocean Chen wrote:
> blk_off might over 512 due to fs corrupt.
> Use ENTRIES_IN_SUM to protect invalid memory access.
> 
> v2:
> - fix typo
> Signed-off-by: Ocean Chen <oceanchen@...gle.com>
> ---
>  fs/f2fs/segment.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 8dee063c833f..a5e8af0bd62e 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -3403,6 +3403,8 @@ static int read_compacted_summaries(struct f2fs_sb_info *sbi)
>  
>  		for (j = 0; j < blk_off; j++) {
>  			struct f2fs_summary *s;
> +			if (j >= ENTRIES_IN_SUM)
> +				return -EFAULT;
>  			s = (struct f2fs_summary *)(kaddr + offset);
>  			seg_i->sum_blk->entries[j] = *s;
>  			offset += SUMMARY_SIZE;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ