From: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
To: ast@kernel.org, christophe.leroy@csgroup.eu,
Daniel Borkmann <daniel@iogearbox.net>,
Hari Bathini <hbathini@linux.ibm.com>,
jniethe5@gmail.com, Michael Ellerman <mpe@ellerman.id.au>
Cc: andrii@kernel.org, bpf@vger.kernel.org, john.fastabend@gmail.com,
kafai@fb.com, kpsingh@kernel.org, linuxppc-dev@lists.ozlabs.org,
netdev@vger.kernel.org, paulus@samba.org, songliubraving@fb.com,
stable@vger.kernel.org, yhs@fb.com
Subject: Re: [PATCH] powerpc/bpf: fix write protecting JIT code
Date: Tue, 02 Nov 2021 17:29:02 +0530 [thread overview]
Message-ID: <1635854227.x13v13l6az.naveen@linux.ibm.com> (raw)
In-Reply-To: <87zgqs8upq.fsf@mpe.ellerman.id.au>
Michael Ellerman wrote:
> Daniel Borkmann <daniel@iogearbox.net> writes:
>> On 10/25/21 8:15 AM, Naveen N. Rao wrote:
>>> Hari Bathini wrote:
>>>> Running program with bpf-to-bpf function calls results in data access
>>>> exception (0x300) with the below call trace:
>>>>
>>>> [c000000000113f28] bpf_int_jit_compile+0x238/0x750 (unreliable)
>>>> [c00000000037d2f8] bpf_check+0x2008/0x2710
>>>> [c000000000360050] bpf_prog_load+0xb00/0x13a0
>>>> [c000000000361d94] __sys_bpf+0x6f4/0x27c0
>>>> [c000000000363f0c] sys_bpf+0x2c/0x40
>>>> [c000000000032434] system_call_exception+0x164/0x330
>>>> [c00000000000c1e8] system_call_vectored_common+0xe8/0x278
>>>>
>>>> as bpf_int_jit_compile() tries writing to write protected JIT code
>>>> location during the extra pass.
>>>>
>>>> Fix it by holding off write protection of JIT code until the extra
>>>> pass, where branch target addresses fixup happens.
>>>>
>>>> Cc: stable@vger.kernel.org
>>>> Fixes: 62e3d4210ac9 ("powerpc/bpf: Write protect JIT code")
>>>> Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
>>>> ---
>>>> arch/powerpc/net/bpf_jit_comp.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> Thanks for the fix!
>>>
>>> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>>
>> LGTM, I presume this fix will be routed via Michael.
>
> Thanks for reviewing, I've picked it up.
>
>> BPF selftests have plenty of BPF-to-BPF calls in there, too bad this was
>> caught so late. :/
>
> Yeah :/
>
> STRICT_KERNEL_RWX is not on by default in all our defconfigs, so that's
> probably why no one caught it.
Yeah, sorry - we should have caught this sooner.
>
> I used to run the BPF selftests but they stopped building for me a while
> back, I'll see if I can get them going again.
Ravi had started looking into getting the selftests working well before
he left. I will take a look at this.
Thanks,
Naveen
WARNING: multiple messages have this Message-ID (diff)
From: "Naveen N. Rao" <naveen.n.rao@linux.ibm.com>
To: ast@kernel.org, christophe.leroy@csgroup.eu,
Daniel Borkmann <daniel@iogearbox.net>,
Hari Bathini <hbathini@linux.ibm.com>,
jniethe5@gmail.com, Michael Ellerman <mpe@ellerman.id.au>
Cc: songliubraving@fb.com, netdev@vger.kernel.org,
john.fastabend@gmail.com, kpsingh@kernel.org,
stable@vger.kernel.org, andrii@kernel.org, paulus@samba.org,
yhs@fb.com, bpf@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
kafai@fb.com
Subject: Re: [PATCH] powerpc/bpf: fix write protecting JIT code
Date: Tue, 02 Nov 2021 17:29:02 +0530 [thread overview]
Message-ID: <1635854227.x13v13l6az.naveen@linux.ibm.com> (raw)
In-Reply-To: <87zgqs8upq.fsf@mpe.ellerman.id.au>
Michael Ellerman wrote:
> Daniel Borkmann <daniel@iogearbox.net> writes:
>> On 10/25/21 8:15 AM, Naveen N. Rao wrote:
>>> Hari Bathini wrote:
>>>> Running program with bpf-to-bpf function calls results in data access
>>>> exception (0x300) with the below call trace:
>>>>
>>>> [c000000000113f28] bpf_int_jit_compile+0x238/0x750 (unreliable)
>>>> [c00000000037d2f8] bpf_check+0x2008/0x2710
>>>> [c000000000360050] bpf_prog_load+0xb00/0x13a0
>>>> [c000000000361d94] __sys_bpf+0x6f4/0x27c0
>>>> [c000000000363f0c] sys_bpf+0x2c/0x40
>>>> [c000000000032434] system_call_exception+0x164/0x330
>>>> [c00000000000c1e8] system_call_vectored_common+0xe8/0x278
>>>>
>>>> as bpf_int_jit_compile() tries writing to write protected JIT code
>>>> location during the extra pass.
>>>>
>>>> Fix it by holding off write protection of JIT code until the extra
>>>> pass, where branch target addresses fixup happens.
>>>>
>>>> Cc: stable@vger.kernel.org
>>>> Fixes: 62e3d4210ac9 ("powerpc/bpf: Write protect JIT code")
>>>> Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
>>>> ---
>>>> arch/powerpc/net/bpf_jit_comp.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> Thanks for the fix!
>>>
>>> Reviewed-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
>>
>> LGTM, I presume this fix will be routed via Michael.
>
> Thanks for reviewing, I've picked it up.
>
>> BPF selftests have plenty of BPF-to-BPF calls in there, too bad this was
>> caught so late. :/
>
> Yeah :/
>
> STRICT_KERNEL_RWX is not on by default in all our defconfigs, so that's
> probably why no one caught it.
Yeah, sorry - we should have caught this sooner.
>
> I used to run the BPF selftests but they stopped building for me a while
> back, I'll see if I can get them going again.
Ravi had started looking into getting the selftests working well before
he left. I will take a look at this.
Thanks,
Naveen
next prev parent reply other threads:[~2021-11-02 11:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 5:56 [PATCH] powerpc/bpf: fix write protecting JIT code Hari Bathini
2021-10-25 5:56 ` Hari Bathini
2021-10-25 6:15 ` Naveen N. Rao
2021-10-25 6:15 ` Naveen N. Rao
2021-10-25 22:54 ` Daniel Borkmann
2021-10-25 22:54 ` Daniel Borkmann
2021-10-29 1:50 ` Michael Ellerman
2021-10-29 1:50 ` Michael Ellerman
2021-11-02 11:59 ` Naveen N. Rao [this message]
2021-11-02 11:59 ` Naveen N. Rao
2021-11-02 13:48 ` Michael Ellerman
2021-11-02 13:48 ` Michael Ellerman
2021-11-02 17:34 ` Andrii Nakryiko
2021-11-02 17:34 ` Andrii Nakryiko
2021-11-02 10:12 ` Michael Ellerman
2021-11-02 10:12 ` Michael Ellerman
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=1635854227.x13v13l6az.naveen@linux.ibm.com \
--to=naveen.n.rao@linux.ibm.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=christophe.leroy@csgroup.eu \
--cc=daniel@iogearbox.net \
--cc=hbathini@linux.ibm.com \
--cc=jniethe5@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=netdev@vger.kernel.org \
--cc=paulus@samba.org \
--cc=songliubraving@fb.com \
--cc=stable@vger.kernel.org \
--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
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.