From: mgherzan@gmail.com (Mircea Gherzan)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] ARM: net: bpf_jit_32: fix sp-relative load/stores offsets.
Date: Sat, 08 Dec 2012 00:15:56 +0100 [thread overview]
Message-ID: <50C278AC.5050205@gmail.com> (raw)
In-Reply-To: <1354804718-1662-2-git-send-email-nschichan@freebox.fr>
Am 06.12.2012 15:38, schrieb Nicolas Schichan:
> The offset must be multiplied by 4 to be sure to access the correct
> 32bit word in the stack scratch space.
>
> For instance, a store at scratch memory cell #1 was generating the
> following:
>
> st r4, [sp, #1]
>
> While the correct code for this is:
>
> st r4, [sp, #4]
>
> To reproduce the bug (assuming your system has a NIC with the mac
> address 52:54:00:12:34:56):
>
> echo 0 > /proc/sys/net/core/bpf_jit_enable
> tcpdump -ni eth0 "ether[1] + ether[2] - ether[3] * ether[4] - ether[5] \
> == -0x3AA" # this will capture packets as expected
>
> echo 1 > /proc/sys/net/core/bpf_jit_enable
> tcpdump -ni eth0 "ether[1] + ether[2] - ether[3] * ether[4] - ether[5] \
> == -0x3AA" # this will not.
>
> This bug was present since the original inclusion of bpf_jit for ARM
> (ddecdfce: ARM: 7259/3: net: JIT compiler for packet filters).
>
> Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
> ---
> arch/arm/net/bpf_jit_32.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
> index a64d349..b6f305e 100644
> --- a/arch/arm/net/bpf_jit_32.c
> +++ b/arch/arm/net/bpf_jit_32.c
> @@ -42,7 +42,7 @@
> #define r_skb_hl ARM_R8
>
> #define SCRATCH_SP_OFFSET 0
> -#define SCRATCH_OFF(k) (SCRATCH_SP_OFFSET + (k))
> +#define SCRATCH_OFF(k) (SCRATCH_SP_OFFSET + 4 * (k))
>
> #define SEEN_MEM ((1 << BPF_MEMWORDS) - 1)
> #define SEEN_MEM_WORD(k) (1 << (k))
Acked-by: Mircea Gherzan <mgherzan@gmail.com>
WARNING: multiple messages have this Message-ID (diff)
From: Mircea Gherzan <mgherzan@gmail.com>
To: Nicolas Schichan <nschichan@freebox.fr>
Cc: rmk+kernel@arm.linux.org.uk,
Russell King <linux@arm.linux.org.uk>,
Eric Dumazet <eric.dumazet@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] ARM: net: bpf_jit_32: fix sp-relative load/stores offsets.
Date: Sat, 08 Dec 2012 00:15:56 +0100 [thread overview]
Message-ID: <50C278AC.5050205@gmail.com> (raw)
In-Reply-To: <1354804718-1662-2-git-send-email-nschichan@freebox.fr>
Am 06.12.2012 15:38, schrieb Nicolas Schichan:
> The offset must be multiplied by 4 to be sure to access the correct
> 32bit word in the stack scratch space.
>
> For instance, a store at scratch memory cell #1 was generating the
> following:
>
> st r4, [sp, #1]
>
> While the correct code for this is:
>
> st r4, [sp, #4]
>
> To reproduce the bug (assuming your system has a NIC with the mac
> address 52:54:00:12:34:56):
>
> echo 0 > /proc/sys/net/core/bpf_jit_enable
> tcpdump -ni eth0 "ether[1] + ether[2] - ether[3] * ether[4] - ether[5] \
> == -0x3AA" # this will capture packets as expected
>
> echo 1 > /proc/sys/net/core/bpf_jit_enable
> tcpdump -ni eth0 "ether[1] + ether[2] - ether[3] * ether[4] - ether[5] \
> == -0x3AA" # this will not.
>
> This bug was present since the original inclusion of bpf_jit for ARM
> (ddecdfce: ARM: 7259/3: net: JIT compiler for packet filters).
>
> Signed-off-by: Nicolas Schichan <nschichan@freebox.fr>
> ---
> arch/arm/net/bpf_jit_32.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
> index a64d349..b6f305e 100644
> --- a/arch/arm/net/bpf_jit_32.c
> +++ b/arch/arm/net/bpf_jit_32.c
> @@ -42,7 +42,7 @@
> #define r_skb_hl ARM_R8
>
> #define SCRATCH_SP_OFFSET 0
> -#define SCRATCH_OFF(k) (SCRATCH_SP_OFFSET + (k))
> +#define SCRATCH_OFF(k) (SCRATCH_SP_OFFSET + 4 * (k))
>
> #define SEEN_MEM ((1 << BPF_MEMWORDS) - 1)
> #define SEEN_MEM_WORD(k) (1 << (k))
Acked-by: Mircea Gherzan <mgherzan@gmail.com>
next prev parent reply other threads:[~2012-12-07 23:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-06 14:38 [PATCH 1/2] ARM: net: bpf_jit_32: fix kzalloc gfp/size mismatch Nicolas Schichan
2012-12-06 14:38 ` Nicolas Schichan
2012-12-06 14:38 ` [PATCH 2/2] ARM: net: bpf_jit_32: fix sp-relative load/stores offsets Nicolas Schichan
2012-12-06 14:38 ` Nicolas Schichan
2012-12-07 23:15 ` Mircea Gherzan [this message]
2012-12-07 23:15 ` Mircea Gherzan
2012-12-07 16:51 ` [PATCH 1/2] ARM: net: bpf_jit_32: fix kzalloc gfp/size mismatch Florian Fainelli
2012-12-07 16:51 ` Florian Fainelli
2012-12-07 23:04 ` Mircea Gherzan
2012-12-07 23:04 ` Mircea Gherzan
2012-12-10 13:18 ` Nicolas Schichan
2012-12-10 13:18 ` Nicolas Schichan
2012-12-10 13:20 ` Russell King - ARM Linux
2012-12-10 13:20 ` Russell King - ARM Linux
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=50C278AC.5050205@gmail.com \
--to=mgherzan@gmail.com \
--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.