From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,wfelipe@google.com,akpm@linux-foundation.org
Subject: [merged mm-nonmm-stable] init-main-fix-off-by-one-in-argv_init-cleanup.patch removed from -mm tree
Date: Tue, 06 Oct 2026 19:04:19 -0700 [thread overview]
Message-ID: <20261007020420.34A3E1F0089C@smtp.kernel.org> (raw)
The quilt patch titled
Subject: init/main: fix off-by-one in argv_init cleanup
has been removed from the -mm tree. Its filename was
init-main-fix-off-by-one-in-argv_init-cleanup.patch
This patch was dropped because it was merged into the mm-nonmm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Wilson Felipe Pereira <wfelipe@google.com>
Subject: init/main: fix off-by-one in argv_init cleanup
Date: Tue, 18 Aug 2026 04:53:46 +0000
Patch series "init: fix array boundary bugs in boot parameter parsing".
This series fixes two distinct boundary logic edge-case bugs in
`init/main.c` related to parsing boot command-line arguments and
environment variables. Both bugs have been present since the early git
history (Linux-2.6.12-rc2).
1. The first patch fixes an off-by-one error in `init_setup()` where
the final slot of the `argv_init` array was left uncleared. This
allowed a stale kernel parameter to leak into the `init` process's
user-space command line if exactly `MAX_INIT_ARGS` unknown
parameters were passed.
2. The second patch fixes a false-positive kernel panic in
`unknown_bootoption()`. If a user filled the environment variable
array up to its exact limit (32) and then attempted to overwrite
the final variable, the kernel would panic before evaluating
whether it was a harmless duplicate.
Exact QEMU reproduction steps for both edge cases are documented inside
their respective commit descriptions.
This patch (of 2):
When cleaning up argv_init in init_setup() and rdinit_setup(), the loop
terminates one element early due to using '<' instead of '<='. Since
argv_init is sized MAX_INIT_ARGS+2, index MAX_INIT_ARGS is a valid element
that should be cleared to NULL.
If exactly MAX_INIT_ARGS unknown arguments are passed before 'init=', the
uncleared argv_init[MAX_INIT_ARGS] can act as a ghost argument to
/sbin/init or cause a spurious kernel panic when later appended to.
To verify the argument leak, boot a VM into a shell with 32 unknown kernel
arguments, the init parameter, and 31 user arguments:
STALE_ARGS=$(for i in {1..32}; do echo -n "stale$i "; done)
USER_ARGS=$(for i in {1..31}; do echo -n "user$i "; done)
qemu-system-x86_64 -kernel bzImage \
-append "$STALE_ARGS init=/bin/sh $USER_ARGS"
Running `cat /proc/1/cmdline` inside the shell reveals that the 32nd
kernel argument ('stale32') incorrectly leaked into the init process's
command line. This patch zeroes the final slot, cleanly terminating the
array.
Link: https://lore.kernel.org/20260818045357.4123784-1-wfelipe@google.com
Link: https://lore.kernel.org/20260818045357.4123784-2-wfelipe@google.com
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Fixes: ffdfc40976dd ("[PATCH] Add rdinit parameter to pick early userspace init")
Signed-off-by: Wilson Felipe Pereira <wfelipe@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
init/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
--- a/init/main.c~init-main-fix-off-by-one-in-argv_init-cleanup
+++ a/init/main.c
@@ -581,7 +581,7 @@ static int __init init_setup(char *str)
* the shell think it should execute a script with such name.
* So we ignore all arguments entered _before_ init=... [MJ]
*/
- for (i = 1; i < MAX_INIT_ARGS; i++)
+ for (i = 1; i <= MAX_INIT_ARGS; i++)
argv_init[i] = NULL;
return 1;
}
@@ -594,7 +594,7 @@ static int __init rdinit_setup(char *str
ramdisk_execute_command = str;
ramdisk_execute_command_set = true;
/* See "auto" comment in init_setup */
- for (i = 1; i < MAX_INIT_ARGS; i++)
+ for (i = 1; i <= MAX_INIT_ARGS; i++)
argv_init[i] = NULL;
return 1;
}
_
Patches currently in -mm which might be from wfelipe@google.com are
mm-zswap-convert-zswap_store_page-and-zswap_compress-to-take-a-folio.patch
reply other threads:[~2026-10-07 2:04 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261007020420.34A3E1F0089C@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=mm-commits@vger.kernel.org \
--cc=wfelipe@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.