public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Anton Protopopov" <a.s.protopopov@gmail.com>,
	<bpf@vger.kernel.org>, "Alexei Starovoitov" <ast@kernel.org>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Eduard Zingerman" <eddyz87@gmail.com>,
	"Yonghong Song" <yonghong.song@linux.dev>
Subject: Re: [PATCH bpf-next 2/3] bpf: insn array: return EACCES for incorrect map access
Date: Mon, 12 Jan 2026 12:12:48 -0500	[thread overview]
Message-ID: <DFMS1OCR2VM0.30PBICO8ECI9O@etsalapatis.com> (raw)
In-Reply-To: <20260111153047.8388-3-a.s.protopopov@gmail.com>

On Sun Jan 11, 2026 at 10:30 AM EST, Anton Protopopov wrote:
> The insn_array_map_direct_value_addr() function currently returns
> -EINVAL when the offset within the map is invalid. Change this to
> return -EACCES, so that it is consistent with similar boundary access
> checks in the verifier.
>
> Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
> ---
>  kernel/bpf/bpf_insn_array.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/bpf/bpf_insn_array.c b/kernel/bpf/bpf_insn_array.c
> index 37b43102953e..c0286f25ca3c 100644
> --- a/kernel/bpf/bpf_insn_array.c
> +++ b/kernel/bpf/bpf_insn_array.c
> @@ -123,7 +123,7 @@ static int insn_array_map_direct_value_addr(const struct bpf_map *map, u64 *imm,
>  
>  	if ((off % sizeof(long)) != 0 ||
>  	    (off / sizeof(long)) >= map->max_entries)
> -		return -EINVAL;
> +		return -EACCES;

-EACCES is reasonable but the other .direct_valud_addr() methods use
-EINVAL (array) and -ERANGE (arena). If we're going for consistency
can we change them all to the same error code?

>  
>  	/* from BPF's point of view, this map is a jump table */
>  	*imm = (unsigned long)insn_array->ips;


  reply	other threads:[~2026-01-12 17:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-11 15:30 [PATCH bpf-next 0/3] properly load insn array values with offsets Anton Protopopov
2026-01-11 15:30 ` [PATCH bpf-next 1/3] bpf: insn array: return proper address for non-zero offsets Anton Protopopov
2026-01-12 17:05   ` Emil Tsalapatis
2026-01-14  3:42   ` Alexei Starovoitov
2026-01-14 10:20     ` Anton Protopopov
2026-01-11 15:30 ` [PATCH bpf-next 2/3] bpf: insn array: return EACCES for incorrect map access Anton Protopopov
2026-01-12 17:12   ` Emil Tsalapatis [this message]
2026-01-12 18:45     ` Anton Protopopov
2026-01-12 19:18       ` Emil Tsalapatis
2026-01-11 15:30 ` [PATCH bpf-next 3/3] selftests/bpf: add tests for loading map values with offsets Anton Protopopov
2026-01-14  3:40 ` [PATCH bpf-next 0/3] properly load insn array " 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=DFMS1OCR2VM0.30PBICO8ECI9O@etsalapatis.com \
    --to=emil@etsalapatis.com \
    --cc=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=yonghong.song@linux.dev \
    /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