[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y1BfK6LpDJDlUYKp@smile.fi.intel.com>
Date: Wed, 19 Oct 2022 23:33:47 +0300
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Jane Chu <jane.chu@...cle.com>
Cc: pmladek@...e.com, rostedt@...dmis.org, senozhatsky@...omium.org,
linux@...musvillemoes.dk, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, wangkefeng.wang@...wei.com,
konrad.wilk@...cle.com, haakon.bugge@...cle.com,
john.haxby@...cle.com
Subject: Re: [PATCH v3 1/1] vsprintf: protect kernel from panic due to
non-canonical pointer dereference
On Wed, Oct 19, 2022 at 01:41:59PM -0600, Jane Chu wrote:
> Having stepped on a local kernel bug where reading sysfs has led to
> out-of-bound pointer dereference by vsprintf() which led to GPF panic.
> And the reason for GPF is that the OOB pointer was turned to a
> non-canonical address such as 0x7665645f63616465.
>
> vsprintf() already has this line of defense
> if ((unsigned long)ptr < PAGE_SIZE || IS_ERR_VALUE(ptr))
> return "(efault)";
> Since a non-canonical pointer can be detected by kern_addr_valid()
> on architectures that present VM holes as well as meaningful
> implementation of kern_addr_valid() that detects the non-canonical
> addresses, this patch adds a check on non-canonical string pointer by
> kern_addr_valid() and "(efault)" to alert user that something
> is wrong instead of unecessarily panic the server.
>
> On the other hand, if the non-canonical string pointer is dereferenced
> else where in the kernel, by virtue of being non-canonical, a crash
> is expected to be immediate.
What if there is no other dereference except the one happened in printf()?
Just to point out here, that I formally NAKed this on the basis that NULL
and error pointers are special, for the bogus pointers we need crash ASAP,
no matter what the code issues it. I.o.w. printf() is not special for that
kind of pointers (i.e. bogus pointers, but not special).
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists