lkml.org 
[lkml]   [2020]   [Dec]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 2/6] mm/mremap: For MREMAP_DONTUNMAP check security_vm_enough_memory_mm()
From
Date
On 12/28/20 6:21 PM, Brian Geffon wrote:
> This looks good to me with a small comment.
>
>> if (do_munmap(mm, old_addr, old_len, uf_unmap) < 0) {
>> /* OOM: unable to split vma, just get accounts right */
>> - if (vm_flags & VM_ACCOUNT)
>> + if (vm_flags & VM_ACCOUNT && !(flags & MREMAP_DONTUNMAP))
>> vm_acct_memory(new_len >> PAGE_SHIFT);
>
> Checking MREMAP_DONTUNMAP in the do_munmap path is unnecessary as
> MREMAP_DONTUNMAP will have already returned by this point.

In this code it is also used as err-path. In case move_page_tables()
fails to move all page tables or .mremap() callback fails, the new VMA
is unmapped.

IOW, MREMAP_DONTUNMAP returns under:
: if (unlikely(!err && (flags & MREMAP_DONTUNMAP))) {

--
Dima

\
 
 \ /
  Last update: 2020-12-28 20:14    [W:0.058 / U:0.576 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site