bpf: Clear per_cpu pointers during bpf_prog_realloc
authorAlexei Starovoitov <ast@kernel.org>
Fri, 12 Feb 2021 03:35:00 +0000 (19:35 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Feb 2021 03:35:00 +0000 (19:35 -0800)
bpf_prog_realloc copies contents of struct bpf_prog.
The pointers have to be cleared before freeing old struct.

Reported-by: Ilya Leoshkevich <iii@linux.ibm.com>
Fixes: 700d4796ef59 ("bpf: Optimize program stats")
Fixes: ca06f55b9002 ("bpf: Add per-program recursion prevention mechanism")
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/core.c

index 334070c..0ae015a 100644 (file)
@@ -245,6 +245,8 @@ struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size,
                 * reallocated structure.
                 */
                fp_old->aux = NULL;
+               fp_old->stats = NULL;
+               fp_old->active = NULL;
                __bpf_prog_free(fp_old);
        }