Netdev List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Martin KaFai Lau <kafai@fb.com>, <netdev@vger.kernel.org>
Cc: Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: Re: [PATCH bpf] bpf: btf: Fix end boundary calculation for type section
Date: Wed, 12 Sep 2018 10:38:46 -0700	[thread overview]
Message-ID: <940cccef-1b05-5853-70b0-0421e196c979@fb.com> (raw)
In-Reply-To: <20180912172911.3609494-1-kafai@fb.com>



On 9/12/18 10:29 AM, Martin KaFai Lau wrote:
> The end boundary math for type section is incorrect in
> btf_check_all_metas().  It just happens that hdr->type_off
> is always 0 for now because there are only two sections
> (type and string) and string section must be at the end (ensured
> in btf_parse_str_sec).
> 
> However, type_off may not be 0 if a new section would be added later.
> This patch fixes it.
> 
> Fixes: f80442a4cd18 ("bpf: btf: Change how section is supported in btf_header")
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>

Acked-by: Yonghong Song <yhs@fb.com>

> ---
>   kernel/bpf/btf.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 2590700237c1..138f0302692e 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -1844,7 +1844,7 @@ static int btf_check_all_metas(struct btf_verifier_env *env)
>   
>   	hdr = &btf->hdr;
>   	cur = btf->nohdr_data + hdr->type_off;
> -	end = btf->nohdr_data + hdr->type_len;
> +	end = cur + hdr->type_len;
>   
>   	env->log_type_id = 1;
>   	while (cur < end) {
> 

  reply	other threads:[~2018-09-12 22:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-12 17:29 [PATCH bpf] bpf: btf: Fix end boundary calculation for type section Martin KaFai Lau
2018-09-12 17:38 ` Yonghong Song [this message]
2018-09-12 20:02 ` Daniel Borkmann

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=940cccef-1b05-5853-70b0-0421e196c979@fb.com \
    --to=yhs@fb.com \
    --cc=ast@fb.com \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=kernel-team@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