From: Jane Chu <jane.chu@oracle.com>
To: Petr Mladek <pmladek@suse.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"rostedt@goodmis.org" <rostedt@goodmis.org>,
"senozhatsky@chromium.org" <senozhatsky@chromium.org>,
"linux@rasmusvillemoes.dk" <linux@rasmusvillemoes.dk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
Haakon Bugge <haakon.bugge@oracle.com>,
John Haxby <john.haxby@oracle.com>,
Konrad Wilk <konrad.wilk@oracle.com>,
Jane Chu <jane.chu@oracle.com>
Subject: Re: [PATCH v2] vsprintf: protect kernel from panic due to non-canonical pointer dereference
Date: Thu, 20 Oct 2022 01:00:15 +0000 [thread overview]
Message-ID: <a967a880-5196-954e-817f-50372a44a159@oracle.com> (raw)
In-Reply-To: <860872bd-127f-36ee-f803-6553a6f03826@oracle.com>
On 10/19/2022 1:02 PM, Jane Chu wrote:
> Hi, Petr,
>
> Sorry, I didn't catch this email prior to sending out v3.
>
> [..]
>>>
>>> Yes, kern_addr_valid() is used by read_kcore() which is architecturally
>>> independent and applies everywhere, so does that imply that it is
>>> defined in all architectures?
>>
>> It is more complicated. fs/proc/kcore.c is built when
>> CONFIG_PROC_KCORE is set. It is defined in fs/proc/Kconfig as:
>>
>> config PROC_KCORE
>> bool "/proc/kcore support" if !ARM
>> depends on PROC_FS && MMU
>>
>> So, it is not built on ARM.
>
> Indeed, it's defined on ARM though.
>
>>
>> More importantly, kern_addr_valid() seems to be implemented only for x86_64.
>> It is always true (1) on all other architectures, see
>>
>> $> git grep kern_addr_valid
>> arch/alpha/include/asm/pgtable.h:#define kern_addr_valid(addr) (1)
>> arch/arc/include/asm/pgtable-bits-arcv2.h:#define kern_addr_valid(addr) (1)
>> arch/arm/include/asm/pgtable-nommu.h:#define kern_addr_valid(addr) (1)
>> arch/arm/include/asm/pgtable.h:#define kern_addr_valid(addr) (1)
>> [...]
>>
>> Wait, it is actually always false (0) on x86 when SPARSEMEM is used,
>> see arch/x86/include/asm/pgtable_32.h:
>>
>> #ifdef CONFIG_FLATMEM
>> #define kern_addr_valid(addr) (1)
>> #else
>> #define kern_addr_valid(kaddr) (0)
>> #endif
>>
>
> Thanks for pointing this out. Let me do some digging ...
So I tried to dig, the history of kern_addr_valid() and its connection
with PROC_KCORE went way back, I'm unable to find out why on old memory
models such as x86 SPARSEMEM & DISCONTIGMEM, kern_addr_valid() is
defined as '(0)'. My guess is perhaps PROC_KCORE isn't supported on
those memory model, and having kern_addr_valid() to reject the start
address is a convenient way to fail the load - just a guess, with no
evidence for support. Anyway a generic use of kern_addr_valid() will
break platforms with SPARSEMEM & DISCONTIGMEM memory model. And this is
beside the fact that kern_addr_valid() is going away, and I don't see a
good replacement.
I understand folks' rejecting the patch on the ground of dereferencing
bogus pointers anywhere in the kernel including vsprintf() is not worth
protecting. I'm not going to insist on any further, I'd just like to
thank all of you who've spent time reviewing the patch, and providing
comments and explanations.
Regards,
-jane
next prev parent reply other threads:[~2022-10-20 1:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 19:44 [PATCH v2] vsprintf: protect kernel from panic due to non-canonical pointer dereference Jane Chu
2022-10-17 20:27 ` Andy Shevchenko
2022-10-17 21:12 ` Jane Chu
2022-10-18 7:40 ` Petr Mladek
2022-10-18 19:36 ` Jane Chu
2022-10-19 9:33 ` Petr Mladek
2022-10-19 20:02 ` Jane Chu
2022-10-20 1:00 ` Jane Chu [this message]
2022-10-18 7:10 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a967a880-5196-954e-817f-50372a44a159@oracle.com \
--to=jane.chu@oracle.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=haakon.bugge@oracle.com \
--cc=john.haxby@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=senozhatsky@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.