]> www.infradead.org Git - users/jedix/linux-maple.git/commit
iommufd/selftest: Fix buffer read overrrun in the dirty test
authorJason Gunthorpe <jgg@nvidia.com>
Thu, 22 Aug 2024 14:47:09 +0000 (11:47 -0300)
committerJason Gunthorpe <jgg@nvidia.com>
Tue, 27 Aug 2024 12:47:04 +0000 (09:47 -0300)
commit79ea4a496ab5c970a3a793d863ed8893b1af107c
tree2ea7d8b3c5726a2d7bc5320492fe0d6887d2c8d6
parent1d4684fbe88dc28e2bf79f5e94a432f0469d2dac
iommufd/selftest: Fix buffer read overrrun in the dirty test

test_bit() is used to read the memory storing the bitmap, however
test_bit() always uses a unsigned long 8 byte access.

If the bitmap is not an aligned size of 64 bits this will now trigger a
KASAN warning reading past the end of the buffer.

Properly round the buffer allocation to an unsigned long size. Continue to
copy_from_user() using a byte granularity.

Fixes: 9560393b830b ("iommufd/selftest: Fix iommufd_test_dirty() to handle <u8 bitmaps")
Link: https://patch.msgid.link/r/0-v1-113e8d9e7861+5ae-iommufd_kasan_jgg@nvidia.com
Reviewed-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
drivers/iommu/iommufd/selftest.c