lkdtm: Correct the size value for WRITE_KERN

Correct the value of size, WRITE_KERN will not work as expected
if the do_overwritten is less than do_nothing.

Change-Id: I2c69c62829cd55f280efd63763316b91691c0620
Signed-off-by: Lijuan Gao <lijuang@codeaurora.org>
This commit is contained in:
Lijuan Gao 2020-07-03 15:13:33 +08:00 committed by Gerrit - the friendly Code Review server
parent 89086d9cfb
commit 8aee7c9bba

View File

@ -109,7 +109,12 @@ void lkdtm_WRITE_KERN(void)
size_t size;
unsigned char *ptr;
size = (unsigned long)do_overwritten - (unsigned long)do_nothing;
if ((unsigned long)do_overwritten < (unsigned long)do_nothing)
size = (unsigned long)do_nothing -
(unsigned long)do_overwritten;
else
size = (unsigned long)do_overwritten -
(unsigned long)do_nothing;
ptr = (unsigned char *)do_overwritten;
pr_info("attempting bad %zu byte write at %px\n", size, ptr);