lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200211124317.x5erhl7kvxj2nq6a@pathway.suse.cz>
Date:   Tue, 11 Feb 2020 13:43:17 +0100
From:   Petr Mladek <pmladek@...e.com>
To:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc:     Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
        linux-kernel@...r.kernel.org, Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH v1] printk: Declare log_wait as external variable

On Mon 2020-02-03 15:15:28, Andy Shevchenko wrote:
> Static analyzer is not happy:
> 
> kernel/printk/printk.c:421:1: warning: symbol 'log_wait' was not declared. Should it be static?
> 
> This is due to usage of log_wait in the other module without announcing
> its declaration to the world. I wasn't able to dug into deep history of
> reasons why it is so, and thus decide to make less invasive change, i.e.
> declaring log_wait as external variable to make static analyzer happy.
> 
> Note the above is done if and only if the CONFIG_PROC_FS is enabled,
> otherwise we fallback to static variable.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
> ---
>  kernel/printk/printk.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 633f41a11d75..43b5cb88c607 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -418,7 +418,14 @@ DEFINE_RAW_SPINLOCK(logbuf_lock);
>  	} while (0)
>  
>  #ifdef CONFIG_PRINTK
> +
> +#ifdef CONFIG_PROC_FS
> +extern wait_queue_head_t log_wait;	/* Used in fs/proc/kmsg.c */
>  DECLARE_WAIT_QUEUE_HEAD(log_wait);
> +#else
> +static DECLARE_WAIT_QUEUE_HEAD(log_wait);
> +#endif /* CONFIG_PROC_FS */

This looks too complicated as a workaround for a warning.

I got really confused. Probably also because the macro DECLARE_*()
does a definition instead of a declaration.

As a minimal fix, I suggest to rename log_wait -> printk_log_wait
and declare it in include/linux/printk.h.

Even better solution might be to move fs/proc/kmsg.c to
kernel/printk/proc_kmsg.c and declare printk_log_wait only
in kernel/printk/internal.h. I think that this is what
Sergey suggested.

Another great thing would be to extract devkmsg stuff from
kernel/printk/printk.c and put it into kernel/printk/dev_kmsg.c.

I am not sure but it might help people to realize that there
are actually two different interfaces (old in /proc dmesg-like,
and in /dev new for systemd). Sigh.

I am not sure how deep and far you would like to go ;-)

Best Regards,
Petr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ