bpf: move explored_state() closer to the beginning of verifier.c
[platform/kernel/linux-rpi.git] / kernel / kprobes.c
index ca385b6..b486504 100644 (file)
@@ -2232,8 +2232,7 @@ int register_kretprobe(struct kretprobe *rp)
                return -ENOMEM;
 
        for (i = 0; i < rp->maxactive; i++) {
-               inst = kzalloc(sizeof(struct kretprobe_instance) +
-                              rp->data_size, GFP_KERNEL);
+               inst = kzalloc(struct_size(inst, data, rp->data_size), GFP_KERNEL);
                if (inst == NULL) {
                        rethook_free(rp->rh);
                        rp->rh = NULL;
@@ -2254,10 +2253,9 @@ int register_kretprobe(struct kretprobe *rp)
        if (!rp->rph)
                return -ENOMEM;
 
-       rp->rph->rp = rp;
+       rcu_assign_pointer(rp->rph->rp, rp);
        for (i = 0; i < rp->maxactive; i++) {
-               inst = kzalloc(sizeof(struct kretprobe_instance) +
-                              rp->data_size, GFP_KERNEL);
+               inst = kzalloc(struct_size(inst, data, rp->data_size), GFP_KERNEL);
                if (inst == NULL) {
                        refcount_set(&rp->rph->ref, i);
                        free_rp_inst(rp);
@@ -2315,7 +2313,7 @@ void unregister_kretprobes(struct kretprobe **rps, int num)
 #ifdef CONFIG_KRETPROBE_ON_RETHOOK
                rethook_free(rps[i]->rh);
 #else
-               rps[i]->rph->rp = NULL;
+               rcu_assign_pointer(rps[i]->rph->rp, NULL);
 #endif
        }
        mutex_unlock(&kprobe_mutex);