Re: [RFC v8 PATCH 3/5] mm: mmap: zap pages with read mmap_sem in munmap

From: Dave Hansen
Date: Wed Aug 22 2018 - 17:42:32 EST


On 08/22/2018 02:10 PM, Kirill A. Shutemov wrote:
>> For x86, mpx_notify_unmap() looks finally zap the VM_MPX vmas in bound table
>> range with zap_page_range() and doesn't update vm flags, so it sounds ok to
>> me since vmas have been detached, nobody can find those vmas. But, I'm not
>> familiar with the details of mpx, maybe Kirill could help to confirm this?
> I don't see anything obviously dependent on down_write() in
> mpx_notify_unmap(), but Dave should know better.

We need mmap_sem for write in mpx_notify_unmap().

Its job is to clean up bounds tables, but bounds tables are dynamically
allocated and destroyed by the kernel. When we destroy a table, we also
destroy the VMA for the bounds table *itself*, separate from the VMA
being unmapped.

But, this code is very likely to go away soon. If it's causing a
problem for you, let me know and I'll see if I can get to removing it
faster.