All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
	eddyz87@gmail.com, ihor.solodrai@linux.dev,
	yonghong.song@linux.dev, song@kernel.org, martin.lau@linux.dev,
	memxor@gmail.com, emil@etsalapatis.com, puranjay@kernel.org,
	yatsenko@meta.com, bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next 1/3] btf: Fix size/vlen validation for BTF_KIND_LOC_PARAM
Date: Tue, 13 Oct 2026 09:43:19 +0200	[thread overview]
Message-ID: <as3hF9vH609sPWOw@krava> (raw)
In-Reply-To: <20261012140640.2932195-2-alan.maguire@oracle.com>

On Mon, Oct 12, 2026 at 03:06:38PM +0100, Alan Maguire wrote:
> Validation logic allowed a BTF_KIND_LOC_PARAM with size <= 4
> and vlen == 2, an inconsistent representation.
> 
> Fixes: a3df11403e8c8 ("bpf: Verify BTF_KIND_LOC_PARAM vlen, flags")
> Suggested-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
> ---
>  kernel/bpf/btf.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index b09c04ccdc6d..64c78434fa05 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -4827,12 +4827,12 @@ static s32 btf_loc_param_check_meta(struct btf_verifier_env *env,
>  	case BTF_LOC_PARAM_CONST | BTF_LOC_PARAM_SIGNED:
>  	case BTF_LOC_PARAM_CONST | BTF_LOC_PARAM_ADDR:
>  	case BTF_LOC_PARAM_CONST | BTF_LOC_PARAM_ADDR | BTF_LOC_PARAM_SIGNED:
> -		if (vlen > 2)
> +		if (vlen < 1 || vlen > 2)
>  			goto invalid_vlen;

nit, is this condition needed? the check down ensures vlen is 1 or 2

jirka

> -		/* Ensure size/vlen are consistent */
> -		if (size > sizeof(__u32) && vlen != 2)
> +		if (!size || size > sizeof(__u64))
>  			goto invalid_vlen;
> -		if (size > sizeof(__u64))
> +		/* Ensure size/vlen are consistent */
> +		if (vlen != (size > sizeof(__u32) ? 2 : 1))
>  			goto invalid_vlen;
>  		break;
>  	case BTF_LOC_PARAM_REG:
> -- 
> 2.43.5
> 

  parent reply	other threads:[~2026-10-13  7:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 14:06 [PATCH bpf-next 0/3] Inline BTF followups Alan Maguire
2026-10-12 14:06 ` [PATCH bpf-next 1/3] btf: Fix size/vlen validation for BTF_KIND_LOC_PARAM Alan Maguire
2026-10-12 14:49   ` bot+bpf-ci
2026-10-13  7:43   ` Jiri Olsa [this message]
2026-10-12 14:06 ` [PATCH bpf-next 2/3] selftests/bpf: Fix btf_inline to use .text section as base Alan Maguire
2026-10-12 14:06 ` [PATCH bpf-next 3/3] selftests/bpf: Enable CONFIG_DEBUG_INFO_BTF_INLINE for CI Alan Maguire
2026-10-13  7:46 ` [PATCH bpf-next 0/3] Inline BTF followups Jiri Olsa
2026-10-13 13:50 ` 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=as3hF9vH609sPWOw@krava \
    --to=olsajiri@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=ihor.solodrai@linux.dev \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=puranjay@kernel.org \
    --cc=song@kernel.org \
    --cc=yatsenko@meta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.