From: yang.shi@linaro.org (Shi, Yang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] arm64: bpf: fix buffer pointer
Date: Wed, 18 Nov 2015 14:59:17 -0800 [thread overview]
Message-ID: <564D02C5.1020200@linaro.org> (raw)
In-Reply-To: <CABg9mcud=quxDbAGwXo0CyHjDa4aOL_yuk9hwRp1asu-z+fOAQ@mail.gmail.com>
On 11/18/2015 1:41 PM, Z Lim wrote:
> On Wed, Nov 18, 2015 at 1:07 PM, Shi, Yang <yang.shi@linaro.org> wrote:
>> On 11/18/2015 12:56 AM, Zi Shen Lim wrote:
>>> emit_a64_mov_i64(r3, size, ctx);
>>> - emit(A64_ADD_I(1, r4, fp, MAX_BPF_STACK), ctx);
>>> + emit(A64_SUB_I(1, r4, fp, STACK_SIZE), ctx);
>>
>>
>> Should not it sub MAX_BPF_STACK?
>
> No, if it's at (BPF_FP - MAX_BPF_STACK), we'll be writing into the BPF
> stack area, which should only be used by the BPF program.
>
>> If you sub STACK_SIZE here, the buffer pointer will point to bottom of the
>> reserved area.
>
> Yes, that's the idea. The buffer is allocated in here. Right now we're
> using this "reserved" space for this buffer only.
OK, I see. The buffer grows from low to high.
Thanks for the elaboration.
Acked-by: Yang Shi <yang.shi@linaro.org>
Yang
>
>>
>> You stack layout change also shows this:
>>
>> + * +-----+ <= (BPF_FP - MAX_BPF_STACK)
>> + * |RSVD | JIT scratchpad
>> + * current A64_SP => +-----+ <= (BPF_FP - STACK_SIZE)
>
> Yes, this diagram reflects the code and intention.
>
>
> Thanks for reviewing, we definitely need more of these :)
>
WARNING: multiple messages have this Message-ID (diff)
From: "Shi, Yang" <yang.shi@linaro.org>
To: Z Lim <zlim.lnx@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
Alexei Starovoitov <ast@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Xi Wang <xi.wang@gmail.com>, LKML <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
Network Development <netdev@vger.kernel.org>
Subject: Re: [PATCH] arm64: bpf: fix buffer pointer
Date: Wed, 18 Nov 2015 14:59:17 -0800 [thread overview]
Message-ID: <564D02C5.1020200@linaro.org> (raw)
In-Reply-To: <CABg9mcud=quxDbAGwXo0CyHjDa4aOL_yuk9hwRp1asu-z+fOAQ@mail.gmail.com>
On 11/18/2015 1:41 PM, Z Lim wrote:
> On Wed, Nov 18, 2015 at 1:07 PM, Shi, Yang <yang.shi@linaro.org> wrote:
>> On 11/18/2015 12:56 AM, Zi Shen Lim wrote:
>>> emit_a64_mov_i64(r3, size, ctx);
>>> - emit(A64_ADD_I(1, r4, fp, MAX_BPF_STACK), ctx);
>>> + emit(A64_SUB_I(1, r4, fp, STACK_SIZE), ctx);
>>
>>
>> Should not it sub MAX_BPF_STACK?
>
> No, if it's at (BPF_FP - MAX_BPF_STACK), we'll be writing into the BPF
> stack area, which should only be used by the BPF program.
>
>> If you sub STACK_SIZE here, the buffer pointer will point to bottom of the
>> reserved area.
>
> Yes, that's the idea. The buffer is allocated in here. Right now we're
> using this "reserved" space for this buffer only.
OK, I see. The buffer grows from low to high.
Thanks for the elaboration.
Acked-by: Yang Shi <yang.shi@linaro.org>
Yang
>
>>
>> You stack layout change also shows this:
>>
>> + * +-----+ <= (BPF_FP - MAX_BPF_STACK)
>> + * |RSVD | JIT scratchpad
>> + * current A64_SP => +-----+ <= (BPF_FP - STACK_SIZE)
>
> Yes, this diagram reflects the code and intention.
>
>
> Thanks for reviewing, we definitely need more of these :)
>
next prev parent reply other threads:[~2015-11-18 22:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-18 8:56 [PATCH] arm64: bpf: fix buffer pointer Zi Shen Lim
2015-11-18 8:56 ` Zi Shen Lim
2015-11-18 20:34 ` David Miller
2015-11-18 20:34 ` David Miller
2015-11-18 21:07 ` Shi, Yang
2015-11-18 21:07 ` Shi, Yang
2015-11-18 21:41 ` Z Lim
2015-11-18 21:41 ` Z Lim
2015-11-18 22:59 ` Shi, Yang [this message]
2015-11-18 22:59 ` Shi, Yang
2015-11-19 3:38 ` David Miller
2015-11-19 3:38 ` David Miller
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=564D02C5.1020200@linaro.org \
--to=yang.shi@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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 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.