---
 kernel/fork.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/kernel/fork.c b/kernel/fork.c
index 1ee8eb11f38b..379dcf5626e9 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -122,6 +122,12 @@
 
 #include <kunit/visibility.h>
 
+#ifdef CONFIG_SAFEFETCH
+#include <linux/safefetch.h>
+#include <linux/safefetch_static_keys.h>
+#include <linux/mem_range.h>
+#endif
+
 /*
  * Minimum number of threads to boot the kernel
  */
@@ -955,6 +961,17 @@ static struct task_struct *dup_task_struct(struct 
task_struct *orig, int node)
        tsk->last_mm_cid = -1;
        tsk->mm_cid_active = 0;
        tsk->migrate_from_cpu = -1;
+#endif
+
+#ifdef CONFIG_SAFEFETCH
+       IF_SAFEFETCH_STATIC_BRANCH_UNLIKELY_WRAPPER(safefetch_hooks_key) {
+               df_task_dup(tsk);
+       }
+#ifdef SAFEFETCH_DEBUG
+       WARN_ON(SAFEFETCH_TASK_MEM_RANGE_INIT_FLAG(tsk));
+       WARN_ON(tsk->df_prot_struct_head.df_metadata_allocator.extended);
+       WARN_ON(tsk->df_prot_struct_head.df_storage_allocator.extended);
+#endif
 #endif
        return tsk;
 
-- 
2.25.1


Reply via email to