Re: [RFC PATCH 1/2] x86: WARN() when uaccess helpers fault on kernel addresses

From: Andy Lutomirski
Date: Tue Aug 07 2018 - 10:02:19 EST



> On Aug 7, 2018, at 4:04 AM, Dmitry Vyukov <dvyukov@xxxxxxxxxx> wrote:
>
>> On Tue, Aug 7, 2018 at 3:22 AM, Jann Horn <jannh@xxxxxxxxxx> wrote:
>> There have been multiple kernel vulnerabilities that permitted userspace to
>> pass completely unchecked pointers through to userspace accessors:
>>
>> - the waitid() bug - commit 96ca579a1ecc ("waitid(): Add missing
>> access_ok() checks")
>> - the sg/bsg read/write APIs
>> - the infiniband read/write APIs
>>
>> These don't happen all that often, but when they do happen, it is hard to
>> test for them properly; and it is probably also hard to discover them with
>> fuzzing. Even when an unmapped kernel address is supplied to such buggy
>> code, it just returns -EFAULT instead of doing a proper BUG() or at least
>> WARN().
>>
>> This patch attempts to make such misbehaving code a bit more visible by
>> WARN()ing in the pagefault handler code when a userspace accessor causes
>> #PF on a kernel address and the current context isn't whitelisted.
>
> This is not triggerable unless there is a kernel bug, right? I mean
> this won't be a DoS vector? And any case is something to report to
> kernel developers?

Yes. I expect it to help fuzzers, since it will make a uaccess at a bad address much more likely to oops.

My old series found one bug when the automated fuzzers fuzzed it. That bug is fixed now.