s390/kasan: avoid short by one page shadow memory
authorAlexander Gordeev <agordeev@linux.ibm.com>
Fri, 26 May 2023 12:30:30 +0000 (14:30 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 20 Jun 2023 17:52:13 +0000 (19:52 +0200)
commit3e8261003bd28208986d3c42004510083c086e24
treec800f820adb082533ff7b3c92e0bfa394c1ab0fa
parent2ed8b509753a0454b52b2d72e982265472c8d861
s390/kasan: avoid short by one page shadow memory

Kernel Address Sanitizer uses 3 bits per byte to
encode memory. That is the number of bits the start
and end address of a memory range is shifted right
when the corresponding shadow memory is created for
that memory range.

The used memory mapping routine expects page-aligned
addresses, while the above described 3-bit shift might
turn the shadow memory range start and end boundaries
into non-page-aligned in case the size of the original
memory range is less than (PAGE_SIZE << 3). As result,
the resulting shadow memory range could be short on one
page.

Align on page boundary the start and end addresses when
mapping a shadow memory range and avoid the described
issue in the future.

Note, that does not fix a real problem, since currently
no virtual regions of size less than (PAGE_SIZE << 3)
exist.

Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/boot/vmem.c