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: <YnxCCPZUfgQNXSg6@google.com>
Date:   Wed, 11 May 2022 16:08:56 -0700
From:   Minchan Kim <minchan@...nel.org>
To:     John Hubbard <jhubbard@...dia.com>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        linux-mm <linux-mm@...ck.org>,
        LKML <linux-kernel@...r.kernel.org>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        John Dias <joaodias@...gle.com>,
        David Hildenbrand <david@...hat.com>
Subject: Re: [PATCH v4] mm: fix is_pinnable_page against on cma page

On Wed, May 11, 2022 at 03:49:06PM -0700, John Hubbard wrote:
> On 5/11/22 15:37, Minchan Kim wrote:
> > > Yes. But one thing that is still unanswered, that I think you can
> > > answer, is: even if the compiler *did* re-read the mt variable, what
> > > problems could that cause? I claim "no problems", because there is
> > > no combination of 0, _CMA, _ISOLATE, _CMA|ISOLATE that will cause
> > > problems here.
> > 
> > What scenario I am concerning with __READ_ONCE so compiler
> > inlining get_pageblock_migratetype two times are
> > 
> >          CPU 0                                                       CPU 1
> >                                                                  alloc_contig_range
> > is_pinnable_page                                                start_isolate_page_range
> >                                                                    set_pageblock_migratetype(MIGRATE_ISOLATE)
> >     if (get_pageeblock_migratetype(page) == MIGRATE_CMA)
> >         so it's false
> >                                                                  undo:
> >                                                                    set_pageblock_migratetype(MIGRATE_CMA)
> >     if (get_pageeblock_migratetype(page) == MIGRATE_ISOLATE)
> >         so it's false
> > 
> > In the end, CMA memory would be pinned by CPU 0 process
> > so CMA allocation keep failed until the process release the
> > refcount.
> > 
> 
> OK, so the code checks the wrong item each time. But the code really
> only needs to know "is either _CMA or _ISOLATE set?". And so you

Yes.

> can just sidestep the entire question by writing it like this:
> 
> int mt = get_pageblock_migratetype(page);
> 
> if (mt & (MIGRATE_ISOLATE | MIGRATE_CMA))
> 	return false;

I am confused. Isn't it same question?

                                                    set_pageblock_migratetype(MIGRATE_ISOLATE)
if (get_pageblock_migrate(page) & MIGRATE_CMA)

                                                    set_pageblock_migratetype(MIGRATE_CMA)

if (get_pageblock_migrate(page) & MIGRATE_ISOLATE)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ