[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <D1A39BE5-CAB2-42D1-B87B-2E21906FE5B1@amacapital.net>
Date: Fri, 15 Feb 2019 17:32:55 -0800
From: Andy Lutomirski <luto@...capital.net>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Linux List Kernel Mailing <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
stable <stable@...r.kernel.org>,
Changbin Du <changbin.du@...il.com>,
Jann Horn <jannh@...gle.com>,
Kees Cook <keescook@...omium.org>,
Andy Lutomirski <luto@...nel.org>
Subject: Re: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault
> On Feb 15, 2019, at 4:19 PM, Steven Rostedt <rostedt@...dmis.org> wrote:
>
> On Fri, 15 Feb 2019 15:49:35 -0800
> Andy Lutomirski <luto@...capital.net> wrote:
>
>> I’m missing most of the context here, but even probe_kernel_...() is
>> unwise for a totally untrustworthy address. It could be MMIO, for
>> example.
>
> True, but kprobes are used like modules, and only allowed by root. They
> are used to poke literally anywhere one wants. That's the entire
> purpose of kprobes.
>
>>
>> If needed, we could come up with a safe-ish helper for tracing. For
>> direct-map addresses, probe_kernel_...() is probably okay. Same for
>> the current stack. Otherwise we could walk the page tables and check
>> that the address is cacheable, I suppose, although this is slightly
>> dubious if we don’t also check MTRRs. We could also check that the PA
>> is in main memory, I suppose, although this may have unfortunate
>> interactions with the MCE code.
>
> I added you just because I wanted help getting the change log correct,
> as that's what Linus was complaining about. I kept using "kernel
> address" when the sample bug used for the patch was really a
> non-canonical address (as Linus said, it's just garbage. Neither kernel
> or user space). But I pointed out that this can also bug if the
> address is canonical and in the kernel address space. The old code
> didn't complain about non-canonical or kernel address faulting before
> commit 9da3f2b7405, which only talks about kernel address space
> faulting (which is why I only mentioned that in my messages).
>
> Would changing all the mention of "kernel address" to "non user space"
> be accurate?
>
I think “kernel address” is right. It’s illegal to access anything that isn’t known to be a valid kernel address while in KERNEL_DS.
The old __copy seems likely to have always been a bit bogus.
BTW, what is this probe_mem_read() thing? Some minimal inspection suggests it’s a buggy reimplementation of probe_kernel_read(). Can you delete it and just use probe_kernel_read() directly?
> For reference:
>
> http://lkml.kernel.org/r/20190215174945.557218316@goodmis.org
> http://lkml.kernel.org/r/20190215142015.860423791@goodmis.org
>
> -- Steve
Powered by blists - more mailing lists