]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
lib/test_hmm: avoid accessing uninitialized pages
authorMiaohe Lin <linmiaohe@huawei.com>
Thu, 9 Jun 2022 13:08:35 +0000 (21:08 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 17 Oct 2022 09:56:34 +0000 (11:56 +0200)
commit152e0a2267027f94aff157850667208c745aac32
tree1ae72806188797ea93085a02c1e540d3504a5925
parenta53d4d53ec2bbd9d71b388a504de2323c3fee500
lib/test_hmm: avoid accessing uninitialized pages

BugLink: https://bugs.launchpad.net/bugs/1990162
[ Upstream commit ed913b055a74b723976f8e885a3395162a0371e6 ]

If make_device_exclusive_range() fails or returns pages marked for
exclusive access less than required, remaining fields of pages will left
uninitialized.  So dmirror_atomic_map() will access those yet
uninitialized fields of pages.  To fix it, do dmirror_atomic_map() iff all
pages are marked for exclusive access (we will break if mapped is less
than required anyway) so we won't access those uninitialized fields of
pages.

Link: https://lkml.kernel.org/r/20220609130835.35110-1-linmiaohe@huawei.com
Fixes: b659baea7546 ("mm: selftests for exclusive device memory")
Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
lib/test_hmm.c