Drivers: hv: balloon: don't crash when memory is added in non-sorted order
authorVitaly Kuznetsov <vkuznets@redhat.com>
Sun, 1 May 2016 02:21:35 +0000 (19:21 -0700)
committerWilly Tarreau <w@1wt.eu>
Tue, 20 Jun 2017 12:04:33 +0000 (14:04 +0200)
commit2b49b1938b5c74e90748d56999edf939e3251f24
tree4bac0f7f476ab0de9c241baae653c58014b3adfa
parent4bbe571cd9552b96303e0228818f9d002065e85b
Drivers: hv: balloon: don't crash when memory is added in non-sorted order

commit 77c0c9735bc0ba5898e637a3a20d6bcb50e3f67d upstream.

When we iterate through all HA regions in handle_pg_range() we have an
assumption that all these regions are sorted in the list and the
'start_pfn >= has->end_pfn' check is enough to find the proper region.
Unfortunately it's not the case with WS2016 where host can hot-add regions
in a different order. We end up modifying the wrong HA region and crashing
later on pages online. Modify the check to make sure we found the region
we were searching for while iterating. Fix the same check in pfn_covered()
as well.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Willy Tarreau <w@1wt.eu>
drivers/hv/hv_balloon.c