]> git.itanic.dy.fi Git - linux-stable/commitdiff
mm: shrinker: use kvzalloc_node() from expand_one_shrinker_info()
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Wed, 3 Jan 2024 01:52:22 +0000 (10:52 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 5 Jan 2024 17:58:32 +0000 (09:58 -0800)
syzbot is reporting uninit-value at shrinker_alloc(), for commit
307bececcd12 ("mm: shrinker: add a secondary array for
shrinker_info::{map, nr_deferred}") which assumed that the ->unit was
allocated with __GFP_ZERO forgot to replace kvmalloc_node() in
expand_one_shrinker_info() with kvzalloc_node().

Link: https://lkml.kernel.org/r/9226cc0a-10e0-4489-80c5-58c3b5b4359c@I-love.SAKURA.ne.jp
Reported-by: syzbot <syzbot+1e0ed05798af62917464@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=1e0ed05798af62917464
Fixes: 307bececcd12 ("mm: shrinker: add a secondary array for shrinker_info::{map, nr_deferred}")
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/shrinker.c

index dd91eab43ed3010c94a3c254235a22f681b4b73f..dc5d2a6fcfc414131e71ef5840bfc780533ddfd7 100644 (file)
@@ -126,7 +126,7 @@ static int expand_one_shrinker_info(struct mem_cgroup *memcg, int new_size,
                if (new_nr_max <= old->map_nr_max)
                        continue;
 
-               new = kvmalloc_node(sizeof(*new) + new_size, GFP_KERNEL, nid);
+               new = kvzalloc_node(sizeof(*new) + new_size, GFP_KERNEL, nid);
                if (!new)
                        return -ENOMEM;