]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - kernel/kcov.c
kexec: Allocate decrypted control pages for kdump if SME is enabled
[mirror_ubuntu-bionic-kernel.git] / kernel / kcov.c
index 7594c033d98a39f3f51632a8f6f77b4440079ec4..23d610e4ddcd03a512a62bdada9994d442ce506c 100644 (file)
@@ -56,7 +56,7 @@ struct kcov {
        struct task_struct      *t;
 };
 
-static bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t)
+static notrace bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t)
 {
        enum kcov_mode mode;
 
@@ -78,7 +78,7 @@ static bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t)
        return mode == needed_mode;
 }
 
-static unsigned long canonicalize_ip(unsigned long ip)
+static notrace unsigned long canonicalize_ip(unsigned long ip)
 {
 #ifdef CONFIG_RANDOMIZE_BASE
        ip -= kaslr_offset();
@@ -112,7 +112,7 @@ void notrace __sanitizer_cov_trace_pc(void)
 EXPORT_SYMBOL(__sanitizer_cov_trace_pc);
 
 #ifdef CONFIG_KCOV_ENABLE_COMPARISONS
-static void write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip)
+static void notrace write_comp_data(u64 type, u64 arg1, u64 arg2, u64 ip)
 {
        struct task_struct *t;
        u64 *area;
@@ -241,7 +241,8 @@ static void kcov_put(struct kcov *kcov)
 
 void kcov_task_init(struct task_struct *t)
 {
-       t->kcov_mode = KCOV_MODE_DISABLED;
+       WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED);
+       barrier();
        t->kcov_size = 0;
        t->kcov_area = NULL;
        t->kcov = NULL;
@@ -358,7 +359,8 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd,
                 */
                if (kcov->mode != KCOV_MODE_INIT || !kcov->area)
                        return -EINVAL;
-               if (kcov->t != NULL)
+               t = current;
+               if (kcov->t != NULL || t->kcov != NULL)
                        return -EBUSY;
                if (arg == KCOV_TRACE_PC)
                        kcov->mode = KCOV_MODE_TRACE_PC;
@@ -370,7 +372,6 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd,
 #endif
                else
                        return -EINVAL;
-               t = current;
                /* Cache in task struct for performance. */
                t->kcov_size = kcov->size;
                t->kcov_area = kcov->area;