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: <CADtm3G5QdadzTcKOjDO1mgtjU_vfqtG6DucTJYdTtyQirLfXDg@mail.gmail.com>
Date:	Fri, 27 Feb 2015 18:06:57 -0800
From:	Gregory Fong <gregory.0xf0@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Danesh Petigara <dpetigara@...adcom.com>,
	Marek Szyprowski <m.szyprowski@...sung.com>,
	Michal Nazarewicz <mina86@...a86.com>,
	Joonsoo Kim <iamjoonsoo.kim@....com>,
	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>,
	Laurent Pinchart <laurent.pinchart+renesas@...asonboard.com>,
	linux-mm@...ck.org,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	stable@...r.kernel.org
Subject: Re: [PATCH v2] mm: cma: fix CMA aligned offset calculation

On Fri, Feb 27, 2015 at 5:18 PM, Andrew Morton
<akpm@...ux-foundation.org> wrote:
> On Fri, 27 Feb 2015 17:07:28 -0800 Danesh Petigara <dpetigara@...adcom.com> wrote:
>
>> On 2/27/2015 3:54 PM, Andrew Morton wrote:
>> > On Fri, 27 Feb 2015 15:52:56 -0800 Danesh Petigara <dpetigara@...adcom.com> wrote:
>> >
>> >> On 2/27/2015 1:24 PM, Andrew Morton wrote:
>> >>> On Tue, 24 Feb 2015 15:39:45 -0800 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.
>> >>>
>> >>> When fixing a bug please always describe the end-user visible effects
>> >>> of that bug.
>> >>>
>> >>> Without that information others are unable to understand why you are
>> >>> recommending a -stable backport.
>> >>>
>> >>
>> >> Thank you for the feedback. I had no crash logs to show, nevertheless, I
>> >> agree that a sentence describing potential effects of the bug would've
>> >> helped.
>> >
>> > What was the reason for adding a cc:stable?
>> >
>>
>> It was added since the commit that introduced the incorrect logic
>> (b5be83e) was already picked up by v3.19.
>
> argh.
>
> afaict the bug will, under some conditions cause cma_alloc() to report
> that no suitable free area is available in the arena when in fact such
> regions *are* available.  So it's effectively a bogus ENOMEM.
>
> Correct?  If so, what are the conditions under which this will occur?

This is correct, and it can occur for any nonzero order_per_bit value.
The previous calculation was wrong and would return too-large values
for the offset, so that when cma_alloc looks for free pages in the
bitmap with the requested alignment > order_per_bit, it starts too far
into the bitmap and so CMA allocations will fail despite there
actually being plenty of free pages remaining.  It will also probably
have the wrong alignment.  With this change, we will get the correct
offset into the bitmap.

One affected user is powerpc KVM, which has kvm_cma->order_per_bit set
to KVM_CMA_CHUNK_ORDER - PAGE_SHIFT, or 18 - 12 = 6.

I actually had written the offset function this way originally, then
tried to make it more like cma_bitmap_aligned_mask(), but screwed up
the transformation and it really wasn't any easier to understand
anyway.  That was stupid, sorry about that. =(

Best regards,
Gregory
--
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