From: Jane Chu <jane.chu@oracle.com>
To: pmladek@suse.com, rostedt@goodmis.org, senozhatsky@chromium.org,
andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk,
linux-kernel@vger.kernel.org
Cc: jane.chu@oracle.com
Subject: [PATCH v2] vsprintf: protect kernel from panic due to non-canonical pointer dereference
Date: Mon, 17 Oct 2022 13:44:47 -0600 [thread overview]
Message-ID: <20221017194447.2579441-1-jane.chu@oracle.com> (raw)
While debugging a separate issue, it was found that an invalid string
pointer could very well contain a non-canical address, such as
0x7665645f63616465. In that case, this line of defense isn't enough
to protect the kernel from crashing due to general protection fault
if ((unsigned long)ptr < PAGE_SIZE || IS_ERR_VALUE(ptr))
return "(efault)";
So run one more round of check via kern_addr_valid(). On architectures
that provide meaningful implementation, this line of check effectively
catches non-canonical pointers, etc.
Signed-off-by: Jane Chu <jane.chu@oracle.com>
---
lib/vsprintf.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index c414a8d9f1ea..b38c12ef1e45 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -698,6 +698,9 @@ static const char *check_pointer_msg(const void *ptr)
if ((unsigned long)ptr < PAGE_SIZE || IS_ERR_VALUE(ptr))
return "(efault)";
+ if (!kern_addr_valid((unsigned long)ptr))
+ return "(efault)";
+
return NULL;
}
--
2.18.4
next reply other threads:[~2022-10-17 19:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-17 19:44 Jane Chu [this message]
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
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=20221017194447.2579441-1-jane.chu@oracle.com \
--to=jane.chu@oracle.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®