From: Yauheni Kaliuta <yauheni.kaliuta@redhat.com>
To: Zi Shen Lim <zlim.lnx@gmail.com>
Cc: bpf@vger.kernel.org
Subject: amr64 jit ctx.offset[-1] access
Date: Mon, 07 Sep 2020 17:39:10 +0300 [thread overview]
Message-ID: <xunypn6xd52p.fsf@redhat.com> (raw)
Hi!
I have a qustion about arm64 bpf jit implementation.
The problem I observe is "taken loop with back jump to 1st insn"
verifier test, the subprogram is:
BPF_ALU64_REG(BPF_ADD, BPF_REG_2, BPF_REG_1),
BPF_ALU64_IMM(BPF_SUB, BPF_REG_1, 1),
BPF_JMP_IMM(BPF_JNE, BPF_REG_1, 0, -3),
BPF_MOV64_REG(BPF_REG_0, BPF_REG_2),
BPF_EXIT_INSN(),
Jitting the program causes invokation of bpf2a64_offset(-1, 2, ctx)
from
jmp_offset = bpf2a64_offset(i + off, i, ctx);
which does ctx->offset[-1] then (and works by accident when it
returns 0).
As far as I see, the offset[] keeps actually offsets of the next
instruction:
ret = build_insn(insn, ctx, extra_pass);
if (ret > 0) {
i++;
if (ctx->image == NULL)
ctx->offset[i] = ctx->idx;
continue;
}
if (ctx->image == NULL)
ctx->offset[i] = ctx->idx;
ctx->idx is updated by build_insn() already.
How is that supposed to work?
--
WBR,
Yauheni Kaliuta
reply other threads:[~2020-09-07 16:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=xunypn6xd52p.fsf@redhat.com \
--to=yauheni.kaliuta@redhat.com \
--cc=bpf@vger.kernel.org \
--cc=zlim.lnx@gmail.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
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.