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

[Xen-changelog] [xen master] tools/kdd: don't use a pointer to an unaligned field.



commit bfd9a2095f1882e8c074b2d911bcb07d12cf6cf5
Author:     Tim Deegan <tim@xxxxxxx>
AuthorDate: Fri Mar 10 10:10:57 2017 +0000
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Wed Mar 15 10:57:00 2017 +0000

    tools/kdd: don't use a pointer to an unaligned field.
    
    The 'val' field in the packet is byte-aligned (because it is part of a
    packed struct), but the pointer argument to kdd_rdmsr() has the normal
    alignment constraints for a uint64_t *.  Use a local variable to make sure
    the passed pointer has the correct alignment.
    
    Reported-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Signed-off-by: Tim Deegan <tim@xxxxxxx>
    Acked-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
    Tested-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 tools/debugger/kdd/kdd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/debugger/kdd/kdd.c b/tools/debugger/kdd/kdd.c
index 70f007e..1bd5dd5 100644
--- a/tools/debugger/kdd/kdd.c
+++ b/tools/debugger/kdd/kdd.c
@@ -710,11 +710,13 @@ static void kdd_handle_read_ctrl(kdd_state *s)
 static void kdd_handle_read_msr(kdd_state *s)
 {
     uint32_t msr = s->rxp.cmd.msr.msr;
+    uint64_t val;
     int ok;
     KDD_LOG(s, "Read MSR 0x%"PRIx32"\n", msr);
 
-    ok = (kdd_rdmsr(s->guest, s->cpuid, msr, &s->txp.cmd.msr.val) == 0);
+    ok = (kdd_rdmsr(s->guest, s->cpuid, msr, &val) == 0);
     s->txp.cmd.msr.msr = msr;
+    s->txp.cmd.msr.val = val;
     s->txp.cmd.msr.status = (ok ? KDD_STATUS_SUCCESS : KDD_STATUS_FAILURE);
     kdd_send_cmd(s, KDD_CMD_READ_MSR, 0);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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