]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.16-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Mar 2022 09:09:36 +0000 (11:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 28 Mar 2022 09:09:36 +0000 (11:09 +0200)
added patches:
mm-kfence-fix-missing-objcg-housekeeping-for-slab.patch

queue-5.16/mm-kfence-fix-missing-objcg-housekeeping-for-slab.patch [new file with mode: 0644]
queue-5.16/series

diff --git a/queue-5.16/mm-kfence-fix-missing-objcg-housekeeping-for-slab.patch b/queue-5.16/mm-kfence-fix-missing-objcg-housekeeping-for-slab.patch
new file mode 100644 (file)
index 0000000..6d0a471
--- /dev/null
@@ -0,0 +1,43 @@
+From ae085d7f9365de7da27ab5c0d16b12d51ea7fca9 Mon Sep 17 00:00:00 2001
+From: Muchun Song <songmuchun@bytedance.com>
+Date: Sun, 27 Mar 2022 13:18:52 +0800
+Subject: mm: kfence: fix missing objcg housekeeping for SLAB
+
+From: Muchun Song <songmuchun@bytedance.com>
+
+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/ [1]
+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>
+---
+ mm/slab.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/mm/slab.c
++++ b/mm/slab.c
+@@ -3429,6 +3429,7 @@ static __always_inline void __cache_free
+       if (is_kfence_address(objp)) {
+               kmemleak_free_recursive(objp, cachep->flags);
++              memcg_slab_free_hook(cachep, &objp, 1);
+               __kfence_free(objp);
+               return;
+       }
index 5335b9c43fb90a6597709ac6e7a693486162c802..a95cefa557e003a34bd8b0d4cb6aa46e0ef25e04 100644 (file)
@@ -3,3 +3,4 @@ usb-serial-pl2303-add-ibm-device-ids.patch
 dt-bindings-usb-hcd-correct-usb-device-path.patch
 usb-serial-pl2303-fix-gs-type-detection.patch
 usb-serial-simple-add-nokia-phone-driver.patch
+mm-kfence-fix-missing-objcg-housekeeping-for-slab.patch