vsprintf: Prevent crash when dereferencing invalid pointers for %pD
authorJia He <justin.he@arm.com>
Fri, 9 Aug 2019 01:24:56 +0000 (09:24 +0800)
committerPetr Mladek <pmladek@suse.com>
Thu, 15 Aug 2019 14:40:10 +0000 (16:40 +0200)
commit36594b317c656bec8f968db93701d2cb9bc9155c
tree4cebb6b88c3d8f37dc076b8bd219ec03f21f974f
parent7011b7e1b702cc76f9e969b41d9a95969f2aecaa
vsprintf: Prevent crash when dereferencing invalid pointers for %pD

Commit 3e5903eb9cff ("vsprintf: Prevent crash when dereferencing invalid
pointers") prevents most crash except for %pD.
There is an additional pointer dereferencing before dentry_name.

At least, vma->file can be NULL and be passed to printk %pD in
print_bad_pte, which can cause crash.

This patch fixes it with introducing a new file_dentry_name.

Link: http://lkml.kernel.org/r/20190809012457.56685-1-justin.he@arm.com
Fixes: 3e5903eb9cff ("vsprintf: Prevent crash when dereferencing invalid pointers")
To: Geert Uytterhoeven <geert+renesas@glider.be>
To: Thomas Gleixner <tglx@linutronix.de>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>
Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: "Tobin C. Harding" <tobin@kernel.org>
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Petr Mladek <pmladek@suse.com>
lib/vsprintf.c