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] [day] [month] [year] [list]
Message-ID: <aaa065c4-5c15-38a1-f2ea-73b4226fb203@huawei.com>
Date:   Mon, 23 Mar 2020 11:22:01 +0800
From:   Chao Yu <yuchao0@...wei.com>
To:     Joe Perches <joe@...ches.com>, <jaegeuk@...nel.org>
CC:     <linux-f2fs-devel@...ts.sourceforge.net>,
        <linux-kernel@...r.kernel.org>, <chao@...nel.org>
Subject: Re: [PATCH v4] f2fs: fix potential .flags overflow on 32bit
 architecture

On 2020/3/23 10:57, Joe Perches wrote:
> On Mon, 2020-03-23 at 10:41 +0800, Chao Yu wrote:
>> f2fs_inode_info.flags is unsigned long variable, it has 32 bits
>> in 32bit architecture, since we introduced FI_MMAP_FILE flag
>> when we support data compression, we may access memory cross
>> the border of .flags field, corrupting .i_sem field, result in
>> below deadlock.
> []
>> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> []
>> @@ -682,6 +682,47 @@ enum {
> []
>> +/* used for f2fs_inode_info->flags */
>> +enum {
> []
>> +	FI_MAX,			/* max flag, never be used */
>> +};
>> +
>> +/* f2fs_inode_info.flags array size */
>> +#define FI_ARRAY_SIZE		(BITS_TO_LONGS(FI_MAX))
> 
> Perhaps FI_ARRAY_SIZE isn't necessary.
> 
>> +
>>  struct f2fs_inode_info {
>>  	struct inode vfs_inode;		/* serve a vfs inode */
>>  	unsigned long i_flags;		/* keep an inode flags for ioctl */
>> @@ -694,7 +735,7 @@ struct f2fs_inode_info {
>>  	umode_t i_acl_mode;		/* keep file acl mode temporarily */
>>  
>>  	/* Use below internally in f2fs*/
>> -	unsigned long flags;		/* use to pass per-file flags */
>> +	unsigned long flags[FI_ARRAY_SIZE];	/* use to pass per-file flags */
> 
> and BITS_TO_LONGS should be used here.
> 
>> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> []
>> @@ -362,7 +363,8 @@ static int do_read_inode(struct inode *inode)
>>  	fi->i_flags = le32_to_cpu(ri->i_flags);
>>  	if (S_ISREG(inode->i_mode))
>>  		fi->i_flags &= ~F2FS_PROJINHERIT_FL;
>> -	fi->flags = 0;
>> +	for (i = 0; i < FI_ARRAY_SIZE; i++)
>> +		fi->flags[i] = 0;
> 
> And this could become
> 
> 	bitmap_zero(fi->flags, BITS_TO_LONG(FI_MAX));
> 
> Is FI_ARRAY_SIZE used anywhere else?

Updated in v5, thanks.

Thanks,

> 
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ