Re: [PATCH] lib/cmdline: fix get_options() count and overflow with large ranges
From: Andrew Morton
Date: Wed Oct 07 2026 - 20:08:32 EST
On Wed, 7 Oct 2026 19:50:38 -0400 Armaan Sandhu <armaan.sandhu0504@xxxxxxxxx> wrote:
> On Wed, 7 Oct 2026 Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
> > Armaan, can you please check the regression tests, see if there's
> > anything to be incorporated into yours?
>
> Leizhen's two cases pass with my patch. "0-2147483647" in validation
> mode is already in my table, but "1,0-2147483647" isn't, and it is worth
> adding since it hits the overflow guard with a value already parsed, which
> none of my cases do. It's one extra row:
>
> { "1,0-2147483647", { 3, 1, 0, 1, }, 1, },
>
> Earlier you asked what would change in a v2. Nothing else, so I can
> send a v2 with that row, or you can fold it in, whichever is easier.
>
> Thanks Leizhen for the review.
Yes, thanks both. I queued Armaan's patch and appended this:
--- a/lib/tests/cmdline_kunit.c~lib-cmdline-fix-get_options-count-and-overflow-with-large-ranges-fix
+++ a/lib/tests/cmdline_kunit.c
@@ -151,6 +151,7 @@ static const struct {
{ "0-2147483647", { 3, 0, 1, 2, }, 0, },
{ "-5-2147483647", { 3, -5, -4, -3, }, 0, },
{ "2147483647--5", { 0, 2147483647, }, 0, },
+ { "1,0-2147483647", { 3, 1, 0, 1, }, 1, },
};
static void cmdline_test_range_overflow(struct kunit *test)
_