git: 5d15f0d5406b - stable/14 - kmsan: Correct the origin address in kmsan_shadow_check()

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Sat, 11 Nov 2023 17:30:46 UTC
The branch stable/14 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=5d15f0d5406b6d27ecc8fa21a6d93754bf6c85f4

commit 5d15f0d5406b6d27ecc8fa21a6d93754bf6c85f4
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-11-03 19:37:09 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-11-11 17:30:37 +0000

    kmsan: Correct the origin address in kmsan_shadow_check()
    
    Otherwise a KMSAN report (which panics the system by default) could
    trigger a recursive panic.
    
    MFC after:      1 week
    Fixes:  ca6cd604c8fc ("kmsan: Use the correct origin bytes in kmsan_check_arg()")
    
    (cherry picked from commit 346134f19aa9ba38a0384244609e2bcd4f7838f4)
---
 sys/kern/subr_msan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c
index f8fdcf478b79..abac71da6d64 100644
--- a/sys/kern/subr_msan.c
+++ b/sys/kern/subr_msan.c
@@ -375,7 +375,7 @@ kmsan_shadow_check(uintptr_t addr, size_t size, const char *hook)
 	for (i = 0; i < size; i++) {
 		if (__predict_true(shad[i] == 0))
 			continue;
-		orig = (msan_orig_t *)kmsan_md_addr_to_orig((vm_offset_t)&shad[i]);
+		orig = (msan_orig_t *)kmsan_md_addr_to_orig(addr + i);
 		orig = (msan_orig_t *)((uintptr_t)orig & MSAN_ORIG_MASK);
 		kmsan_report_hook((const char *)addr + i, orig, size, i, hook);
 		break;