[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAO9qdTEZW74N_XDM0N1UkRy9BfrKE1SL-S4h2bvtEJ9QROTETA@mail.gmail.com>
Date: Fri, 4 Oct 2024 23:50:12 +0900
From: Jeongjun Park <aha310510@...il.com>
To: Matthew Wilcox <willy@...radead.org>
Cc: akpm@...ux-foundation.org, kasong@...cent.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org,
syzbot+fa43f1b63e3aa6f66329@...kaller.appspotmail.com
Subject: Re: [PATCH] mm: swap: prevent possible data-race in __try_to_reclaim_swap
Matthew Wilcox <willy@...radead.org> wrote:
>
> On Fri, Oct 04, 2024 at 11:25:04PM +0900, Jeongjun Park wrote:
> > A report [1] was uploaded from syzbot.
> >
> > In the previous commit 862590ac3708 ("mm: swap: allow cache reclaim to skip
> > slot cache"), the __try_to_reclaim_swap() function reads offset and nr_pages
> > from folio without folio_lock protection.
>
> Umm. You don't need folio_lock to read nr_pages. Holding a refcount
> is sufficient to stabilise nr_pages. I cannot speak to folio->swap
> though (and the KCSAN report does appear to be pointing to folio->swap).
>
That's right. It looks like KCSAN log occurs when reading folio->swap.
In fact, since most of the code reads folio->swap under the protection
of folio_lock, it is possible to modify only the part that reads folio->swap
and the code that reads offset to operate under the protection of
folio_lock.
However, even if reading nr_pages does not require folio_lock, I don't
think it is very desirable to modify only this code to not be protected
by folio_lock.
Regards,
Jeongjun Park
Powered by blists - more mailing lists