[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20210418213420.1086500-1-paul.gortmaker@windriver.com>
Date: Sun, 18 Apr 2021 17:34:20 -0400
From: Paul Gortmaker <paul.gortmaker@...driver.com>
To: <linux-kernel@...r.kernel.org>
Subject: [PATCH] sched/isolation: don't do unbounded chomp on bootarg string
After commit 3662daf023500dc084fa3b96f68a6f46179ddc73
("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")
the isolcpus= string is walked to skip over what might be future flag
comma separated additions.
However, there is a logic error, and so as can clearly be seen below, it
will ignore its own arg len and search to the end of the bootarg string.
$ dmesg|grep isol
Command line: BOOT_IMAGE=/boot/bzImage isolcpus=xyz pleasedontparseme=1 root=/dev/sda1 ro
Kernel command line: BOOT_IMAGE=/boot/bzImage isolcpus=xyz pleasedontparseme=1 root=/dev/sda1 ro
isolcpus: Skipped unknown flag xyz
isolcpus: Invalid flag pleasedontparseme=1 root=/dev/sda1 ro
This happens because the flag "skip" code does an unconditional
increment, which skips over the '\0' check the loop body looks for. If
the isolcpus= happens to be the last bootarg, then you'd never notice?
So we only increment if the skipped flag is followed by a comma, as per
what the existing "continue" flag matching code does.
Note that isolcpus= was declared deprecated as of v4.15 (b0d40d2b22fe),
so we might want to revisit that if we are trying to future-proof it
as recently as a year ago for as yet unseen new flags.
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Frederic Weisbecker <frederic@...nel.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Peter Xu <peterx@...hat.com>
Fixes: 3662daf02350 ("sched/isolation: Allow "isolcpus=" to skip unknown sub-parameters")
Signed-off-by: Paul Gortmaker <paul.gortmaker@...driver.com>
diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c
index 5a6ea03f9882..9652dba7e938 100644
--- a/kernel/sched/isolation.c
+++ b/kernel/sched/isolation.c
@@ -188,7 +188,8 @@ static int __init housekeeping_isolcpus_setup(char *str)
}
pr_info("isolcpus: Skipped unknown flag %.*s\n", len, par);
- str++;
+ if (str[1] == ',') /* above continue; match on "flag," */
+ str++;
}
/* Default behaviour for isolcpus without flags */
--
2.25.1
Powered by blists - more mailing lists