Re: [PATCH] mm: add account_locked_vm utility function
From: Daniel Jordan
Date: Mon May 06 2019 - 23:11:51 EST
On Fri, May 03, 2019 at 11:28:22PM +0000, Jason Gunthorpe wrote:
> On Fri, May 03, 2019 at 01:16:30PM -0700, Daniel Jordan wrote:
> > Andrew, this one patch replaces these six from [1]:
> >
> > mm-change-locked_vms-type-from-unsigned-long-to-atomic64_t.patch
> > vfio-type1-drop-mmap_sem-now-that-locked_vm-is-atomic.patch
> > vfio-spapr_tce-drop-mmap_sem-now-that-locked_vm-is-atomic.patch
> > fpga-dlf-afu-drop-mmap_sem-now-that-locked_vm-is-atomic.patch
> > kvm-book3s-drop-mmap_sem-now-that-locked_vm-is-atomic.patch
> > powerpc-mmu-drop-mmap_sem-now-that-locked_vm-is-atomic.patch
> >
> > That series converts locked_vm to an atomic, but on closer inspection causes at
> > least one accounting race in mremap, and fixing it just for this type
> > conversion came with too much ugly in the core mm to justify, especially when
> > the right long-term fix is making these drivers use pinned_vm instead.
>
> Did we ever decide what to do here? Should all these drivers be
> switched to pinned_vm anyhow?
Well, there were the concerns about switching in [1]. Alex, is there an
example of an application or library that would break or be exploitable? If
there were particular worries (qemu for vfio type1, for example), perhaps some
coordinated changes across the kernel and userspace would be possible,
especially given the amount of effort it's likely going to take to get the
locked_vm/pinned_vm accounting sorted out.
[1] https://lore.kernel.org/linux-mm/20190213130330.76ef1987@xxxxxxxxx/