public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Quentin Monnet <qmo@kernel.org>
To: Christoph Werle <christoph.werle@longjmp.de>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bpftool: fix control flow graph segfault during edge creation
Date: Thu, 9 Jan 2025 18:19:46 +0000	[thread overview]
Message-ID: <55b9484a-c7db-402b-94f8-fe0544a9739f@kernel.org> (raw)
In-Reply-To: <20250108220937.1470029-1-christoph.werle@longjmp.de>

On 08/01/2025 22:09, Christoph Werle wrote:
> If the last instruction of a control flow graph building block is a
> BPF_CALL, an incorrect edge with e->dst set to NULL is created and
> results in a segfault during graph output.
> 
> Ensure that BPF_CALL as last instruction of a building block is handled
> correctly and only generates a single edge unlike actual BPF_JUMP*
> instructions.
> 
> Signed-off-by: Christoph Werle <christoph.werle@longjmp.de>


Fixes: 0824611f9b38 ("tools: bpftool: partition basic-block for each function in the CFG")


> ---
>  tools/bpf/bpftool/cfg.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/bpf/bpftool/cfg.c b/tools/bpf/bpftool/cfg.c
> index eec437cca2ea..e3785f9a697d 100644
> --- a/tools/bpf/bpftool/cfg.c
> +++ b/tools/bpf/bpftool/cfg.c
> @@ -302,6 +302,7 @@ static bool func_add_bb_edges(struct func_node *func)
>  
>  		insn = bb->tail;
>  		if (!is_jmp_insn(insn->code) ||
> +		    BPF_OP(insn->code) == BPF_CALL ||
>  		    BPF_OP(insn->code) == BPF_EXIT) {
>  			e->dst = bb_next(bb);
>  			e->flags |= EDGE_FLAG_FALLTHROUGH;


Thanks for this! It looks OK, would you have a minimal reproducer by any
chance?

Quentin

  reply	other threads:[~2025-01-09 18:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 22:09 [PATCH] bpftool: fix control flow graph segfault during edge creation Christoph Werle
2025-01-09 18:19 ` Quentin Monnet [this message]
2025-01-10 12:57   ` christoph.werle
2025-01-10 15:02     ` Quentin Monnet
2025-01-10 22:20 ` 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=55b9484a-c7db-402b-94f8-fe0544a9739f@kernel.org \
    --to=qmo@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=christoph.werle@longjmp.de \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=sdf@fomichev.me \
    --cc=song@kernel.org \
    --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