From: Matteo Croce <mcroce@linux.microsoft.com>
To: linux-kernel@vger.kernel.org
Cc: Guenter Roeck <linux@roeck-us.net>,
Petr Mladek <pmladek@suse.com>, Arnd Bergmann <arnd@arndb.de>,
Mike Rapoport <rppt@kernel.org>,
Kees Cook <keescook@chromium.org>,
Pavel Tatashin <pasha.tatashin@soleen.com>,
Robin Holt <robinmholt@gmail.com>,
Fabian Frederick <fabf@skynet.be>,
Andrew Morton <akpm@linux-foundation.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: [PATCH v3 1/3] Revert "kernel/reboot.c: convert simple_strtoul to kstrtoint"
Date: Tue, 3 Nov 2020 22:40:23 +0100 [thread overview]
Message-ID: <20201103214025.116799-2-mcroce@linux.microsoft.com> (raw)
In-Reply-To: <20201103214025.116799-1-mcroce@linux.microsoft.com>
From: Matteo Croce <mcroce@microsoft.com>
This reverts commit 616feab753972b9751308f3cd2a68fc57eae8edb.
kstrtoint() and simple_strtoul() have a subtle difference which makes
them non interchangeable: if a non digit character is found amid the
parsing, the former will return an error, while the latter will just
stop parsing, e.g. simple_strtoul("123xyx") = 123.
The kernel cmdline reboot= argument allows to specify the CPU used
for rebooting, with the syntax `s####` among the other flags,
e.g. "reboot=warm,s31,force", so if this flag is not the last given,
it's silently ignored as well as the subsequent ones.
Fixes: 616feab75397 ("kernel/reboot.c: convert simple_strtoul to kstrtoint")
Cc: stable@vger.kernel.org
Signed-off-by: Matteo Croce <mcroce@microsoft.com>
---
kernel/reboot.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)
diff --git a/kernel/reboot.c b/kernel/reboot.c
index e7b78d5ae1ab..8fbba433725e 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -551,22 +551,15 @@ static int __init reboot_setup(char *str)
break;
case 's':
- {
- int rc;
-
- if (isdigit(*(str+1))) {
- rc = kstrtoint(str+1, 0, &reboot_cpu);
- if (rc)
- return rc;
- } else if (str[1] == 'm' && str[2] == 'p' &&
- isdigit(*(str+3))) {
- rc = kstrtoint(str+3, 0, &reboot_cpu);
- if (rc)
- return rc;
- } else
+ if (isdigit(*(str+1)))
+ reboot_cpu = simple_strtoul(str+1, NULL, 0);
+ else if (str[1] == 'm' && str[2] == 'p' &&
+ isdigit(*(str+3)))
+ reboot_cpu = simple_strtoul(str+3, NULL, 0);
+ else
*mode = REBOOT_SOFT;
break;
- }
+
case 'g':
*mode = REBOOT_GPIO;
break;
--
2.28.0
next prev parent reply other threads:[~2020-11-03 21:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-03 21:40 [PATCH v3 0/3] fix parsing of reboot= cmdline Matteo Croce
2020-11-03 21:40 ` Matteo Croce [this message]
2020-11-05 18:02 ` [PATCH v3 1/3] Revert "kernel/reboot.c: convert simple_strtoul to kstrtoint" Petr Mladek
2020-11-03 21:40 ` [PATCH v3 2/3] reboot: fix overflow parsing reboot cpu number Matteo Croce
2020-11-05 18:09 ` Petr Mladek
2020-11-05 18:14 ` Matteo Croce
2020-11-06 10:18 ` Petr Mladek
2020-11-03 21:40 ` [PATCH v3 3/3] reboot: refactor and comment the cpu selection code Matteo Croce
2020-11-05 18:09 ` Petr Mladek
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=20201103214025.116799-2-mcroce@linux.microsoft.com \
--to=mcroce@linux.microsoft.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=fabf@skynet.be \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=pasha.tatashin@soleen.com \
--cc=pmladek@suse.com \
--cc=robinmholt@gmail.com \
--cc=rppt@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome