Programs die when max_map_count is too large
Quoted 2 lines
IMO, the problem is '
sysctl_max_map_count' is actually signed int, while when writing to it, the value is treated as unsigned.
The problem is the loop in simple_strtoul(), some people were so afraid to touch so they even came up with strict_* variants.
Quoted 2 lines
A better fix which I could imagine is to fix sysctl to understand signed int's.
- int map_count; + unsigned int map_count;
This is incomplete at least.
Quoted 6 lines · Alexey Dobriyan
Quoted 2 lines
IMO, the problem is '
sysctl_max_map_count' is actually signed int, while when writing to it, the value is treated as unsigned.The problem is the loop in
simple_strtoul(), some people were so afraid to touch so they even came up with strict_* variants.
Quoted 8 lines
Quoted 2 lines
A better fix which I could imagine is to fix sysctl to understand signed int's.
- int
map_count;
+ unsigned intmap_count;This is incomplete at least.
Yeah, perhaps.
I got a better fix, but only for max_map_count. Please check it below.
(Sorr for attatching it, gmail's IMAP sucks.)
----------------->
Make negative values for 'max_map_count' invalid, they are meaningless. And avoid overflow.
I already tested this.
-------
kernel/sysctl.c +2 -1
@@ -1245,7 +1245,8 @@ static struct ctl_table vm_table[] = { .data = &sysctl_max_map_count, .maxlen = sizeof(sysctl_max_map_count), .mode = 0644, - .proc_handler = &proc_dointvec + .proc_handler = &proc_dointvec_minmax, + .extra1 = &zero, },#else {