]> git.baikalelectronics.ru Git - kernel.git/commit
dm table: fix invalid memory accesses with too high sector number
authorMikulas Patocka <mpatocka@redhat.com>
Fri, 23 Aug 2019 13:54:09 +0000 (09:54 -0400)
committerMike Snitzer <snitzer@redhat.com>
Fri, 23 Aug 2019 14:11:42 +0000 (10:11 -0400)
commitdd57fd15ef2eb45fcf75b51a0ec354afc17be7ad
tree034851b363826a16d05f251473bf526b895f80c3
parent25b7711be66e289f0f7c9af315d831b2823a51c9
dm table: fix invalid memory accesses with too high sector number

If the sector number is too high, dm_table_find_target() should return a
pointer to a zeroed dm_target structure (the caller should test it with
dm_target_is_valid).

However, for some table sizes, the code in dm_table_find_target() that
performs btree lookup will access out of bound memory structures.

Fix this bug by testing the sector number at the beginning of
dm_table_find_target(). Also, add an "inline" keyword to the function
dm_table_get_size() because this is a hot path.

Fixes: 99d92fef3437 ("dm: table detect io beyond device")
Cc: stable@vger.kernel.org
Reported-by: Zhang Tao <kontais@zoho.com>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
drivers/md/dm-table.c