Re: [PATCH] mm: use compare-exchange operation to set KASAN page tag

From: Matthew Wilcox
Date: Wed Jan 12 2022 - 22:32:47 EST


On Wed, Jan 12, 2022 at 07:14:34PM -0800, Peter Collingbourne wrote:
> It has been reported that the tag setting operation on newly-allocated
> pages can cause the page flags to be corrupted when performed
> concurrently with other flag updates as a result of the use of
> non-atomic operations. Fix the problem by using a compare-exchange
> loop to update the tag.

I really dislike it that kasan has taken some page flags for its use.
I would much prefer it if kasan used some page_ext_flags. It's somewhat
slower to access them, and they take up a bit of extra space (unless
you already have CONFIG_PAGE_EXTENSION enabled). But page flags are a
really scarce resource and kasan has taken 9.