[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 5/7] contrib/elf2dmp: Use rol64() to decode
From: |
Akihiko Odaki |
Subject: |
[PATCH 5/7] contrib/elf2dmp: Use rol64() to decode |
Date: |
Sun, 03 Mar 2024 19:50:39 +0900 |
rol64() is roubust against too large shift values and fixes UBSan
warnings.
Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
---
contrib/elf2dmp/main.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/contrib/elf2dmp/main.c b/contrib/elf2dmp/main.c
index dd686280f981..432f8629f321 100644
--- a/contrib/elf2dmp/main.c
+++ b/contrib/elf2dmp/main.c
@@ -6,6 +6,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/bitops.h"
#include "err.h"
#include "addrspace.h"
@@ -47,11 +48,6 @@ static const uint64_t SharedUserData = 0xfffff78000000000;
s ? printf(#s" = 0x%016"PRIx64"\n", s) :\
eprintf("Failed to resolve "#s"\n"), s)
-static uint64_t rol(uint64_t x, uint64_t y)
-{
- return (x << y) | (x >> (64 - y));
-}
-
/*
* Decoding algorithm can be found in Volatility project
*/
@@ -64,7 +60,7 @@ static void kdbg_decode(uint64_t *dst, uint64_t *src, size_t
size,
uint64_t block;
block = src[i];
- block = rol(block ^ kwn, (uint8_t)kwn);
+ block = rol64(block ^ kwn, kwn);
block = __builtin_bswap64(block ^ kdbe) ^ kwa;
dst[i] = block;
}
--
2.44.0
- [PATCH 0/7] contrib/elf2dmp: Improve robustness, Akihiko Odaki, 2024/03/03
- [PATCH 1/7] contrib/elf2dmp: Always check for PA resolution failure, Akihiko Odaki, 2024/03/03
- [PATCH 2/7] contrib/elf2dmp: Always destroy PA space, Akihiko Odaki, 2024/03/03
- [PATCH 3/7] contrib/elf2dmp: Ensure segment fits in file, Akihiko Odaki, 2024/03/03
- [PATCH 4/7] contrib/elf2dmp: Use lduw_le_p() to read PDB, Akihiko Odaki, 2024/03/03
- [PATCH 5/7] contrib/elf2dmp: Use rol64() to decode,
Akihiko Odaki <=
- [PATCH 7/7] MAINTAINERS: Add Akihiko Odaki as a elf2dmp reviewer, Akihiko Odaki, 2024/03/03
- [PATCH 6/7] contrib/elf2dmp: Continue even contexts are lacking, Akihiko Odaki, 2024/03/03
- Re: [PATCH 0/7] contrib/elf2dmp: Improve robustness, Peter Maydell, 2024/03/04