public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <ast@plumgrid.com>
To: Xi Wang <xi.wang@gmail.com>, linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, Zi Shen Lim <zlim.lnx@gmail.com>,
	Will Deacon <will.deacon@arm.com>
Subject: Re: [PATCH] arm64: bpf: fix out-of-bounds read in bpf2a64_offset()
Date: Thu, 25 Jun 2015 06:34:12 -0700	[thread overview]
Message-ID: <558C0354.4080809@plumgrid.com> (raw)
In-Reply-To: <1435236459-15141-1-git-send-email-xi.wang@gmail.com>

On 6/25/15 5:47 AM, Xi Wang wrote:
> Problems occur when bpf_to or bpf_from has value prog->len - 1 (e.g.,
> "Very long jump backwards" in test_bpf where the last instruction is a
> jump): since ctx->offset has length prog->len, ctx->offset[bpf_to + 1]
> or ctx->offset[bpf_from + 1] will cause an out-of-bounds read, leading
> to a bogus jump offset and kernel panic.
>
> This patch moves updating ctx->offset to after calling build_insn(),
> and changes indexing to use bpf_to and bpf_from without + 1.
>
> Cc: Zi Shen Lim<zlim.lnx@gmail.com>
> Cc: Alexei Starovoitov<ast@plumgrid.com>
> Cc: Will Deacon<will.deacon@arm.com>
> Fixes: e54bcde3d69d ("arm64: eBPF JIT compiler")
> Signed-off-by: Xi Wang<xi.wang@gmail.com>

Nice catch! Looks good to me.
Acked-by: Alexei Starovoitov <ast@plumgrid.com>


  reply	other threads:[~2015-06-25 13:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 12:47 [PATCH] arm64: bpf: fix out-of-bounds read in bpf2a64_offset() Xi Wang
2015-06-25 13:34 ` Alexei Starovoitov [this message]
2015-06-25 14:26 ` Catalin Marinas

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=558C0354.4080809@plumgrid.com \
    --to=ast@plumgrid.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=will.deacon@arm.com \
    --cc=xi.wang@gmail.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox