Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Jason Gunthorpe
On Wed, Nov 23, 2022 at 04:15:05PM +0100, Christian König wrote: > I have not the slightest idea how people got this impression, but I have > heard it so many time from so many different sources that there must be some > common cause to this. Is the maybe some book or tutorial how to sophisticate

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Daniel Vetter
On Wed, 23 Nov 2022 at 16:15, Christian König wrote: > > Am 23.11.22 um 16:08 schrieb Jason Gunthorpe: > > On Wed, Nov 23, 2022 at 03:34:54PM +0100, Daniel Vetter wrote: > >>> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > >>> index 1376a47fedeedb..4161241fc3228c 100644 > >>> --- a/virt/

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Daniel Vetter
On Wed, 23 Nov 2022 at 16:04, Jason Gunthorpe wrote: > > On Wed, Nov 23, 2022 at 03:28:27PM +0100, Daniel Vetter wrote: > > > > This patch is known to be broken in so many ways. It also has a major > > > security hole that it ignores the PTE flags making the page > > > RO. Ignoring the special bit

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Christian König
Am 23.11.22 um 16:08 schrieb Jason Gunthorpe: On Wed, Nov 23, 2022 at 03:34:54PM +0100, Daniel Vetter wrote: diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 1376a47fedeedb..4161241fc3228c 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2598,6 +2598,19 @@ static int hv

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Jason Gunthorpe
On Wed, Nov 23, 2022 at 03:34:54PM +0100, Daniel Vetter wrote: > > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > > index 1376a47fedeedb..4161241fc3228c 100644 > > --- a/virt/kvm/kvm_main.c > > +++ b/virt/kvm/kvm_main.c > > @@ -2598,6 +2598,19 @@ static int hva_to_pfn_remapped(struct vm_a

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Jason Gunthorpe
On Wed, Nov 23, 2022 at 03:28:27PM +0100, Daniel Vetter wrote: > > This patch is known to be broken in so many ways. It also has a major > > security hole that it ignores the PTE flags making the page > > RO. Ignoring the special bit is somehow not surprising :( > > > > This probably doesn't work,

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Daniel Vetter
On Wed, 23 Nov 2022 at 14:28, Jason Gunthorpe wrote: > > On Wed, Nov 23, 2022 at 02:12:25PM +0100, Christian König wrote: > > Am 23.11.22 um 13:53 schrieb Jason Gunthorpe: > > > On Wed, Nov 23, 2022 at 01:49:41PM +0100, Christian König wrote: > > > > Am 23.11.22 um 13:46 schrieb Jason Gunthorpe: >

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Daniel Vetter
On Wed, 23 Nov 2022 at 14:28, Jason Gunthorpe wrote: > > On Wed, Nov 23, 2022 at 02:12:25PM +0100, Christian König wrote: > > Am 23.11.22 um 13:53 schrieb Jason Gunthorpe: > > > On Wed, Nov 23, 2022 at 01:49:41PM +0100, Christian König wrote: > > > > Am 23.11.22 um 13:46 schrieb Jason Gunthorpe: >

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Jason Gunthorpe
On Wed, Nov 23, 2022 at 02:12:25PM +0100, Christian König wrote: > Am 23.11.22 um 13:53 schrieb Jason Gunthorpe: > > On Wed, Nov 23, 2022 at 01:49:41PM +0100, Christian König wrote: > > > Am 23.11.22 um 13:46 schrieb Jason Gunthorpe: > > > > On Wed, Nov 23, 2022 at 11:06:55AM +0100, Daniel Vetter w

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Christian König
Am 23.11.22 um 13:53 schrieb Jason Gunthorpe: On Wed, Nov 23, 2022 at 01:49:41PM +0100, Christian König wrote: Am 23.11.22 um 13:46 schrieb Jason Gunthorpe: On Wed, Nov 23, 2022 at 11:06:55AM +0100, Daniel Vetter wrote: Maybe a GFP flag to set the page reference count to zero or something lik

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Jason Gunthorpe
On Wed, Nov 23, 2022 at 01:49:41PM +0100, Christian König wrote: > Am 23.11.22 um 13:46 schrieb Jason Gunthorpe: > > On Wed, Nov 23, 2022 at 11:06:55AM +0100, Daniel Vetter wrote: > > > > > > Maybe a GFP flag to set the page reference count to zero or something > > > > like this? > > > Hm yeah tha

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Christian König
Am 23.11.22 um 13:46 schrieb Jason Gunthorpe: On Wed, Nov 23, 2022 at 11:06:55AM +0100, Daniel Vetter wrote: Maybe a GFP flag to set the page reference count to zero or something like this? Hm yeah that might work. I'm not sure what it will all break though? And we'd need to make sure that und

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Jason Gunthorpe
On Wed, Nov 23, 2022 at 11:06:55AM +0100, Daniel Vetter wrote: > > Maybe a GFP flag to set the page reference count to zero or something > > like this? > > Hm yeah that might work. I'm not sure what it will all break though? > And we'd need to make sure that underflowing the page refcount dies in

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Daniel Vetter
On Wed, 23 Nov 2022 at 10:39, Christian König wrote: > > Am 23.11.22 um 10:30 schrieb Daniel Vetter: > > On Wed, 23 Nov 2022 at 10:06, Christian König > > wrote: > >> Am 22.11.22 um 20:50 schrieb Daniel Vetter: > >>> On Tue, 22 Nov 2022 at 20:34, Jason Gunthorpe wrote: > On Tue, Nov 22, 20

Re: [Linaro-mm-sig] Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Christian König
Am 23.11.22 um 10:30 schrieb Daniel Vetter: On Wed, 23 Nov 2022 at 10:06, Christian König wrote: Am 22.11.22 um 20:50 schrieb Daniel Vetter: On Tue, 22 Nov 2022 at 20:34, Jason Gunthorpe wrote: On Tue, Nov 22, 2022 at 08:29:05PM +0100, Daniel Vetter wrote: You nuke all the ptes. Drivers tha

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Daniel Vetter
On Wed, 23 Nov 2022 at 09:07, Thomas Zimmermann wrote: > > Hi > > Am 22.11.22 um 18:08 schrieb Daniel Vetter: > > tldr; DMA buffers aren't normal memory, expecting that you can use > > them like that (like calling get_user_pages works, or that they're > > accounting like any other normal memory) c

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Daniel Vetter
On Wed, 23 Nov 2022 at 10:06, Christian König wrote: > Am 22.11.22 um 20:50 schrieb Daniel Vetter: > > On Tue, 22 Nov 2022 at 20:34, Jason Gunthorpe wrote: > >> On Tue, Nov 22, 2022 at 08:29:05PM +0100, Daniel Vetter wrote: > >>> You nuke all the ptes. Drivers that move have slightly more than a

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Christian König
Am 22.11.22 um 20:50 schrieb Daniel Vetter: On Tue, 22 Nov 2022 at 20:34, Jason Gunthorpe wrote: On Tue, Nov 22, 2022 at 08:29:05PM +0100, Daniel Vetter wrote: You nuke all the ptes. Drivers that move have slightly more than a bare struct file, they also have a struct address_space so that inv

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-23 Thread Thomas Zimmermann
Hi Am 22.11.22 um 18:08 schrieb Daniel Vetter: tldr; DMA buffers aren't normal memory, expecting that you can use them like that (like calling get_user_pages works, or that they're accounting like any other normal memory) cannot be guaranteed. Since some userspace only runs on integrated device

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-22 Thread Daniel Vetter
On Tue, 22 Nov 2022 at 20:34, Jason Gunthorpe wrote: > On Tue, Nov 22, 2022 at 08:29:05PM +0100, Daniel Vetter wrote: > > You nuke all the ptes. Drivers that move have slightly more than a > > bare struct file, they also have a struct address_space so that > > invalidate_mapping_range() works. > >

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-22 Thread Jason Gunthorpe
On Tue, Nov 22, 2022 at 08:29:05PM +0100, Daniel Vetter wrote: > You nuke all the ptes. Drivers that move have slightly more than a > bare struct file, they also have a struct address_space so that > invalidate_mapping_range() works. Okay, this is one of the ways that this can be made to work cor

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-22 Thread Daniel Vetter
On Tue, 22 Nov 2022 at 19:50, Jason Gunthorpe wrote: > > On Tue, Nov 22, 2022 at 07:08:25PM +0100, Daniel Vetter wrote: > > On Tue, 22 Nov 2022 at 19:04, Jason Gunthorpe wrote: > > > > > > On Tue, Nov 22, 2022 at 06:08:00PM +0100, Daniel Vetter wrote: > > > > tldr; DMA buffers aren't normal memor

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-22 Thread Jason Gunthorpe
On Tue, Nov 22, 2022 at 07:08:25PM +0100, Daniel Vetter wrote: > On Tue, 22 Nov 2022 at 19:04, Jason Gunthorpe wrote: > > > > On Tue, Nov 22, 2022 at 06:08:00PM +0100, Daniel Vetter wrote: > > > tldr; DMA buffers aren't normal memory, expecting that you can use > > > them like that (like calling g

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-22 Thread Daniel Vetter
On Tue, 22 Nov 2022 at 19:04, Jason Gunthorpe wrote: > > On Tue, Nov 22, 2022 at 06:08:00PM +0100, Daniel Vetter wrote: > > tldr; DMA buffers aren't normal memory, expecting that you can use > > them like that (like calling get_user_pages works, or that they're > > accounting like any other normal

Re: [PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-22 Thread Jason Gunthorpe
On Tue, Nov 22, 2022 at 06:08:00PM +0100, Daniel Vetter wrote: > tldr; DMA buffers aren't normal memory, expecting that you can use > them like that (like calling get_user_pages works, or that they're > accounting like any other normal memory) cannot be guaranteed. > > Since some userspace only ru

[PATCH] dma-buf: Require VM_PFNMAP vma for mmap

2022-11-22 Thread Daniel Vetter
tldr; DMA buffers aren't normal memory, expecting that you can use them like that (like calling get_user_pages works, or that they're accounting like any other normal memory) cannot be guaranteed. Since some userspace only runs on integrated devices, where all buffers are actually all resident sys