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]
Message-ID: <C8ADDC89-FE41-4DA1-A820-E3F7CE818955@nvidia.com>
Date:   Fri, 01 Apr 2022 15:25:44 -0400
From:   Zi Yan <ziy@...dia.com>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Linux-MM <linux-mm@...ck.org>,
        Steven Rostedt <rostedt@...dmis.org>,
        David Hildenbrand <david@...hat.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Mel Gorman <mgorman@...hsingularity.net>,
        Mike Rapoport <rppt@...nel.org>,
        Oscar Salvador <osalvador@...e.de>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2 2/2] mm: wrap __find_buddy_pfn() with a necessary buddy page validation.

On 1 Apr 2022, at 15:01, Linus Torvalds wrote:

> On Fri, Apr 1, 2022 at 11:56 AM Zi Yan <ziy@...dia.com> wrote:
>>
>> How about the patch below? If it looks good, I will send v3.
>
> I can't see anything worrisome, but by now I've looked at several
> versions and who knows what I'm missing.
>
> Making it inline and allowing a NULL 'buddy_pfn' pointer for the cases
> that don't care might be an option, but I don't think it matters
> hugely.

What do you mean by inlining it? Moving the function and __find_buddy_pfn()
to mm/internal.h and mark both inline?

Something like below to allow a NULL 'buddy_pfn'? buddy_pfn is needed
to store the result of __find_buddy_pfn(). The code does not look
as nice as before.

struct page *find_buddy_page_pfn(struct page *page, unsigned long pfn,
                        unsigned int order, unsigned long *buddy_pfn)
{
        struct page *buddy;

        if (buddy_pfn) {
                *buddy_pfn = __find_buddy_pfn(pfn, order);
                buddy = page + (*buddy_pfn - pfn);
        } else
                buddy = page + (__find_buddy_pfn(pfn, order) - pfn);

        if (page_is_buddy(page, buddy, order))
                return buddy;
        return NULL;
}

or

struct page *find_buddy_page_pfn(struct page *page, unsigned long pfn,
                        unsigned int order, unsigned long *buddy_pfn)
{
        struct page *buddy;
        unsigned long local_buddy_pfn = __find_buddy_pfn(pfn, order);

        buddy = page + (local_buddy_pfn - pfn);
        if (buddy_pfn)
                *buddy_pfn = local_buddy_pfn;

        if (page_is_buddy(page, buddy, order))
                return buddy;
        return NULL;
}

--
Best Regards,
Yan, Zi

Download attachment "signature.asc" of type "application/pgp-signature" (855 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ