> diff --git a/tools/testing/selftests/bpf/prog_tests/copy_from_user_bprm.c b/tools/testing/selftests/bpf/prog_tests/copy_from_user_bprm.c
> new file mode 100644
> index 000000000000..3d5080a3975e
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/copy_from_user_bprm.c
[ ... ]
> + if (!child) {
> + char *const argv[] = { "first", "second-argument", NULL };
> +
> + skel->bss->monitored_pid = getpid();
> + execv("/bin/true", argv);
> + _exit(errno);
> + }
[ ... ]
> + ASSERT_EQ(skel->bss->str_arg0_ret, 6, "str_arg0_ret");
> + ASSERT_EQ(skel->bss->str_arg1_ret, 16, "str_arg1_ret");
This isn't a bug, but could these be written as sizeof("first") and
sizeof("second-argument") so the expected lengths track the argv[] strings
defined above? The literals 6 and 16 mean anyone changing an argument
string has to update three places.
> diff --git a/tools/testing/selftests/bpf/progs/copy_from_user_bprm.c b/tools/testing/selftests/bpf/progs/copy_from_user_bprm.c
> new file mode 100644
> index 000000000000..679363811edc
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/copy_from_user_bprm.c
[ ... ]
> + invalid_flags_ret = bpf_copy_from_user_bprm(args, sizeof(args),
> + (void *)bprm->p, bprm, 1);
> +
> + copy_ret = bpf_copy_from_user_bprm(args, sizeof(args),
> + (void *)bprm->p, bprm, 0);
> + if (copy_ret)
> + return 0;
> +
> + args_match = !__builtin_memcmp(args, expected_args, sizeof(expected_args));
> +
> + str_arg0_ret = bpf_copy_from_user_bprm_str(arg0, sizeof(arg0),
> + (void *)bprm->p, bprm,
> + BPF_F_PAD_ZEROS);
This isn't a bug, but would an obviously out-of-range value like ~0ULL
read better than the literal 1 for the invalid-flags probe, given that
BPF_F_PAD_ZEROS is also 1? A reader has to look up the flag's value to
see the two uses are unrelated.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/31592551940
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.