xen/ubsan: Implement __ubsan_handle_nonnull_arg()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 3 Oct 2017 18:07:52 +0000 (19:07 +0100)
committerWei Liu <wei.liu2@citrix.com>
Mon, 9 Oct 2017 16:04:58 +0000 (17:04 +0100)
This hook appears to be missing from the Linux ubsan implemention.  This patch
is a forward port of https://lkml.org/lkml/2014/10/20/182

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/common/ubsan/ubsan.c

index fb0409df1bcf8474969ab5bf28f2c9623a77e041..685b4de0d63edca014369d915d294fcb03835d16 100644 (file)
@@ -328,6 +328,25 @@ void __ubsan_handle_type_mismatch(struct type_mismatch_data *data,
 }
 EXPORT_SYMBOL(__ubsan_handle_type_mismatch);
 
+void __ubsan_handle_nonnull_arg(struct nonnull_arg_data *data)
+{
+       unsigned long flags;
+
+       if (suppress_report(&data->location))
+               return;
+
+       ubsan_prologue(&data->location, &flags);
+
+       pr_err("null pointer passed as argument %d, declared with nonnull attribute\n",
+              data->arg_index);
+
+       if (location_is_valid(&data->attr_location))
+               print_source_location("nonnull attribute declared in ",
+                                     &data->attr_location);
+
+       ubsan_epilogue(&flags);
+}
+
 void __ubsan_handle_nonnull_return(struct nonnull_return_data *data)
 {
        unsigned long flags;