Re: [PATCH] vsprintf: Do not break early boot with probing addresses
From: Sergey Senozhatsky
Date: Mon May 13 2019 - 22:09:12 EST
On (05/13/19 14:42), Petr Mladek wrote:
> > The "(null)" is good enough by itself and already an established
> > practice..
> (efault) made more sense with the probe_kernel_read() that
> checked wide range of addresses. Well, I still think that
> it makes sense to distinguish a pure NULL. And it still
> used also for IS_ERR_VALUE().
Wouldn't anything within first PAGE_SIZE bytes be reported as
a NULL deref?
char *p = (char *)(PAGE_SIZE - 2);
*p = 'a';
kernel: BUG: kernel NULL pointer dereference, address = 0000000000000ffe
kernel: #PF: supervisor-privileged write access from kernel code
kernel: #PF: error_code(0x0002) - not-present page
And I like Steven's "(fault)" idea.
How about this:
if ptr < PAGE_SIZE -> "(null)"
if IS_ERR_VALUE(ptr) -> "(fault)"