linux-stable/init
Yuntao Wang 2ef607ea10 init/main.c: Fix potential static_command_line memory overflow
commit 46dad3c1e5 upstream.

We allocate memory of size 'xlen + strlen(boot_command_line) + 1' for
static_command_line, but the strings copied into static_command_line are
extra_command_line and command_line, rather than extra_command_line and
boot_command_line.

When strlen(command_line) > strlen(boot_command_line), static_command_line
will overflow.

This patch just recovers strlen(command_line) which was miss-consolidated
with strlen(boot_command_line) in the commit f5c7310ac7 ("init/main: add
checks for the return value of memblock_alloc*()")

Link: https://lore.kernel.org/all/20240412081733.35925-2-ytcoode@gmail.com/

Fixes: f5c7310ac7 ("init/main: add checks for the return value of memblock_alloc*()")
Cc: stable@vger.kernel.org
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-05-02 16:23:39 +02:00
..
Kconfig kbuild: check the minimum assembler version in Kconfig 2023-04-20 12:10:28 +02:00
Makefile md: move the early init autodetect code to drivers/md/ 2020-07-16 15:34:47 +02:00
calibrate.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
do_mounts.c rootfs: Fix support for rootfstype= when root= is given 2024-01-25 14:37:52 -08:00
do_mounts.h init: add an init_mknod helper 2020-07-31 08:17:54 +02:00
do_mounts_initrd.c Merge branch 'hch.init_path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2020-08-07 09:40:34 -07:00
do_mounts_rd.c init: add an init_unlink helper 2020-07-31 08:17:52 +02:00
init_task.c seccomp: Fix CONFIG tests for Seccomp_filters 2021-05-14 09:50:24 +02:00
initramfs.c init: open /initrd.image with O_LARGEFILE 2024-04-13 12:59:02 +02:00
main.c init/main.c: Fix potential static_command_line memory overflow 2024-05-02 16:23:39 +02:00
noinitramfs.c init: add an init_mknod helper 2020-07-31 08:17:54 +02:00
version.c treewide: Add SPDX license identifier for missed files 2019-05-21 10:50:45 +02:00