Skip to content
Snippets Groups Projects
Commit f5c12105 authored by Oscar Salvador's avatar Oscar Salvador Committed by Andrew Morton
Browse files

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: default avatar <syzbot+41bbfdb8d41003d12c0f@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/linux-mm/00000000000090e8ff0613eda0e5@google.com


Fixes: 217b2119 ("mm,page_owner: implement the tracking of the stacks count")
Signed-off-by: default avatarOscar Salvador <osalvador@suse.de>
Reviewed-by: default avatarVlastimil Babka <vbabka@suse.cz>
Tested-by: default avatarAlexandre 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: default avatarAndrew Morton <akpm@linux-foundation.org>
parent ea4b5b33
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment