]> xenbits.xensource.com Git - xen.git/commitdiff
ubsan: Fix pointer overflow error message
authorMichal Orzel <michal.orzel@amd.com>
Tue, 7 Nov 2023 09:14:17 +0000 (10:14 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 7 Nov 2023 10:00:11 +0000 (10:00 +0000)
In __ubsan_handle_pointer_overflow(), fix the condition for determining
whether a pointer operation overflowed or underflowed. Currently, the
function reports "underflowed" when it should be reporting "overflowed"
and vice versa.

Example of incorrect error reporting:
void *foo = (void *)__UINTPTR_MAX__;
foo += 1;

UBSAN:
pointer operation underflowed ffffffff to 00000000

Fixes: 4e3fb2fb47d6 ("ubsan: add clang 5.0 support")
Signed-off-by: Michal Orzel <michal.orzel@amd.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/ubsan/ubsan.c

index 0fddacabda6ac4ab9f5ccba795e70f8dd544ebe1..a3a80fa99eecc3b0b9867c643efc7ab4d53afbd8 100644 (file)
@@ -513,7 +513,7 @@ void __ubsan_handle_pointer_overflow(struct pointer_overflow_data *data,
        ubsan_prologue(&data->location, &flags);
 
        pr_err("pointer operation %s %p to %p\n",
-              base > result ? "underflowed" : "overflowed",
+              base > result ? "overflowed" : "underflowed",
               _p(base), _p(result));
 
        ubsan_epilogue(&flags);