Commit 4b8365d752ef introduced the ability to dynamically register
VM object types, for use by tmpfs, which creates swap-backed objects.
As a part of this, checks for such objects changed from
object->type == OBJT_DEFAULT || object->type == OBJT_SWAP
to
object->type == OBJT_DEFAULT || (object->flags & OBJ_SWAP) != 0
In particular, objects of type OBJT_DEFAULT do not have OBJ_SWAP set;
the swap pager sets this flag when converting from OBJT_DEFAULT to
OBJT_SWAP.
A few of these checks are done without the object lock held. It turns
out that this can result in false negatives since the swap pager
converts objects like so:
object->type = OBJT_SWAP; object->flags |= OBJ_SWAP;
See comment 16 of PR 258932 for an example of how this can cause
problems.
Fix the problem rather simplistically, by adding tests for
object->type == OBJT_SWAP in places where we locklessly test for a
swap-backed object. Suggestions for a more robust approach would be
appreciated. We could perhaps add a store barrier in
swp_pager_meta_build(), for instance.
PR: 258932
Fixes: 4b8365d752ef ("Add OBJT_SWAP_TMPFS pager")