Re: [PATCH] mm,page_owner: Fix recursion

From: Tetsuo Handa
Date: Wed Mar 13 2024 - 23:01:45 EST


On 2024/03/14 8:42, Oscar Salvador wrote:
> Prior to 217b2119b9e2 ("mm,page_owner: implement the tracking of the stacks count")
> the only place where page_owner could potentially go into recursion due to
> its need of allocating more memory was in save_stack(), which ends up calling
> into stackdepot code with the possibility of allocating memory.
>
> We made sure to guard against that by signaling that the current task was
> already in page_owner code, so in case a recursion attempt was made, we
> could catch that and return dummy_handle.
>
> After above commit, a new place in page_owner code was introduced where we
> could allocate memory, meaning we could go into recursion would we take that
> path.
>
> Make sure to signal that we are in page_owner in that codepath as well.
> Move the guard code into two helpers {un}set_current_in_page_owner()
> and use them prior to calling in the two functions that might allocate
> memory.
>
> Signed-off-by: Oscar Salvador <osalvador@xxxxxxx>
> Fixes: 217b2119b9e2 ("mm,page_owner: implement the tracking of the stacks count")

Maybe culprit for a page owner refcount bug reported at
https://syzkaller.appspot.com/bug?id=8e4e66dfe299a2a00204ad220c641daaf1486a00 , for
that commit went to next-20240214 and syzbot started failing to test since next-20240215 ?

Please send this patch to linux-next.git as soon as possible (or can someone experiencing
this bug try booting linux-next.git with this patch applied, so that we can check whether
syzbot can resume testing linux-next.git), and then send to linux.git together (so that
various trees which depend on linux.git won't start failing to boot).