]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit - mm/slab.c
mm: kfence: fix missing objcg housekeeping for SLAB
authorMuchun Song <songmuchun@bytedance.com>
Sun, 27 Mar 2022 05:18:52 +0000 (13:18 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:37:15 +0000 (14:37 +0200)
commit8f8c81d90e308ed324d1d449902013a4a1c15cac
treeb4471d583c2dbae99a106b3cf50862a3d32ca17a
parent36e7c097776502d3b05c7088537d7ba997c66a04
mm: kfence: fix missing objcg housekeeping for SLAB

BugLink: https://bugs.launchpad.net/bugs/1969110
commit ae085d7f9365de7da27ab5c0d16b12d51ea7fca9 upstream.

The objcg is not cleared and put for kfence object when it is freed,
which could lead to memory leak for struct obj_cgroup and wrong
statistics of NR_SLAB_RECLAIMABLE_B or NR_SLAB_UNRECLAIMABLE_B.

Since the last freed object's objcg is not cleared,
mem_cgroup_from_obj() could return the wrong memcg when this kfence
object, which is not charged to any objcgs, is reallocated to other
users.

A real word issue [1] is caused by this bug.

Link: https://lore.kernel.org/all/000000000000cabcb505dae9e577@google.com/
Reported-by: syzbot+f8c45ccc7d5d45fc5965@syzkaller.appspotmail.com
Fixes: d3fb45f370d9 ("mm, kfence: insert KFENCE hooks for SLAB")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Marco Elver <elver@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit dd84d71bcbcb2eb7f889449f6d4a3e65ae439e71)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
mm/slab.c