LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* LZ4 decompressor broken on ARM due to missing strchrnul() string traverse in cpumask_parse"
@ 2019-05-28 11:04 Sebastian Andrzej Siewior
  2019-05-28 11:33 ` Rasmus Villemoes
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-05-28 11:04 UTC (permalink / raw)
  To: Yury Norov, Andrew Morton
  Cc: Rasmus Villemoes, tglx, linux-kernel, linux-arm-kernel

|  CC      arch/arm/boot/compressed/decompress.o
|In file included from include/linux/mm_types_task.h:14,
|                 from include/linux/mm_types.h:5,
|                 from include/linux/mmzone.h:21,
|                 from include/linux/gfp.h:6,
|                 from include/linux/umh.h:4,
|                 from include/linux/kmod.h:22,
|                 from include/linux/module.h:13,
|                 from arch/arm/boot/compressed/../../../../lib/lz4/lz4_decompress.c:39,
|                 from arch/arm/boot/compressed/../../../../lib/decompress_unlz4.c:13,
|                 from arch/arm/boot/compressed/decompress.c:55:
|include/linux/cpumask.h: In function ‘cpumask_parse’:
|include/linux/cpumask.h:636:21: error: implicit declaration of function ‘strchrnul’; did you mean ‘strchr’? [-Werror=implicit-function-declaration]
|  unsigned int len = strchrnul(buf, '\n') - buf;
|                     ^~~~~~~~~
|                     strchr
|include/linux/cpumask.h:636:42: error: invalid operands to binary - (have ‘int’ and ‘const char *’)
|  unsigned int len = strchrnul(buf, '\n') - buf;
|                     ~~~~~~~~~~~~~~~~~~~~ ^
|cc1: some warnings being treated as errors

3713a4e1fdb8da86f96a3e770b08e278d97529b4 is the first bad commit
commit 3713a4e1fdb8da86f96a3e770b08e278d97529b4
Author: Yury Norov <ynorov@marvell.com>
Date:   Tue May 14 15:44:46 2019 -0700

    include/linux/cpumask.h: fix double string traverse in cpumask_parse

    cpumask_parse() finds first occurrence of either or strchr() and
    strlen().  We can do it better with a single call of strchrnul().

    [akpm@linux-foundation.org: remove unneeded cast]
    Link: http://lkml.kernel.org/r/20190409204208.12190-1-ynorov@marvell.com
    Signed-off-by: Yury Norov <ynorov@marvell.com>
    Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

:040000 040000 f20d8a9ec1755b3981520ecf015248f6a0d9f116 db67caf64f99a9be808cd73e413c106c5aee15b7 M      include

This commit is v5.2-rc1~62^2~49.
How do we deal with this one?

Sebastian

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LZ4 decompressor broken on ARM due to missing strchrnul() string traverse in cpumask_parse"
  2019-05-28 11:04 LZ4 decompressor broken on ARM due to missing strchrnul() string traverse in cpumask_parse" Sebastian Andrzej Siewior
@ 2019-05-28 11:33 ` Rasmus Villemoes
  2019-05-28 11:53   ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 3+ messages in thread
From: Rasmus Villemoes @ 2019-05-28 11:33 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior, Yury Norov, Andrew Morton
  Cc: tglx, linux-kernel, linux-arm-kernel

On 28/05/2019 13.04, Sebastian Andrzej Siewior wrote:
> |  CC      arch/arm/boot/compressed/decompress.o
> |In file included from include/linux/mm_types_task.h:14,
> |                 from include/linux/mm_types.h:5,
> |                 from include/linux/mmzone.h:21,
> |                 from include/linux/gfp.h:6,
> |                 from include/linux/umh.h:4,
> |                 from include/linux/kmod.h:22,
> |                 from include/linux/module.h:13,
> |                 from arch/arm/boot/compressed/../../../../lib/lz4/lz4_decompress.c:39,
> |                 from arch/arm/boot/compressed/../../../../lib/decompress_unlz4.c:13,
> |                 from arch/arm/boot/compressed/decompress.c:55:
> |include/linux/cpumask.h: In function ‘cpumask_parse’:
> |include/linux/cpumask.h:636:21: error: implicit declaration of function ‘strchrnul’; did you mean ‘strchr’? [-Werror=implicit-function-declaration]
> |  unsigned int len = strchrnul(buf, '\n') - buf;
> |                     ^~~~~~~~~
> |                     strchr
> |include/linux/cpumask.h:636:42: error: invalid operands to binary - (have ‘int’ and ‘const char *’)
> |  unsigned int len = strchrnul(buf, '\n') - buf;
> |                     ~~~~~~~~~~~~~~~~~~~~ ^
> |cc1: some warnings being treated as errors
> 
> 3713a4e1fdb8da86f96a3e770b08e278d97529b4 is the first bad commit
> commit 3713a4e1fdb8da86f96a3e770b08e278d97529b4
> Author: Yury Norov <ynorov@marvell.com>
> Date:   Tue May 14 15:44:46 2019 -0700
> 
>     include/linux/cpumask.h: fix double string traverse in cpumask_parse
> 
>     cpumask_parse() finds first occurrence of either or strchr() and
>     strlen().  We can do it better with a single call of strchrnul().
> 
>     [akpm@linux-foundation.org: remove unneeded cast]
>     Link: http://lkml.kernel.org/r/20190409204208.12190-1-ynorov@marvell.com
>     Signed-off-by: Yury Norov <ynorov@marvell.com>
>     Acked-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>     Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
>     Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> 
> :040000 040000 f20d8a9ec1755b3981520ecf015248f6a0d9f116 db67caf64f99a9be808cd73e413c106c5aee15b7 M      include
> 
> This commit is v5.2-rc1~62^2~49.
> How do we deal with this one?

Urgh. The problem is really in arch/arm/boot/compressed/decompress.c
which does

#define _LINUX_STRING_H_

preventing linux/string.h from providing strchrnul. It also #includes
asm/string.h, which for arm has a declaration of strchr(), explaining
why this didn't use to fail.

However, the solution is also in the same file, it already has a section

/* Not needed, but used in some headers pulled in by decompressors */
extern char * strstr(const char * s1, const char *s2);
extern size_t strlen(const char *s);
extern int memcmp(const void *cs, const void *ct, size_t count);

so just add another declaration to that list - I strongly assume we
won't get a link failure since I find it hard to believe the
decompressor would actually call cpumask_parse...

I'm wondering why this wasn't caught by 0day and/or while in -next?

Rasmus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: LZ4 decompressor broken on ARM due to missing strchrnul() string traverse in cpumask_parse"
  2019-05-28 11:33 ` Rasmus Villemoes
@ 2019-05-28 11:53   ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Andrzej Siewior @ 2019-05-28 11:53 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Yury Norov, Andrew Morton, tglx, linux-kernel, linux-arm-kernel

On 2019-05-28 13:33:12 [+0200], Rasmus Villemoes wrote:
> > How do we deal with this one?
> 
> Urgh. The problem is really in arch/arm/boot/compressed/decompress.c
> which does
> 
> #define _LINUX_STRING_H_
> 
> preventing linux/string.h from providing strchrnul. It also #includes
> asm/string.h, which for arm has a declaration of strchr(), explaining
> why this didn't use to fail.
> 
> However, the solution is also in the same file, it already has a section
> 
> /* Not needed, but used in some headers pulled in by decompressors */
> extern char * strstr(const char * s1, const char *s2);
> extern size_t strlen(const char *s);
> extern int memcmp(const void *cs, const void *ct, size_t count);
> 
> so just add another declaration to that list - I strongly assume we
> won't get a link failure since I find it hard to believe the
> decompressor would actually call cpumask_parse...

The hunk at the bottom of this mail compiles. Care to send to formal
patch?

> I'm wondering why this wasn't caught by 0day and/or while in -next?

must be related to lz4 usage in the configs tested :) A few set
XZ/LZO/LZMA. Majority falls back to GZIP.

> Rasmus

diff --git a/arch/arm/boot/compressed/decompress.c b/arch/arm/boot/compressed/decompress.c
index c16c1829a5e4f..05814c2b382a3 100644
--- a/arch/arm/boot/compressed/decompress.c
+++ b/arch/arm/boot/compressed/decompress.c
@@ -32,6 +32,7 @@
 extern char * strstr(const char * s1, const char *s2);
 extern size_t strlen(const char *s);
 extern int memcmp(const void *cs, const void *ct, size_t count);
+extern char * strchrnul(const char *,int);
 
 #ifdef CONFIG_KERNEL_GZIP
 #include "../../../../lib/decompress_inflate.c"

Sebastian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-28 11:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-28 11:04 LZ4 decompressor broken on ARM due to missing strchrnul() string traverse in cpumask_parse" Sebastian Andrzej Siewior
2019-05-28 11:33 ` Rasmus Villemoes
2019-05-28 11:53   ` Sebastian Andrzej Siewior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).