limit the mm->map_count not greater than sysctl_max_map_count
Subsystems (2)
PATCH 1/1 limit the mm->map_count not greater than sysctl_max_map_count
When reading the mmap codes, I found the checking of mm->map_count against sysctl_max_map_count is not consistent. At some places, ">" is used; at some other places, ">=" is used.
This patch changes ">" to ">=", so they are consistent, and makes sure the value is not greater (one more) than sysctl_max_map_count.
--- mm/mmap.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
mm/mmap.c +0 -0
@@ -987,7 +987,7 @@ unsigned long do_mmap_pgoff(struct file *file,
unsigned long addr,
return -EOVERFLOW;
/* Too many mappings? */
- if (mm->map_count > sysctl_max_map_count)
+ if (mm->map_count >= sysctl_max_map_count)
return -ENOMEM;
/* Obtain the address to map to. we verify (or select) it and ensure
@@ -2193,7 +2193,7 @@ unsigned long do_brk(unsigned long addr, unsigned long len)
if (!may_expand_vm(mm, len >> PAGE_SHIFT))
return -ENOMEM;
- if (mm->map_count > sysctl_max_map_count)
+ if (mm->map_count >= sysctl_max_map_count)
return -ENOMEM;
if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
Signature · 10 lines
1.7.6.5 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 7 lines · Li Zhong
When reading the mmap codes, I found the checking of
mm->map_countagainstsysctl_max_map_countis not consistent. At some places, ">" is used; at some other places, ">=" is used.This patch changes ">" to">=", so they are consistent, and makes sure the value is not greater (one more) than
sysctl_max_map_count.
Well, according to Documentation/sysctl/vm.txt,
max_map_count:
This file contains the maximum number of memory map areas a process may have. [...]
I think ->map_count == sysctl_max_map_count should be allowed, so using '>' is correct.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Quoted 11 lines · Cong Wang
Quoted 7 lines · Li Zhong
When reading the mmap codes, I found the checking of
mm->map_countagainstsysctl_max_map_countis not consistent. At some places, ">" is used; at some other places, ">=" is used.This patch changes ">" to">=", so they are consistent, and makes sure the value is not greater (one more) than
sysctl_max_map_count.Well, according to
Documentation/sysctl/vm.txt,
Quoted 8 lines
max_map_count:This file contains the maximum number of memory map areas a process may have. [...]
I think ->map_count ==
sysctl_max_map_countshould be allowed, so using '>' is correct.
Yes, I agree that ->map_count == sysctl_max_map_count should be allowed. However, with '>' used. The ->map_count could be sysctl_max_map_count+1. It could be seen with a simple program doing continuously mmaping of a file.
( Still it is possible, as stated in the comments of do_munmap code, if the VMA is going to be divided into two, the map_count could temporarily be sysctl_max_map_count+1, after the original vma split into two, and before one of the two vmas removed. )
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>