]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bpf: ensure all memory is initialized in bpf_get_current_comm
authorBarret Rhoden <brho@google.com>
Fri, 7 Apr 2023 00:18:08 +0000 (20:18 -0400)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 7 Apr 2023 01:48:24 +0000 (18:48 -0700)
BPF helpers that take an ARG_PTR_TO_UNINIT_MEM must ensure that all of
the memory is set, including beyond the end of the string.

Signed-off-by: Barret Rhoden <brho@google.com>
Link: https://lore.kernel.org/r/20230407001808.1622968-1-brho@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/helpers.c

index 6be16db9f1882c6146a0e206c8f379a182f83fc0..b6a5cda5bb5976015f3279cf9bcc61cdcd012363 100644 (file)
@@ -258,7 +258,7 @@ BPF_CALL_2(bpf_get_current_comm, char *, buf, u32, size)
                goto err_clear;
 
        /* Verifier guarantees that size > 0 */
-       strscpy(buf, task->comm, size);
+       strscpy_pad(buf, task->comm, size);
        return 0;
 err_clear:
        memset(buf, 0, size);