BPF Archive on lore.kernel.org
 help / color / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Yonghong Song <yhs@fb.com>
Cc: bpf@vger.kernel.org, Alexei Starovoitov <ast@fb.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	kernel-team@fb.com
Subject: Re: [PATCH bpf 2/2] selftests/bpf: add a fexit/bpf2bpf test with target bpf prog no callees
Date: Wed, 4 Dec 2019 21:37:02 -0800
Message-ID: <20191205053700.7e6oxm77zjypbrik@ast-mbp.dhcp.thefacebook.com> (raw)
In-Reply-To: <20191205010607.177904-1-yhs@fb.com>

On Wed, Dec 04, 2019 at 05:06:07PM -0800, Yonghong Song wrote:
>  
> -	obj = bpf_object__open_file("./fexit_bpf2bpf.o", &opts);
> +	obj = bpf_object__open_file(obj_file, &opts);
>  	if (CHECK(IS_ERR_OR_NULL(obj), "obj_open",
>  		  "failed to open fexit_bpf2bpf: %ld\n",
>  		  PTR_ERR(obj)))
> @@ -38,7 +34,14 @@ void test_fexit_bpf2bpf(void)
>  	if (CHECK(err, "obj_load", "err %d\n", err))
>  		goto close_prog;
>  
> -	for (i = 0; i < PROG_CNT; i++) {
> +	link = calloc(sizeof(struct bpf_link *), prog_cnt);
> +	prog = calloc(sizeof(struct bpf_program *), prog_cnt);
> +	result = malloc(prog_cnt * sizeof(u64));
> +	if (CHECK(!link || !prog || !result, "alloc_memory",
> +		  "failed to alloc memory"))
> +		goto close_prog;

bpf_object__open_file() can fail when jit is off and for() loop in close_prog
will segfault. I fixed it up by moving above 3 mallocs before
bpf_object__open_file() and applied both patches. Thanks!


      reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-05  1:06 [PATCH bpf 0/2] fix a verifier bug in check_attach_btf_id() Yonghong Song
2019-12-05  1:06 ` [PATCH bpf 1/2] bpf: fix a bug when getting subprog 0 jited image in check_attach_btf_id Yonghong Song
2019-12-05  5:33   ` Alexei Starovoitov
2019-12-05  1:06 ` [PATCH bpf 2/2] selftests/bpf: add a fexit/bpf2bpf test with target bpf prog no callees Yonghong Song
2019-12-05  5:37   ` Alexei Starovoitov [this message]

Reply instructions:

You may reply publically 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=20191205053700.7e6oxm77zjypbrik@ast-mbp.dhcp.thefacebook.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=yhs@fb.com \
    /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

BPF Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/bpf/0 bpf/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 bpf bpf/ https://lore.kernel.org/bpf \
		bpf@vger.kernel.org
	public-inbox-index bpf

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.bpf


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git