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: <20200924181501.GF9916@ziepe.ca>
Date:   Thu, 24 Sep 2020 15:15:01 -0300
From:   Jason Gunthorpe <jgg@...pe.ca>
To:     Peter Xu <peterx@...hat.com>
Cc:     John Hubbard <jhubbard@...dia.com>, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org,
        Andrew Morton <akpm@...ux-foundation.org>,
        Jan Kara <jack@...e.cz>, Michal Hocko <mhocko@...e.com>,
        Kirill Tkhai <ktkhai@...tuozzo.com>,
        Kirill Shutemov <kirill@...temov.name>,
        Hugh Dickins <hughd@...gle.com>,
        Christoph Hellwig <hch@....de>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Oleg Nesterov <oleg@...hat.com>,
        Leon Romanovsky <leonro@...dia.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Jann Horn <jannh@...gle.com>
Subject: Re: [PATCH 1/5] mm: Introduce mm_struct.has_pinned

On Thu, Sep 24, 2020 at 01:55:31PM -0400, Peter Xu wrote:
> On Thu, Sep 24, 2020 at 01:51:52PM -0300, Jason Gunthorpe wrote:
> > > Regarding the solution here, I think we can also cover read-only fast-gup too
> > > in the future - IIUC what we need to do is to make it pte_protnone() instead of
> > > pte_wrprotect(), then in the fault handler we should identify this special
> > > pte_protnone() against numa balancing (change_prot_numa()).  I think it should
> > > work fine too, iiuc, because I don't think we should migrate a page at all if
> > > it's pinned for any reason...
> 
> [1]
> 
> > 
> > With your COW breaking patch the read only fast-gup should break the
> > COW because of the write protect, just like for the write side. Not
> > seeing why we need to do something more?
> 
> Consider this sequence of a parent process managed to fork() a child:
> 
>        buf = malloc();
>        // RDONLY gup
>        pin_user_pages(buf, !WRITE);
>        // pte of buf duplicated on both sides
>        fork();
>        mprotect(buf, WRITE);
>        *buf = 1;
>        // buf page replaced as cow triggered
> 
> Currently when fork() we'll happily share a pinned read-only page with the
> child by copying the pte directly.  

Why? This series prevents that, the page will be maybe_dma_pinned, so
fork() will copy it.

> As a summary: imho the important thing is we should not allow any kind of
> sharing of any dma page, even it's pinned for read.

Any sharing that results in COW. MAP_SHARED is fine, for instance

My feeling for READ when FOLL_PIN is used GUP_fast will go to the slow
path any time it sees a read-only page.

The slow path will determine if it is read-only because it could be
COW'd or read-only for some other reason

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ