]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/swapfile: fix possible data races of inuse_pages
authorMiaohe Lin <linmiaohe@huawei.com>
Wed, 8 Jun 2022 14:40:30 +0000 (22:40 +0800)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 20 Jul 2022 00:15:05 +0000 (20:15 -0400)
commite45cb5c17c80969dfa5a975d7eb2dd82c5d040b5
tree51eb8fc5c4fe26742961241331763f0ecb179c0b
parent7c24e10ff90beb350f668bb57b8a796ba62c9a20
mm/swapfile: fix possible data races of inuse_pages

si->inuse_pages could still be accessed concurrently now.  The plain reads
outside si->lock critical section, i.e.  swap_show and si_swapinfo, which
results in data races.  READ_ONCE and WRITE_ONCE is used to fix such data
races.  Note these data races should be ok because they're just used for
showing swap info.

Link: https://lkml.kernel.org/r/20220608144031.829-3-linmiaohe@huawei.com
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/swapfile.c