From: Thomas Gleixner <tglx@linutronix.de>
To: Ingo Molnar <mingo@kernel.org>, Muchun Song <songmuchun@bytedance.com>
Cc: peterz@infradead.org, bigeasy@linutronix.de, namit@vmware.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] smp: Fix a potential usage of stale nr_cpus
Date: Mon, 27 Jul 2020 18:04:53 +0200 [thread overview]
Message-ID: <87mu3laqqi.fsf@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20200727114303.GA57241@gmail.com>
Ingo Molnar <mingo@kernel.org> writes:
>> - get_option(&str, &nr_cpus);
>> + if (get_option(&str, &nr_cpus) != 1)
>> + return -EINVAL;
>> +
>> if (nr_cpus > 0 && nr_cpus < nr_cpu_ids)
>> nr_cpu_ids = nr_cpus;
>> + else
>> + return -EINVAL;
>
> Exactly what does 'not valid' mean, and why doesn't get_option()
> return -EINVAL in that case?
What's unclear about invalid? If you specify nr_cpus=-1 or
nr_cpus=2000000 the its obviously invalid.
How should get_option() know that this is invalid? get_option() is a
number parser and does not know about any restrictions on the parsed
value obviously.
get_option() returns string parsing information:
0 -> not integer found
1 -> integer found, no trailing comma or hyphen
2 -> integer found and trailing comma
3 -> integer found and traling hyphen (range parsing)
And that's what is checked in if (get_option() != 1), i.e. anything else
than a plain integer is invalid for this command line option.
Thanks,
tglx
next prev parent reply other threads:[~2020-07-27 16:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-21 3:42 [PATCH v3] smp: Fix a potential usage of stale nr_cpus Muchun Song
2020-07-27 11:43 ` Ingo Molnar
2020-07-27 16:04 ` Thomas Gleixner [this message]
2020-07-27 21:34 ` Ingo Molnar
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=87mu3laqqi.fsf@nanos.tec.linutronix.de \
--to=tglx@linutronix.de \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namit@vmware.com \
--cc=peterz@infradead.org \
--cc=songmuchun@bytedance.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox