mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 02:01:24 +01:00
xsm/flask: Fix undefined behaviour in avc_dump_av()
When booting Xen with CONFIG_USBAN=y and CONFIG_XSM_FLASK=y, UBSAN reports undefined behaviour in avc_dump_av() due to a left shift on a signed int: (XEN) [ 1.104348] ================================================================================ (XEN) [ 1.105096] UBSAN: Undefined behaviour in xsm/flask/avc.c:184:14 (XEN) [ 1.106052] left shift of 1073741824 by 1 places cannot be represented in type 'int' (XEN) [ 1.107546] Xen WARN at common/ubsan/ubsan.c:176 (XEN) [ 1.108295] ----[ Xen-4.21.1 arm64 debug=y ubsan=y Not tainted ]---- (XEN) [ 1.108848] CPU: 0 (XEN) [ 1.109147] PC: 00000a00002f64fc ubsan.c#ubsan_epilogue+0x10/0xd4 [...] (XEN) [ 1.146320] Xen call trace: (XEN) [ 1.146663] [<00000a00002f64fc>] ubsan.c#ubsan_epilogue+0x10/0xd4 (PC) (XEN) [ 1.147227] [<00000a00002f7bc4>] __ubsan_handle_shift_out_of_bounds+0x1a0/0x290 (LR) (XEN) [ 1.147868] (XEN) [ 1.148177] ================================================================================ This can be solved by making 'perm' an unsigned 32-bit type (u32). Signed-off-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com> Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
This commit is contained in:
1 parent
4ff927133e
commit
4f9457ece1
1 file changed
+2
-1
+2
-1
@@ -152,7 +152,8 @@ static void __attribute__ ((format (printf, 2, 3)))
|
||||
*/
|
||||
static void avc_dump_av(struct avc_dump_buf *buf, u16 tclass, u32 av)
|
||||
{
|
||||
int i, i2, perm;
|
||||
int i, i2;
|
||||
uint32_t perm;
|
||||
|
||||
if ( av == 0 )
|
||||
{
|
||||
|
||||