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  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]
Date:	Tue, 1 Sep 2015 09:16:38 +0800
From:	Zhang Zhen <zhenzhang.zhang@...wei.com>
To:	Andreas Dilger <adilger@...ger.ca>
CC:	"tytso@....edu" <tytso@....edu>, Jan Kara <jack@...e.cz>,
	<adilger.kernel@...ger.ca>,
	"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] fs/ext4: fix potential endless loop in ext4_mb_discard_group_preallocations()

On 2015/9/1 6:34, Andreas Dilger wrote:
> On Aug 31, 2015, at 3:46 AM, Zhang Zhen <zhenzhang.zhang@...wei.com> wrote:
>>
>> In ext4_mb_discard_group_preallocations(), if free is always less
>> than needed, and some PAs are always used in every loop, it will
>> be endless loop.
>>
>> Here we pick a random value to limit the max number of loop.
>>
>> Signed-off-by: Zhang Zhen <zhenzhang.zhang@...wei.com>
>> ---
>> fs/ext4/mballoc.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
>> index 34b610e..553fbde 100644
>> --- a/fs/ext4/mballoc.c
>> +++ b/fs/ext4/mballoc.c
>> @@ -3836,6 +3836,7 @@ ext4_mb_discard_group_preallocations(struct super_block *sb,
>> 	int err;
>> 	int busy = 0;
>> 	int free = 0;
>> +	int tried = 0;
>>
>> 	mb_debug(1, "discard preallocation for group %u\n", group);
>>
>> @@ -3886,9 +3887,11 @@ repeat:
>> 		list_add(&pa->u.pa_tmp_list, &list);
>> 	}
>>
>> -	/* if we still need more blocks and some PAs were used, try again */
>> -	if (free < needed && busy) {
>> +	/* if we still need more blocks and some PAs were used, try again,
>> +	   here 20 is a ramdon value. */
> 
> (typo) s/ramdon/random/
> 
My mistake, thanks!

>> +	if (free < needed && busy && tried < 20) {
>> 		busy = 0;
>> +		tried++;
>> 		ext4_unlock_group(sb, group);
>> 		cond_resched();
>> 		goto repeat;
> 
> Looks OK otherwise.
> 
> Cheers, Andreas
> 
> 
> 
> 
> 
> 
> 


--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists