netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: hpa@zytor.com
To: Eric Dumazet <eric.dumazet@gmail.com>,
	Daniel Borkmann <daniel@iogearbox.net>,
	alexei.starovoitov@gmail.com
Cc: peterz@infradead.org, netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf] bpf: avoid setting bpf insns pages read-only when prog is jited
Date: Sun, 01 Dec 2019 19:44:39 -0800	[thread overview]
Message-ID: <E02AAB2B-987E-497C-B241-6E86472CC529@zytor.com> (raw)
In-Reply-To: <adc89dbf-361a-838f-a0a5-8ef7ea619848@gmail.com>

On December 1, 2019 6:49:32 PM PST, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
>
>On 11/30/19 1:52 AM, Daniel Borkmann wrote:
>> On 11/30/19 2:37 AM, Eric Dumazet wrote:
>>> On 11/29/19 2:29 PM, Daniel Borkmann wrote:
>>>> For the case where the interpreter is compiled out or when the prog
>is jited
>>>> it is completely unnecessary to set the BPF insn pages as
>read-only. In fact,
>>>> on frequent churn of BPF programs, it could lead to performance
>degradation of
>>>> the system over time since it would break the direct map down to 4k
>pages when
>>>> calling set_memory_ro() for the insn buffer on x86-64 / arm64 and
>there is no
>>>> reverse operation. Thus, avoid breaking up large pages for data
>maps, and only
>>>> limit this to the module range used by the JIT where it is
>necessary to set
>>>> the image read-only and executable.
>>>
>>> Interesting... But why the non JIT case would need RO protection ?
>> 
>> It was done for interpreter around 5 years ago mainly due to concerns
>from security
>> folks that the BPF insn image could get corrupted (through some other
>bug in the
>> kernel) in post-verifier stage by an attacker and then there's
>nothing really that
>> would provide any sort of protection guarantees; pretty much the same
>reasons why
>> e.g. modules are set to read-only in the kernel.
>> 
>>> Do you have any performance measures to share ?
>> 
>> No numbers, and I'm also not aware of any reports from users, but it
>was recently
>> brought to our attention from mm folks during discussion of a
>different set:
>> 
>>
>https://lore.kernel.org/lkml/1572171452-7958-2-git-send-email-rppt@kernel.org/T/
>> 
>
>Thanks for the link !
>
>Having RO protection as a debug feature would be useful.
>
>I believe we have CONFIG_STRICT_MODULE_RWX (and
>CONFIG_STRICT_KERNEL_RWX) for that already.
>
>Or are we saying we also want to get rid of them ?

The notion is that for security there should never been a page which is both writable and executable at the same time. This makes it harder to inject code.
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.

  reply	other threads:[~2019-12-02  3:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29 22:29 [PATCH bpf] bpf: avoid setting bpf insns pages read-only when prog is jited Daniel Borkmann
2019-11-30  1:37 ` Eric Dumazet
2019-11-30  9:52   ` Daniel Borkmann
2019-12-01 17:54     ` Alexei Starovoitov
2019-12-02  2:49     ` Eric Dumazet
2019-12-02  3:44       ` hpa [this message]
2019-12-02  8:30       ` Peter Zijlstra
2019-12-02  9:17         ` Daniel Borkmann
2019-12-02 16:19           ` Alexei Starovoitov
2019-12-02 20:09             ` Daniel Borkmann

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=E02AAB2B-987E-497C-B241-6E86472CC529@zytor.com \
    --to=hpa@zytor.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peterz@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).