diff mbox series

bpf: ensure all memory is initialized in bpf_get_current_comm

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

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 54 this patch: 54
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 54 this patch: 54
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Barret Rhoden April 5, 2023, 10:52 p.m. UTC
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(-)

Comments

Alexei Starovoitov April 6, 2023, 11 p.m. UTC | #1
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 mbox series

Patch

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);