mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
x86/hvm: Fix UB on defensive default case in handle_pio()
There's a potential 32bit left-shift (when size is 4) to a 32bit value,
which would trigger UB and tickle UBSAN the wrong way. Shifting right an
all-ones mask fixes the issue.
Fixes: 4609fc8eb0 ("x86/hvm: Improve error information in handle_pio()")
Signed-off-by: Alejandro Vallejo <alejandro.garciavallejo@amd.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
7d50aaad10
commit
2b3f56ab51
1 file changed
+1
-1
@@ -135,7 +135,7 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
|
|||||||
default:
|
default:
|
||||||
gprintk(XENLOG_ERR, "Unexpected PIO status %d, port %#x %s 0x%0*x\n",
|
gprintk(XENLOG_ERR, "Unexpected PIO status %d, port %#x %s 0x%0*x\n",
|
||||||
rc, port, dir == IOREQ_WRITE ? "write" : "read",
|
rc, port, dir == IOREQ_WRITE ? "write" : "read",
|
||||||
size * 2, data & ((1u << (size * 8)) - 1));
|
size * 2, data & (UINT32_MAX >> (32 - size * 8)));
|
||||||
domain_crash(curr->domain);
|
domain_crash(curr->domain);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||