From: Eduard Zingerman <eddyz87@gmail.com>
To: Matt Bobrowski <mattbobrowski@google.com>, bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
kpsingh@kernel.org, sdf@fomichev.me, jolsa@kernel.org,
Kumar Kartikeya Dwivedi <memxor@gmail.com>
Subject: Re: [PATCH bpf] bpf: add missing check_func_arg_reg_off() to prevent out-of-bounds memory accesses
Date: Wed, 19 Jun 2024 15:53:13 -0700 [thread overview]
Message-ID: <98105e974668a12d72cb3bdf490a70a4b1e227ad.camel@gmail.com> (raw)
In-Reply-To: <20240619082946.2389067-1-mattbobrowski@google.com>
On Wed, 2024-06-19 at 08:29 +0000, Matt Bobrowski wrote:
> Currently, it's possible to pass in a modified CONST_PTR_TO_DYNPTR to
> a global function as an argument. The adverse effects of this is that
> BPF helpers can continue to make use of this modified
> CONST_PTR_TO_DYNPTR from within the context of the global function,
> which can unintentionally result in out-of-bounds memory accesses and
> therefore compromise overall system stability i.e.
[...]
> Reported-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> Signed-off-by: Matt Bobrowski <mattbobrowski@google.com>
> ---
Hi Matt,
Thank you for fixing this bug. Overall looks good,
I second the requests from Kumar + one nit from me.
Also, note that kfunc_param_nullable/kfunc_dynptr_nullable_test3
needs an update.
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
[...]
> @@ -9464,7 +9471,13 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
> return -EINVAL;
> }
> } else if (arg->arg_type == (ARG_PTR_TO_DYNPTR | MEM_RDONLY)) {
> - ret = process_dynptr_func(env, regno, -1, arg->arg_type, 0);
> + ret = check_func_arg_reg_off(env, reg, regno,
> + ARG_PTR_TO_DYNPTR);
Nit: Please avoid splitting lines too often, this line should be:
ret = check_func_arg_reg_off(env, reg, regno, ARG_PTR_TO_DYNPTR);
the limit for line length is 100 characters.
There are a few more such places.
> + if (ret)
> + return ret;
> +
> + ret = process_dynptr_func(env, regno, -1, arg->arg_type,
> + 0);
> if (ret)
> return ret;
> } else if (base_type(arg->arg_type) == ARG_PTR_TO_BTF_ID) {
[...]
prev parent reply other threads:[~2024-06-19 22:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 8:29 [PATCH bpf] bpf: add missing check_func_arg_reg_off() to prevent out-of-bounds memory accesses Matt Bobrowski
2024-06-19 8:51 ` Kumar Kartikeya Dwivedi
2024-06-19 22:53 ` Eduard Zingerman [this message]
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=98105e974668a12d72cb3bdf490a70a4b1e227ad.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=mattbobrowski@google.com \
--cc=memxor@gmail.com \
--cc=sdf@fomichev.me \
/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