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: <20200107142512.b3d63df56ffee1ef471b6acd@linux-foundation.org>
Date:   Tue, 7 Jan 2020 14:25:12 -0800
From:   Andrew Morton <akpm@...ux-foundation.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Oleksandr Natalenko <oleksandr@...hat.com>, linux-mm@...ck.org,
        Arnaldo Carvalho de Melo <acme@...hat.com>,
        Will Deacon <will@...nel.org>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Song Liu <songliubraving@...com>,
        Alexey Dobriyan <adobriyan@...il.com>,
        Marc Zyngier <maz@...nel.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kallsyms: work around bogus -Wrestrict warning

On Tue,  7 Jan 2020 22:40:26 +0100 Arnd Bergmann <arnd@...db.de> wrote:

> gcc -O3 produces some really odd warnings for this file:
> 
> kernel/kallsyms.c: In function 'sprint_symbol':
> kernel/kallsyms.c:369:3: error: 'strcpy' source argument is the same as destination [-Werror=restrict]
>    strcpy(buffer, name);
>    ^~~~~~~~~~~~~~~~~~~~
> kernel/kallsyms.c: In function 'sprint_symbol_no_offset':
> kernel/kallsyms.c:369:3: error: 'strcpy' source argument is the same as destination [-Werror=restrict]
>    strcpy(buffer, name);
>    ^~~~~~~~~~~~~~~~~~~~
> kernel/kallsyms.c: In function 'sprint_backtrace':
> kernel/kallsyms.c:369:3: error: 'strcpy' source argument is the same as destination [-Werror=restrict]
>    strcpy(buffer, name);
>    ^~~~~~~~~~~~~~~~~~~~
> 
> This obviously cannot be since it is preceded by an 'if (name != buffer)'
> check.
> 
> Using sprintf() instead of strcpy() is a bit wasteful but is
> the best workaround I could come up with.
> 
> ...
>
> --- a/kernel/kallsyms.c
> +++ b/kernel/kallsyms.c
> @@ -366,7 +366,7 @@ static int __sprint_symbol(char *buffer, unsigned long address,
>  		return sprintf(buffer, "0x%lx", address - symbol_offset);
>  
>  	if (name != buffer)
> -		strcpy(buffer, name);
> +		sprintf(buffer, "%s", name);
>  	len = strlen(buffer);
>  	offset -= symbol_offset;

gee, is that even worth "fixing"?  Oleksandr, I've seen a couple of
these false positives.  Do we know if anyone is taking them to the gcc
developers?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ