Skip to content

Commit

Permalink
ubsan: Fix pointer overflow error message
Browse files Browse the repository at this point in the history
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: 4e3fb2f ("ubsan: add clang 5.0 support")
Signed-off-by: Michal Orzel <[email protected]>
Acked-by: Andrew Cooper <[email protected]>
  • Loading branch information
orzelmichal authored and andyhhp committed Nov 7, 2023
1 parent e3c409d commit fab5109
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion xen/common/ubsan/ubsan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fab5109

Please sign in to comment.