[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] tools/libxl: Fixes to libxl__domain_set_paging_mempool_size()


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 21 Nov 2022 14:37:30 +0000
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Henry Wang <Henry.Wang@xxxxxxx>
  • Delivery-date: Mon, 21 Nov 2022 14:37:48 +0000
  • Ironport-data: A9a23:oaQB36NGvw4EYGLvrR3Jl8FynXyQoLVcMsEvi/4bfWQNrUp00mMPn GtMXG+Ob/uPN2TxfI12PI3j805U6JTUx4dqTAto+SlhQUwRpJueD7x1DKtS0wC6dZSfER09v 63yTvGacajYm1eF/k/F3oDJ9CU6jufQA+KmU4YoAwgpLSd8UiAtlBl/rOAwh49skLCRDhiE/ Nj/uKUzAnf8s9JPGj9SuvzrRC9H5qyo4mpB5AVmPJingXeF/5UrJMNHTU2OByOQrrl8RoaSW +vFxbelyWLVlz9F5gSNy+uTnuUiG9Y+DCDW4pZkc/HKbitq/0Te5p0TJvsEAXq7vh3S9zxHJ HehgrTrIeshFvWkdO3wyHC0GQkmVUFN0OevzXRSLaV/ZqAJGpfh66wGMa04AWEX0u9ZIkYT/ KZBEmwmN0upi73p4b+JFeY506zPLOGzVG8eknRpzDWfBvc6W5HTBa7N4Le03h9p2JoIR6yHI ZNEN3w/N3wsYDUWUrsTILs4kP2lmT/UdDpApUjOjaE2/3LS3Ep6172F3N/9KoHQGpkKwhrwS mTu/0CoOg5KJtem6mSCw3jytMSX2j7fcddHfFG/3qEz2wDCroAJMzU2WF2hsL+Gg0ixc9tFL gof/S9Ghbg/8gmnQ8fwWzW8oWWYpVgMVtxICeo45QqRjK3O7G6k6nMsF2AbLoZ87YlvGGJsh gThc87V6SJHuZO2bi+UrO6u8RjrYgIZcjAjaB1bQl5QizX8m70bghXKR9dlNae6iNzpBD39q wy3QDgCa6Y71pBSifjilbzTq3f1/8WSEFZpjunCdjj9hj6VcrJJcGBBBbLzyf9bZLiUQVCa1 JTvs5jPtbteZX1hecHkfQnsIF1Kz6zfWNE5vbKIN8dJythV0yT/Fb28GRknTKqpW+5dEdMTX GfduBlK+LhYN2awYKl8buqZUpp0nfm+RI6+Cq6MMrKih6SdkyferUlTibO4hTixwCDAb4liU XtkTSpcJSlDUvk2pNZHb+wczaUq1kgDKZD7HPjGItXO+eT2WUN5vp9fbgDRP7hlsP3ZyOgXm v4GX/a3J9xkeLWWSkHqHUQ7dDjm8VBT6UjKlvFq
  • Ironport-hdrordr: A9a23:Vkj/tKtZPkAEFi9VuPyHl7Pl7skDdtV00zEX/kB9WHVpmszxra +TdZUgpHnJYVkqOU3I9ersBEDEewK/yXcX2/h3AV7BZmnbUQKTRekIh7cKgQeQfhEWntQtsZ uIGJIRNDSfNzRHZL7BkWqFL+o=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The error message accidentally printed the bytes value as if it were kB.

Furthermore, both b_info.shadow_memkb and shadow_mem are uint64_t, meaning
there is a risk of overflow if the user specified a stupidly large value in
the vm.cfg file.  Check and reject such a condition.

Fixes: 7c3bbd940dd8 ("xen/arm, libxl: Revert XEN_DOMCTL_shadow_op; use p2m 
mempool hypercalls")
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Anthony PERARD <anthony.perard@xxxxxxxxxx>
CC: Henry Wang <Henry.Wang@xxxxxxx>

v2:
 * Retain PRIu64
 * Check for overflow

For 4.17.  This is a low risk change, removes one overflow case, and makes an
error message accurate.
---
 tools/libs/light/libxl_dom.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/libs/light/libxl_dom.c b/tools/libs/light/libxl_dom.c
index fa5c79e4f650..b454f988fbc5 100644
--- a/tools/libs/light/libxl_dom.c
+++ b/tools/libs/light/libxl_dom.c
@@ -1458,10 +1458,18 @@ int libxl__domain_set_paging_mempool_size(
     shadow_mem = d_config->b_info.shadow_memkb;
     shadow_mem <<= 10;
 
+    if ((shadow_mem >> 10) != d_config->b_info.shadow_memkb) {
+        LOGED(ERROR, domid,
+              "shadow_memkb value %"PRIu64"kB too large",
+              d_config->b_info.shadow_memkb);
+        return ERROR_FAIL;
+    }
+
     int r = xc_set_paging_mempool_size(CTX->xch, domid, shadow_mem);
     if (r) {
         LOGED(ERROR, domid,
-              "Failed to set paging mempool size to %"PRIu64"kB", shadow_mem);
+              "Failed to set paging mempool size to %"PRIu64"kB",
+              d_config->b_info.shadow_memkb);
         return ERROR_FAIL;
     }
 
-- 
2.11.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.