[no subject]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: liusongtang <liusongtang@xxxxxxxxxx>
Date: Thu, 21 Apr 2022 17:44:07 +0800
Subject: [PATCH] mm: reduce Committed_AS if memory protection is changed to
 PROT_NONE

If PROT_WRITE is set, the size of vm area will be added to Committed_AS.
However, if memory protection is changed to PROT_NONE,
the corresponding physical memory will not be used, but Committed_AS still
count the size of the PROT_NONE memory.

This patch reduce Committed_AS and free the corresponding memory if
memory protection is changed to PROT_NONE.

Signed-off-by: liusongtang <liusongtang@xxxxxxxxxx>
---
 mm/mprotect.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index b69ce7a..c3121e6 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -497,6 +497,12 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
        }

 success:
+       if ((newflags & (VM_READ | VM_WRITE | VM_EXEC | VM_LOCKED | VM_ACCOUNT)) == VM_ACCOUNT) {
+               zap_page_range(vma, start, end - start);
+               newflags &= ~VM_ACCOUNT;
+               vm_unacct_memory((end - start) >> PAGE_SHIFT);
+       }
+
        /*
         * vm_flags and vm_page_prot are protected by the mmap_lock
         * held in write mode.
--
2.12.3





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux