diff mbox series

ubsan: Fix pointer overflow error message

Message ID 20231107091417.34159-1-michal.orzel@amd.com (mailing list archive)
State New, archived
Headers show
Series ubsan: Fix pointer overflow error message | expand

Commit Message

Michal Orzel Nov. 7, 2023, 9:14 a.m. UTC
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>
---
 xen/common/ubsan/ubsan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Cooper Nov. 7, 2023, 9:25 a.m. UTC | #1
On 07/11/2023 9:14 am, Michal Orzel wrote:
> 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>
> ---
>  xen/common/ubsan/ubsan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c
> index 0fddacabda6a..a3a80fa99eec 100644
> --- a/xen/common/ubsan/ubsan.c
> +++ b/xen/common/ubsan/ubsan.c
> @@ -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",

Lovely.

Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox series

Patch

diff --git a/xen/common/ubsan/ubsan.c b/xen/common/ubsan/ubsan.c
index 0fddacabda6a..a3a80fa99eec 100644
--- a/xen/common/ubsan/ubsan.c
+++ b/xen/common/ubsan/ubsan.c
@@ -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);