Skip to content

Commit b8e57ef

Browse files
Kirill Tkhaigregkh
authored andcommitted
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 <ktkhai@virtuozzo.com> Reported-by: Cyrill Gorcunov <gorcunov@openvz.org> Acked-by: Cyrill Gorcunov <gorcunov@openvz.org> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Cc: Michal Hocko <mhocko@suse.com> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Cc: Shakeel Butt <shakeelb@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 58bc4c3 commit b8e57ef

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

mm/vmscan.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -580,8 +580,8 @@ static unsigned long shrink_slab_memcg(gfp_t gfp_mask, int nid,
580580
struct mem_cgroup *memcg, int priority)
581581
{
582582
struct memcg_shrinker_map *map;
583-
unsigned long freed = 0;
584-
int ret, i;
583+
unsigned long ret, freed = 0;
584+
int i;
585585

586586
if (!memcg_kmem_enabled() || !mem_cgroup_online(memcg))
587587
return 0;
@@ -677,9 +677,8 @@ static unsigned long shrink_slab(gfp_t gfp_mask, int nid,
677677
struct mem_cgroup *memcg,
678678
int priority)
679679
{
680+
unsigned long ret, freed = 0;
680681
struct shrinker *shrinker;
681-
unsigned long freed = 0;
682-
int ret;
683682

684683
if (!mem_cgroup_is_root(memcg))
685684
return shrink_slab_memcg(gfp_mask, nid, memcg, priority);

0 commit comments

Comments
 (0)