Message ID | 20230405225246.1327344-1-brho@google.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | bpf: ensure all memory is initialized in bpf_get_current_comm | expand |
On Wed, Apr 5, 2023 at 3:53 PM Barret Rhoden <brho@google.com> wrote: > > 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> The patch looks fine, but please rebase to bpf-next and resubmit with [PATCH bpf-next] subj, so it goes through BPF CI. See Documentation/bpf/bpf_devel_QA.rst
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 5b278a38ae58..adffb2f87e44 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -257,7 +257,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);
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> --- kernel/bpf/helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)