diff options
author | Kirill Tkhai <[email protected]> | 2018-10-05 15:52:10 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2018-10-05 16:32:05 -0700 |
commit | b8e57efa2c98cc56c49461c4950cf026422c29e9 (patch) | |
tree | 844349c6cbf468687ffb737aba763c6fe8fd3bcf | |
parent | 58bc4c34d249bf1bc50730a9a209139347cfacfe (diff) |
mm/vmscan.c: fix int overflow in callers of do_shrink_slab()
do_shrink_slab() returns unsigned long value, and the placing into int
variable cuts high bytes off. Then we compare ret and 0xfffffffe (since
SHRINK_EMPTY is converted to ret type).
Thus a large number of objects returned by do_shrink_slab() may be
interpreted as SHRINK_EMPTY, if low bytes of their value are equal to
0xfffffffe. Fix that by declaration ret as unsigned long in these
functions.
Link: http://lkml.kernel.org/r/153813407177.17544.14888305435570723973.stgit@localhost.localdomain
Signed-off-by: Kirill Tkhai <[email protected]>
Reported-by: Cyrill Gorcunov <[email protected]>
Acked-by: Cyrill Gorcunov <[email protected]>
Reviewed-by: Josef Bacik <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Andrey Ryabinin <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Tetsuo Handa <[email protected]>
Cc: Shakeel Butt <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r-- | mm/vmscan.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c index c7ce2c161225..c5ef7240cbcb 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -580,8 +580,8 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, int priority) { struct memcg_shrinker_map *map; - unsigned long freed = 0; - int ret, i; + unsigned long ret, freed = 0; + int i; if (!memcg_kmem_enabled() || !mem_cgroup_online(memcg)) return 0; @@ -677,9 +677,8 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid, struct mem_cgroup *memcg, int priority) { + unsigned long ret, freed = 0; struct shrinker *shrinker; - unsigned long freed = 0; - int ret; if (!mem_cgroup_is_root(memcg)) return shrink_slab_memcg(gfp_mask, nid, memcg, priority); |