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] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 29 Jun 2017 09:54:51 -0700
From:   Doug Berger <opendmb@...il.com>
To:     Gregory Fong <gregory.0xf0@...il.com>
Cc:     Angus Clark <angus@...usclark.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Laura Abbott <labbott@...hat.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Lucas Stach <l.stach@...gutronix.de>,
        Catalin Marinas <catalin.marinas@....com>,
        Shiraz Hashim <shashim@...eaurora.org>,
        Jaewon Kim <jaewon31.kim@...sung.com>,
        "open list:MEMORY MANAGEMENT" <linux-mm@...ck.org>,
        open list <linux-kernel@...r.kernel.org>,
        Danesh Petigara <dpetigara@...adcom.com>
Subject: Re: [PATCH] cma: fix calculation of aligned offset

On 06/28/2017 11:23 PM, Gregory Fong wrote:
> On Wed, Jun 28, 2017 at 10:07 AM, Doug Berger <opendmb@...il.com> wrote:
>> The align_offset parameter is used by bitmap_find_next_zero_area_off()
>> to represent the offset of map's base from the previous alignment
>> boundary; the function ensures that the returned index, plus the
>> align_offset, honors the specified align_mask.
>>
>> The logic introduced by commit b5be83e308f7 ("mm: cma: align to
>> physical address, not CMA region position") has the cma driver
>> calculate the offset to the *next* alignment boundary.
> 
> Wow, I had that completely backward, nice catch.
Thanks go to Angus for that!

>> In most cases,
>> the base alignment is greater than that specified when making
>> allocations, resulting in a zero offset whether we align up or down.
>> In the example given with the commit, the base alignment (8MB) was
>> half the requested alignment (16MB) so the math also happened to work
>> since the offset is 8MB in both directions.  However, when requesting
>> allocations with an alignment greater than twice that of the base,
>> the returned index would not be correctly aligned.
> 
> It may be worth explaining what impact incorrect alignment has for an
> end user, then considering for inclusion in stable.
It would be difficult to explain in a general way since the end user is
requesting the alignment and only she knows what the consequences would
be for insufficient alignment.

I assume in general with the CMA it is most likely a DMA constraint.
However, in our particular case the problem affected an allocation used
by a co-processor.  The larger CONFIG_CMA_ALIGNMENT is the less likely
users would run into this bug.  We encountered it after reducing our
default CONFIG_CMA_ALIGNMENT.

I agree that it should be considered for stable.

>>
>> Also, the align_order arguments of cma_bitmap_aligned_mask() and
>> cma_bitmap_aligned_offset() should not be negative so the argument
>> type was made unsigned.
>>
>> Fixes: b5be83e308f7 ("mm: cma: align to physical address, not CMA region position")
>> Signed-off-by: Angus Clark <angus@...usclark.org>
>> Signed-off-by: Doug Berger <opendmb@...il.com>
> 
> Acked-by: Gregory Fong <gregory.0xf0@...il.com>
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ