[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMrEMU-8KizWmgmYHzu8B++HOyfvC-2LF4KP7ibZki_q-_JrxA@mail.gmail.com>
Date: Sat, 4 Jan 2020 17:19:14 -0800
From: Justin Capella <justincapella@...il.com>
To: KP Singh <kpsingh@...omium.org>
Cc: Andy Lutomirski <luto@...capital.net>,
Rick Edgecombe <rick.p.edgecombe@...el.com>,
LKML <linux-kernel@...r.kernel.org>, bpf@...r.kernel.org,
x86@...nel.org, linux-security-module@...r.kernel.org,
Kees Cook <keescook@...omium.org>,
"David S. Miller" <davem@...emloft.net>,
Alexey Kuznetsov <kuznet@....inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Andrii Nakryiko <andriin@...com>,
Thomas Garnier <thgarnie@...omium.org>,
Florent Revest <revest@...omium.org>,
Brendan Jackman <jackmanb@...omium.org>,
Jann Horn <jannh@...gle.com>,
Matthew Garrett <mjg59@...gle.com>,
Michael Halcrow <mhalcrow@...gle.com>
Subject: Re: [PATCH bpf-next] bpf: Make trampolines W^X
I'm guessing 2 pages are used to allow for different protections? Does
only the first page's protections need to be changed? Is that
"old_image"?
+ set_memory_nx((unsigned long)image, 1);
+ set_memory_rw((unsigned long)image, 1);
+ set_memory_ro((unsigned long)new_image, 1);
+ set_memory_x((unsigned long)new_image, 1);
Because
+ void *old_image = tr->image + ((tr->selector + 1) & 1) * PAGE_SIZE;
+ void *new_image = tr->image + (tr->selector & 1) * PAGE_SIZE
> > - Mark the memory as read-only (set_memory_ro)
> > - Mark the memory as executable (set_memory_x)
>
> No, thanks. There’s very little excuse for doing two IPI flushes when one would suffice.
If there were checks between these steps to verify the trampoline
wasn't tampered with while the page was writable it would make sense
to do so before enabling execution.
Could some of these int's be unsigned to be extra cautious?
One last thought, if the extra checks are implemented, maybe comparing
against the old image prior to setting rw would be worthwhile?
Powered by blists - more mailing lists