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]
Date:	Tue, 24 Feb 2015 13:43:45 -0800
From:	Danesh Petigara <dpetigara@...adcom.com>
To:	Michal Nazarewicz <mina86@...a86.com>, <akpm@...ux-foundation.org>
CC:	<m.szyprowski@...sung.com>, <iamjoonsoo.kim@....com>,
	<aneesh.kumar@...ux.vnet.ibm.com>,
	<laurent.pinchart+renesas@...asonboard.com>,
	<gregory.0xf0@...il.com>, <linux-mm@...ck.org>,
	<linux-kernel@...r.kernel.org>, <stable@...r.kernel.org>
Subject: Re: [PATCH] mm: cma: fix CMA aligned offset calculation



On 2/24/2015 1:10 PM, Michal Nazarewicz wrote:
> On Tue, Feb 24 2015, Danesh Petigara <dpetigara@...adcom.com> wrote:
>> The CMA aligned offset calculation is incorrect for
>> non-zero order_per_bit values.
>>
>> For example, if cma->order_per_bit=1, cma->base_pfn=
>> 0x2f800000 and align_order=12, the function returns
>> a value of 0x17c00 instead of 0x400.
>>
>> This patch fixes the CMA aligned offset calculation.
>>
>> Cc: stable@...r.kernel.org
>> Signed-off-by: Danesh Petigara <dpetigara@...adcom.com>
>> Reviewed-by: Gregory Fong <gregory.0xf0@...il.com>
> 
> Acked-by: Michal Nazarewicz <mina86@...a86.com>
> 
>> ---
>>  mm/cma.c | 10 +++++++---
>>  1 file changed, 7 insertions(+), 3 deletions(-)
>>
>> diff --git a/mm/cma.c b/mm/cma.c
>> index 75016fd..58f37bd 100644
>> --- a/mm/cma.c
>> +++ b/mm/cma.c
>> @@ -70,9 +70,13 @@ static unsigned long cma_bitmap_aligned_offset(struct cma *cma, int align_order)
>>  
>>  	if (align_order <= cma->order_per_bit)
>>  		return 0;
>> -	alignment = 1UL << (align_order - cma->order_per_bit);
>> -	return ALIGN(cma->base_pfn, alignment) -
>> -		(cma->base_pfn >> cma->order_per_bit);
>> +
>> +	/*
>> +	 * Find a PFN aligned to the specified order and return
>> +	 * an offset represented in order_per_bits.
>> +	 */
> 
> It probably makes sense to move this comment outside of the function as
> function documentation.
> 

Thanks for the feedback. Will send out patch v2 with the comment moved
outside the function and also remove the unused 'alignment' variable.

>> +	return (ALIGN(cma->base_pfn, (1UL << align_order))
>> +		- cma->base_pfn) >> cma->order_per_bit;
>>  }
>>  
>>  static unsigned long cma_bitmap_maxno(struct cma *cma)
>> -- 
>> 1.9.1
>>
> 

Best regards,
Danesh Petigara
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ