Re: What should we do with match_option()?

From: Borislav Petkov
Date: Fri Feb 07 2020 - 14:16:35 EST


On Tue, Feb 04, 2020 at 02:25:47PM -0800, Luck, Tony wrote:
> But this seems to be a belt, braces (USA=suspenders) and stapling the
> waistband of trousers (USA=pants) to your body approach.

Haha.

> If the user supplies a large enough buffer to cmdline_find_option()
> for any of the legal options Then the resulting "arg" will not be
> truncated for anything legal. So we should be able to just use
> "strcmp()" to see which of the options is matched.
>
> So should we promote match_option() to <linux/string.h>? Or
> drop it and just use strcmp() instead?

Makes sense to me: cmdline_find_option() will make sure the string is
NULL-terminated if the buffer is smaller than the option so strcmp()
should not go off into the weeds. The worst that can happen, AFAICT,
is the option not matching but that should be picked up pretty soon in
testing. (I'm assuming we all test our code before sending :-))).

Thx.

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette