lkml.org 
[lkml]   [2018]   [Apr]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v5 10/11] vsprintf: WARN() on invalid pointer access
From
Date
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


\
 
 \ /
  Last update: 2018-04-25 14:43    [W:0.156 / U:11.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site