xen: CFI hardening for call_rcu()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 28 Oct 2021 09:28:35 +0000 (10:28 +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/arch/x86/hvm/mtrr.c
xen/arch/x86/hvm/vmsi.c
xen/arch/x86/mm/mem_sharing.c
xen/arch/x86/percpu.c
xen/common/domain.c
xen/common/radix-tree.c
xen/common/rcupdate.c
xen/common/sched/core.c
xen/xsm/flask/avc.c

index b3ef1bf54133ad6511a3a1dbc2583e3107886a1c..42f3d83192960dc763351bbe9825b2bea924d748 100644 (file)
@@ -586,7 +586,7 @@ int hvm_get_mem_pinned_cacheattr(struct domain *d, gfn_t gfn,
     return rc;
 }
 
-static void free_pinned_cacheattr_entry(struct rcu_head *rcu)
+static void cf_check free_pinned_cacheattr_entry(struct rcu_head *rcu)
 {
     xfree(container_of(rcu, struct hvm_mem_pinned_cacheattr_range, rcu));
 }
index 13e2a190b439db67882406bc76096988dc227c7d..2889575a2035c2d68ca7ce8092e0769a535413a8 100644 (file)
@@ -441,7 +441,7 @@ static void add_msixtbl_entry(struct domain *d,
     list_add_rcu(&entry->list, &d->arch.hvm.msixtbl_list);
 }
 
-static void free_msixtbl_entry(struct rcu_head *rcu)
+static void cf_check free_msixtbl_entry(struct rcu_head *rcu)
 {
     struct msixtbl_entry *entry;
 
index 74d2869c0e6faa89f40236c992f2e9fedcc1af15..15e6a7ed814b169ca676e2edb159c18647acb5d6 100644 (file)
@@ -75,7 +75,7 @@ static DEFINE_SPINLOCK(shr_audit_lock);
 static DEFINE_RCU_READ_LOCK(shr_audit_read_lock);
 
 /* RCU delayed free of audit list entry */
-static void _free_pg_shared_info(struct rcu_head *head)
+static void cf_check _free_pg_shared_info(struct rcu_head *head)
 {
     xfree(container_of(head, struct page_sharing_info, rcu_head));
 }
index eb3ba7bc8874eebc1a786fab245982e73d848cb4..46460689b73d4e70595eae98c03e1de87b810017 100644 (file)
@@ -45,7 +45,7 @@ struct free_info {
 };
 static DEFINE_PER_CPU(struct free_info, free_info);
 
-static void _free_percpu_area(struct rcu_head *head)
+static void cf_check _free_percpu_area(struct rcu_head *head)
 {
     struct free_info *info = container_of(head, struct free_info, rcu);
     unsigned int cpu = info->cpu;
index dacd03254cb2cb81a1c6180a4bdba602336fd527..c5716cd72f63132834c5343c2a5c31b3faeaf19d 100644 (file)
@@ -1075,7 +1075,7 @@ void vcpu_end_shutdown_deferral(struct vcpu *v)
 }
 
 /* Complete domain destroy after RCU readers are not holding old references. */
-static void complete_domain_destroy(struct rcu_head *head)
+static void cf_check complete_domain_destroy(struct rcu_head *head)
 {
     struct domain *d = container_of(head, struct domain, rcu);
     struct vcpu *v;
@@ -1798,7 +1798,7 @@ struct pirq *pirq_get_info(struct domain *d, int pirq)
     return info;
 }
 
-static void _free_pirq_struct(struct rcu_head *head)
+static void cf_check _free_pirq_struct(struct rcu_head *head)
 {
     xfree(container_of(head, struct pirq, rcu_head));
 }
index 628a7e06988fbafe6645ecb0fd0a165e7c08069f..33b47748ae490f9a3580259df4daf1809f92b358 100644 (file)
@@ -58,7 +58,7 @@ static struct radix_tree_node *rcu_node_alloc(void *arg)
        return rcu_node ? &rcu_node->node : NULL;
 }
 
-static void _rcu_node_free(struct rcu_head *head)
+static void cf_check _rcu_node_free(struct rcu_head *head)
 {
        struct rcu_node *rcu_node =
                container_of(head, struct rcu_node, rcu_head);
index f9dd2584a8b7a7f0a012b4683a5926a4d7515c51..423d6b1d6d023e132a2dc801ef94d6cb7fee9580 100644 (file)
@@ -167,7 +167,7 @@ static int rsinterval = 1000;
 static atomic_t cpu_count = ATOMIC_INIT(0);
 static atomic_t pending_count = ATOMIC_INIT(0);
 
-static void rcu_barrier_callback(struct rcu_head *head)
+static void cf_check rcu_barrier_callback(struct rcu_head *head)
 {
     /*
      * We need a barrier making all previous writes visible to other cpus
index 6a1f17e94ebed8a61c52d803b337eed38b8693dd..aaa7ef2a6f4e43f1f13921dd9c3532616eabefb9 100644 (file)
@@ -2798,7 +2798,7 @@ static int cpu_schedule_up(unsigned int cpu)
     return 0;
 }
 
-static void sched_res_free(struct rcu_head *head)
+static void cf_check sched_res_free(struct rcu_head *head)
 {
     struct sched_resource *sr = container_of(head, struct sched_resource, rcu);
 
index 87ea38b7a0d02c6ce6ae3d9d61c442e3fb22fabd..e20c165042137fb84dca4fc2ba17743f106ce8a9 100644 (file)
@@ -276,7 +276,7 @@ int avc_get_hash_stats(struct xen_flask_hash_stats *arg)
     return 0;
 }
 
-static void avc_node_free(struct rcu_head *rhead)
+static void cf_check avc_node_free(struct rcu_head *rhead)
 {
     struct avc_node *node = container_of(rhead, struct avc_node, rhead);
     xfree(node);