diff mbox

[v1,2/3] livepatch: Include sizes when an mismatch occurs

Message ID 20170711165313.26497-3-konrad.wilk@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Konrad Rzeszutek Wilk July 11, 2017, 4:53 p.m. UTC
If the .bug.frames.X or .livepatch.funcs sizes are different
than what the hypervisor expects - we fail the payload. To help
in diagnosing this include the expected and the payload
sizes.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 xen/common/livepatch.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Jan Beulich July 11, 2017, 7:59 p.m. UTC | #1
>>> Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> 07/11/17 6:53 PM >>>
>--- a/xen/common/livepatch.c
>+++ b/xen/common/livepatch.c
>@@ -520,8 +520,8 @@ static int prepare_payload(struct payload *payload,
     >ASSERT(sec);
     >if ( sec->sec->sh_size % sizeof(*payload->funcs) )
     >{
>-        dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size of "ELF_LIVEPATCH_FUNC"!\n",
>-                elf->name);
>+        dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size of "ELF_LIVEPATCH_FUNC"! (exp: %zu vs %"PRIuElfWord")\n",
>+                elf->name, sizeof(*payload->funcs), sec->sec->sh_size);

What you print as expected value isn't really the only permitted one - the
expectation is the value to be a multiple of it. I wonder if the message
text therefore isn't confusing now. Also, how about embedding the actual
size right in the base message, i.e. something like ''Wrong size NNN of ...
(must be multiple of MMM)"?

Jan
diff mbox

Patch

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 5d53096..c0eb609 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -520,8 +520,8 @@  static int prepare_payload(struct payload *payload,
     ASSERT(sec);
     if ( sec->sec->sh_size % sizeof(*payload->funcs) )
     {
-        dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size of "ELF_LIVEPATCH_FUNC"!\n",
-                elf->name);
+        dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size of "ELF_LIVEPATCH_FUNC"! (exp: %zu vs %"PRIuElfWord")\n",
+                elf->name, sizeof(*payload->funcs), sec->sec->sh_size);
         return -EINVAL;
     }
 
@@ -648,8 +648,9 @@  static int prepare_payload(struct payload *payload,
 
         if ( sec->sec->sh_size % sizeof(*region->frame[i].bugs) )
         {
-            dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size of .bug_frames.%u!\n",
-                    elf->name, i);
+            dprintk(XENLOG_ERR, LIVEPATCH "%s: Wrong size of .bug_frames.%u! (exp: %zu vs %"PRIuElfWord")\n",
+                    elf->name, i, sizeof(*region->frame[i].bugs),
+                    sec->sec->sh_size);
             return -EINVAL;
         }