]> git.itanic.dy.fi Git - linux-stable/commit
mm,page_owner: fix refcount imbalance
authorOscar Salvador <osalvador@suse.de>
Thu, 4 Apr 2024 07:07:00 +0000 (09:07 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 16 Apr 2024 22:39:49 +0000 (15:39 -0700)
commitf5c12105c15f0ddf0ff37646290568dd986fa2f3
treed4e8271721c9067c1d152fe24be97fa2b8761355
parentea4b5b33bf8a4936cfb07759d926db697c43fb1e
mm,page_owner: fix refcount imbalance

Current code does not contemplate scenarios were an allocation and free
operation on the same pages do not handle it in the same amount at once.
To give an example, page_alloc_exact(), where we will allocate a page of
enough order to stafisfy the size request, but we will free the remainings
right away.

In the above example, we will increment the stack_record refcount only
once, but we will decrease it the same number of times as number of unused
pages we have to free.  This will lead to a warning because of refcount
imbalance.

Fix this by recording the number of base pages in the refcount field.

Link: https://lkml.kernel.org/r/20240404070702.2744-3-osalvador@suse.de
Reported-by: syzbot+41bbfdb8d41003d12c0f@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/linux-mm/00000000000090e8ff0613eda0e5@google.com
Fixes: 217b2119b9e2 ("mm,page_owner: implement the tracking of the stacks count")
Signed-off-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Marco Elver <elver@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Documentation/mm/page_owner.rst
mm/page_owner.c