Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address -Wstringop-overflow warning in arch/s390/kernel/setup.c #340

Open
GustavoARSilva opened this issue Aug 17, 2023 · 0 comments
Open
Labels
-Wstringop-overflow Emits warnings under -Wstringop-overflow

Comments

@GustavoARSilva
Copy link
Collaborator

GustavoARSilva commented Aug 17, 2023

Seen under s390 and allyesconfig

In function 'strlcat',
    inlined from 'strcat' at include/linux/fortify-string.h:432:6,
    inlined from 'setup_zfcpdump' at arch/s390/kernel/setup.c:309:2,
    inlined from 'setup_arch' at arch/s390/kernel/setup.c:1009:2:
include/linux/fortify-string.h:57:33: warning: '__builtin_memcpy' writing 30 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=]
   57 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
include/linux/fortify-string.h:405:9: note: in expansion of macro '__underlying_memcpy'
  405 |         __underlying_memcpy(p + p_len, q, copy_len);
      |         ^~~~~~~~~~~~~~~~~~~

Code to audit:

arch/s390/kernel/setup.c:

 302 #ifdef CONFIG_CRASH_DUMP
 303 static void __init setup_zfcpdump(void)
 304 {
 305         if (!is_ipl_type_dump())
 306                 return;
 307         if (oldmem_data.start)
 308                 return;
 @ 309         strcat(boot_command_line, " cio_ignore=all,!ipldev,!condev");
 310         console_loglevel = 2;
 311 }
 312 #else
 313 static inline void setup_zfcpdump(void) {}
 314 #endif /* CONFIG_CRASH_DUMP */

init/main.c:

 137 /* Untouched command line saved by arch-specific code. */
 138 char boot_command_line[COMMAND_LINE_SIZE] __ro_after_init;

include/linux/init.h:

147 extern char boot_command_line[];

arch/s390/include/asm/setup.h:

 15 #define COMMAND_LINE_SIZE CONFIG_COMMAND_LINE_SIZE

arch/s390/Kconfig:

436 config COMMAND_LINE_SIZE
437         int "Maximum size of kernel command line"
438         default 4096
439         range 896 1048576
440         help
441           This allows you to specify the maximum length of the kernel command
442           line.
@GustavoARSilva GustavoARSilva added the -Wstringop-overflow Emits warnings under -Wstringop-overflow label Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-Wstringop-overflow Emits warnings under -Wstringop-overflow
Projects
None yet
Development

No branches or pull requests

1 participant