From: Stanislav Fomichev <sdf@google.com>
To: "Björn Töpel" <bjorn@kernel.org>
Cc: "Andrii Nakryiko" <andrii@kernel.org>,
"Mykola Lysenko" <mykolal@fb.com>,
bpf@vger.kernel.org, netdev@vger.kernel.org,
"Björn Töpel" <bjorn@rivosinc.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next] selftests/bpf: Bump and validate MAX_SYMS
Date: Thu, 6 Jul 2023 10:46:27 -0700 [thread overview]
Message-ID: <ZKb986L59CTFITjP@google.com> (raw)
In-Reply-To: <20230706142228.1128452-1-bjorn@kernel.org>
On 07/06, Björn Töpel wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
>
> BPF tests that load /proc/kallsyms, e.g. bpf_cookie, will perform a
> buffer overrun if the number of syms on the system is larger than
> MAX_SYMS.
>
> Bump the MAX_SYMS to 400000, and add a runtime check that bails out if
> the maximum is reached.
>
> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Acked-by: Stanislav Fomichev <sdf@google.com>
OTOH, should be easy to convert this to malloc/realloc? That should fix
it once and for all and avoid future need to bump the limit?
> ---
> tools/testing/selftests/bpf/trace_helpers.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/selftests/bpf/trace_helpers.c
> index 9b070cdf44ac..f83d9f65c65b 100644
> --- a/tools/testing/selftests/bpf/trace_helpers.c
> +++ b/tools/testing/selftests/bpf/trace_helpers.c
> @@ -18,7 +18,7 @@
> #define TRACEFS_PIPE "/sys/kernel/tracing/trace_pipe"
> #define DEBUGFS_PIPE "/sys/kernel/debug/tracing/trace_pipe"
>
> -#define MAX_SYMS 300000
> +#define MAX_SYMS 400000
> static struct ksym syms[MAX_SYMS];
> static int sym_cnt;
>
> @@ -46,6 +46,9 @@ int load_kallsyms_refresh(void)
> break;
> if (!addr)
> continue;
> + if (i >= MAX_SYMS)
> + return -EFBIG;
> +
> syms[i].addr = (long) addr;
> syms[i].name = strdup(func);
> i++;
>
> base-commit: fd283ab196a867f8f65f36913e0fadd031fcb823
> --
> 2.39.2
>
next prev parent reply other threads:[~2023-07-06 17:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-06 14:22 [PATCH bpf-next] selftests/bpf: Bump and validate MAX_SYMS Björn Töpel
2023-07-06 17:46 ` Stanislav Fomichev [this message]
2023-07-06 21:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZKb986L59CTFITjP@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bjorn@rivosinc.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mykolal@fb.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).