]> git.proxmox.com Git - mirror_ubuntu-bionic-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)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 4 Sep 2019 20:23:27 +0000 (16:23 -0400)
commitc9f083014f90c73ed7c64d821fe957b510cfea7e
tree3098efb2537f27689b0b11a4103c871bc4de407b
parentcb4733b6deaac2bdf1b6b1c850e01333fcd8db1a
dm table: fix invalid memory accesses with too high sector number

BugLink: https://bugs.launchpad.net/bugs/1842114
commit 1cfd5d3399e87167b7f9157ef99daa0e959f395d upstream.

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: 512875bd9661 ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/md/dm-table.c