Skip to content

mm/kmemleak: Simplify kmemleak_cond_resched() & fix UAF

Waiman Long linux-mm lkml 3 versions – Applied

Status from this message: [merged mm-stable] mm-kmemleak-simplify-kmemleak_cond_resched-usage.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest posting 2/22 patches 4 repliesApplied 2/2
  2. v2 posting 1/22 patches 0 repliesSuperseded
  3. v12 patches 6 repliesSuperseded

Patches in v2 posting 2/2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2mm/kmemleak: Simplify kmemleak_cond_resched() usagemm/kmemleak.c+12 -360 repliesApplied
2/2mm/kmemleak: Fix UAF bug in kmemleak_scan()mm/kmemleak.c+29 -64 repliesApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchCatalin Marinas
1/2R-b
2/2R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [RESEND PATCH v2 0/2] mm/kmemleak: Simplify kmemleak_cond_resched() & fix UAF

It was found that a KASAN use-after-free error was reported in the kmemleak_scan() function. After further examination, it is believe that even though a reference is taken from the current object, it does not prevent the object pointed to by the next pointer from going away after a cond_resched().

To fix that, additional flags are added to make sure that the current object won't be removed from the object_list during the duration of the cond_resched() to ensure the validity of the next pointer.

While making the change, I also simplify the current usage of kmemleak_cond_resched() to make it easier to understand.

Waiman Long (2):
mm/kmemleak: Simplify kmemleak_cond_resched() usage mm/kmemleak: Fix UAF bug in kmemleak_scan()

[v2: Update patch 2 to prevent object_list removal of current object]

 mm/kmemleak.c | 83 +++++++++++++++++++++++++--------------------------
 1 file changed, 41 insertions(+), 42 deletions(-)
Signature · 1 line
2.31.1