[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f01f7010-f757-c2d2-ff31-eba2b12974e3@rasmusvillemoes.dk>
Date: Wed, 25 Apr 2018 14:43:29 +0200
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Petr Mladek <pmladek@...e.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
"Tobin C . Harding" <me@...in.cc>, Joe Perches <joe@...ches.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Michal Hocko <mhocko@...e.cz>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 10/11] vsprintf: WARN() on invalid pointer access
On 2018-04-25 13:12, Petr Mladek wrote:
>
> diff --git a/lib/test_printf.c b/lib/test_printf.c
> index 45c33143fb4a..74dff6c44ec6 100644
> --- a/lib/test_printf.c
> +++ b/lib/test_printf.c
> @@ -285,12 +285,19 @@ null_pointer(void)
>
> #define PTR_INVALID ((void *)0x000000ab)
>
> +extern int test_printf_pointer_access;
> +
> static void __init
> invalid_pointer(void)
> {
> + /* Avoid calling WARN() */
> + test_printf_pointer_access = 1;
> +
> plain(PTR_INVALID);
> test(ZEROS "000000ab", "%px", PTR_INVALID);
> test("(efault)", "%pE", PTR_INVALID);
> +
> + test_printf_pointer_access = 0;
> }
>
> static void __init
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 5dfdc7e11d05..46e3e7c71229 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -610,6 +610,9 @@ static char *valid_string(char *buf, char *end, const char *s,
> return widen_string(buf, len, end, spec);
> }
>
> +int test_printf_pointer_access;
> +EXPORT_SYMBOL_GPL(test_printf_pointer_access);
> +
I understand that the printf test module needs this hook, and I
considered adding similar things for other tests when I originally wrote
the printf test module. But can we please make that
#if IS_ENABLED(CONFIG_TEST_PRINTF)
int test_printf_pointer_access;
EXPORT_SYMBOL_GPL(test_printf_pointer_access);
#else
#define test_printf_pointer_access 0
#endif
and maybe also wrap the EXPORT_SYMBOL_GPL in another #if
IS_MODULE(CONFIG_TEST_PRINTF). It's not something random modules should
play with, and I'd hate adding ~100 bytes (or whatever the export
metadata uses these days) to vmlinux for the sake of a module that is
most likely not built at all.
Rasmus
Powered by blists - more mailing lists