]> xenbits.xensource.com Git - people/royger/xen.git/commitdiff
x86/apei: CFI hardening
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 29 Oct 2021 18:37:20 +0000 (19:37 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 23 Feb 2022 15:33:43 +0000 (15:33 +0000)
Control Flow Integrity schemes use toolchain and optionally hardware support
to help protect against call/jump/return oriented programming attacks.

Use cf_check to annotate function pointer targets for the toolchain.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/drivers/acpi/apei/apei-base.c
xen/drivers/acpi/apei/apei-internal.h
xen/drivers/acpi/apei/erst.c

index 6f81e7fa366ae608d2f533d2b4c90e67db04cf5f..de75c1cef9922f8fd7a82b13ce1446b6231a612e 100644 (file)
@@ -80,8 +80,8 @@ int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val)
        return 0;
 }
 
-int apei_exec_read_register(struct apei_exec_context *ctx,
-                           struct acpi_whea_header *entry)
+int cf_check apei_exec_read_register(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
        u64 val = 0;
@@ -94,8 +94,8 @@ int apei_exec_read_register(struct apei_exec_context *ctx,
        return 0;
 }
 
-int apei_exec_read_register_value(struct apei_exec_context *ctx,
-                                 struct acpi_whea_header *entry)
+int cf_check apei_exec_read_register_value(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
 
@@ -126,14 +126,14 @@ int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val)
        return rc;
 }
 
-int apei_exec_write_register(struct apei_exec_context *ctx,
-                            struct acpi_whea_header *entry)
+int cf_check apei_exec_write_register(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        return __apei_exec_write_register(entry, ctx->value);
 }
 
-int apei_exec_write_register_value(struct apei_exec_context *ctx,
-                                  struct acpi_whea_header *entry)
+int cf_check apei_exec_write_register_value(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
 
@@ -143,8 +143,8 @@ int apei_exec_write_register_value(struct apei_exec_context *ctx,
        return rc;
 }
 
-int apei_exec_noop(struct apei_exec_context *ctx,
-                  struct acpi_whea_header *entry)
+int cf_check apei_exec_noop(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        return 0;
 }
@@ -230,9 +230,9 @@ static int __init apei_exec_for_each_entry(struct apei_exec_context *ctx,
        return 0;
 }
 
-static int __init pre_map_gar_callback(struct apei_exec_context *ctx,
-                                      struct acpi_whea_header *entry,
-                                      void *data)
+static int __init cf_check pre_map_gar_callback(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry,
+       void *data)
 {
        u8 ins = entry->instruction;
 
@@ -259,9 +259,9 @@ int __init apei_exec_pre_map_gars(struct apei_exec_context *ctx)
        return rc;
 }
 
-static int __init post_unmap_gar_callback(struct apei_exec_context *ctx,
-                                         struct acpi_whea_header *entry,
-                                         void *data)
+static int __init cf_check post_unmap_gar_callback(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry,
+       void *data)
 {
        u8 ins = entry->instruction;
 
index b813d55b92a9590fa150964549562921c2843d52..360e94b9c8772d5039319e6714d95d9d810f38a3 100644 (file)
@@ -68,16 +68,16 @@ static inline int apei_exec_run_optional(struct apei_exec_context *ctx, u8 actio
 
 int __apei_exec_read_register(struct acpi_whea_header *entry, u64 *val);
 int __apei_exec_write_register(struct acpi_whea_header *entry, u64 val);
-int apei_exec_read_register(struct apei_exec_context *ctx,
-                           struct acpi_whea_header *entry);
-int apei_exec_read_register_value(struct apei_exec_context *ctx,
-                                 struct acpi_whea_header *entry);
-int apei_exec_write_register(struct apei_exec_context *ctx,
-                            struct acpi_whea_header *entry);
-int apei_exec_write_register_value(struct apei_exec_context *ctx,
-                                  struct acpi_whea_header *entry);
-int apei_exec_noop(struct apei_exec_context *ctx,
-                  struct acpi_whea_header *entry);
+int cf_check apei_exec_read_register(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry);
+int cf_check apei_exec_read_register_value(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry);
+int cf_check apei_exec_write_register(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry);
+int cf_check apei_exec_write_register_value(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry);
+int cf_check apei_exec_noop(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry);
 int apei_exec_pre_map_gars(struct apei_exec_context *ctx);
 int apei_exec_post_unmap_gars(struct apei_exec_context *ctx);
 
index c5df512b98384c06544c25381ca5cb5891fd9232..40d8f00270d0ac5acab558661d4041f1634c6bf9 100644 (file)
@@ -114,40 +114,40 @@ static int erst_timedout(u64 *t, u64 spin_unit)
        return 0;
 }
 
-static int erst_exec_load_var1(struct apei_exec_context *ctx,
-                              struct acpi_whea_header *entry)
+static int cf_check erst_exec_load_var1(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        return __apei_exec_read_register(entry, &ctx->var1);
 }
 
-static int erst_exec_load_var2(struct apei_exec_context *ctx,
-                              struct acpi_whea_header *entry)
+static int cf_check erst_exec_load_var2(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        return __apei_exec_read_register(entry, &ctx->var2);
 }
 
-static int erst_exec_store_var1(struct apei_exec_context *ctx,
-                               struct acpi_whea_header *entry)
+static int cf_check erst_exec_store_var1(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        return __apei_exec_write_register(entry, ctx->var1);
 }
 
-static int erst_exec_add(struct apei_exec_context *ctx,
-                        struct acpi_whea_header *entry)
+static int cf_check erst_exec_add(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        ctx->var1 += ctx->var2;
        return 0;
 }
 
-static int erst_exec_subtract(struct apei_exec_context *ctx,
-                             struct acpi_whea_header *entry)
+static int cf_check erst_exec_subtract(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        ctx->var1 -= ctx->var2;
        return 0;
 }
 
-static int erst_exec_add_value(struct apei_exec_context *ctx,
-                              struct acpi_whea_header *entry)
+static int cf_check erst_exec_add_value(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
        u64 val;
@@ -160,8 +160,8 @@ static int erst_exec_add_value(struct apei_exec_context *ctx,
        return rc;
 }
 
-static int erst_exec_subtract_value(struct apei_exec_context *ctx,
-                                   struct acpi_whea_header *entry)
+static int cf_check erst_exec_subtract_value(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
        u64 val;
@@ -174,8 +174,8 @@ static int erst_exec_subtract_value(struct apei_exec_context *ctx,
        return rc;
 }
 
-static int erst_exec_stall(struct apei_exec_context *ctx,
-                          struct acpi_whea_header *entry)
+static int cf_check erst_exec_stall(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        udelay((ctx->var1 > FIRMWARE_MAX_STALL) ? 
                        FIRMWARE_MAX_STALL : 
@@ -183,8 +183,8 @@ static int erst_exec_stall(struct apei_exec_context *ctx,
        return 0;
 }
 
-static int erst_exec_stall_while_true(struct apei_exec_context *ctx,
-                                     struct acpi_whea_header *entry)
+static int cf_check erst_exec_stall_while_true(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
        u64 val;
@@ -205,9 +205,8 @@ static int erst_exec_stall_while_true(struct apei_exec_context *ctx,
        return 0;
 }
 
-static int erst_exec_skip_next_instruction_if_true(
-       struct apei_exec_context *ctx,
-       struct acpi_whea_header *entry)
+static int cf_check erst_exec_skip_next_instruction_if_true(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
        u64 val;
@@ -223,27 +222,27 @@ static int erst_exec_skip_next_instruction_if_true(
        return 0;
 }
 
-static int erst_exec_goto(struct apei_exec_context *ctx,
-                         struct acpi_whea_header *entry)
+static int cf_check erst_exec_goto(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        ctx->ip = ctx->value;
        return APEI_EXEC_SET_IP;
 }
 
-static int erst_exec_set_src_address_base(struct apei_exec_context *ctx,
-                                         struct acpi_whea_header *entry)
+static int cf_check erst_exec_set_src_address_base(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        return __apei_exec_read_register(entry, &ctx->src_base);
 }
 
-static int erst_exec_set_dst_address_base(struct apei_exec_context *ctx,
-                                         struct acpi_whea_header *entry)
+static int cf_check erst_exec_set_dst_address_base(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        return __apei_exec_read_register(entry, &ctx->dst_base);
 }
 
-static int erst_exec_move_data(struct apei_exec_context *ctx,
-                              struct acpi_whea_header *entry)
+static int cf_check erst_exec_move_data(
+       struct apei_exec_context *ctx, struct acpi_whea_header *entry)
 {
        int rc;
        u64 offset;