]> xenbits.xensource.com Git - xen.git/commitdiff
xen/ubsan: expand pointer overflow message printing
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 13 Mar 2025 11:02:50 +0000 (12:02 +0100)
committerRoger Pau Monne <roger.pau@citrix.com>
Mon, 17 Mar 2025 12:33:29 +0000 (13:33 +0100)
Add messages about operations against the NULL pointer, or that result in
a NULL pointer.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
xen/common/ubsan/ubsan.c

index 7ebe4bfc14dc0edbef6a9c61c70ac6cb507b79f4..20aa0cb598e1ca3fa5a7ee001d24dcece0701e1d 100644 (file)
@@ -517,9 +517,18 @@ 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 ? "overflowed" : "underflowed",
-              _p(base), _p(result));
+       if (!base && !result)
+               pr_err("applying zero offset to null pointer\n");
+       else if (!base && result)
+               pr_err("applying non-zero offset %p to null pointer\n",
+                       _p(result));
+       else if (base && !result)
+               pr_err("applying non-zero offset to non-null pointer %p produced null pointer\n",
+                       _p(base));
+       else
+               pr_err("pointer operation %s %p to %p\n",
+                       base > result ? "overflowed" : "underflowed",
+                       _p(base), _p(result));
 
        ubsan_epilogue(&flags);
 }