mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [Patch] KVM: selftests: Make reclaim_period_ms input always be positive
@ 2023-01-10 21:52 Vipin Sharma
  2023-01-10 22:19 ` Ben Gardon
  0 siblings, 1 reply; 3+ messages in thread
From: Vipin Sharma @ 2023-01-10 21:52 UTC (permalink / raw)
  To: seanjc, pbonzini, bgardon; +Cc: kvm, linux-kernel, Vipin Sharma

reclaim_period_ms used to be positive only but the commit 0001725d0f9b
("KVM: selftests: Add atoi_positive() and atoi_non_negative() for input
validation") incorrectly changed it to non-negative validation.

Change validation to allow only positive input.

Signed-off-by: Vipin Sharma <vipinsh@google.com>
Reported-by: Ben Gardon <bgardon@google.com>
---
 tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
index ea0978f22db8..251794f83719 100644
--- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
+++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
@@ -241,7 +241,7 @@ int main(int argc, char **argv)
 	while ((opt = getopt(argc, argv, "hp:t:r")) != -1) {
 		switch (opt) {
 		case 'p':
-			reclaim_period_ms = atoi_non_negative("Reclaim period", optarg);
+			reclaim_period_ms = atoi_positive("Reclaim period", optarg);
 			break;
 		case 't':
 			token = atoi_paranoid(optarg);
-- 
2.39.0.314.g84b9a713c41-goog


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] KVM: selftests: Make reclaim_period_ms input always be positive
  2023-01-10 21:52 [Patch] KVM: selftests: Make reclaim_period_ms input always be positive Vipin Sharma
@ 2023-01-10 22:19 ` Ben Gardon
  2023-01-11  0:45   ` Vipin Sharma
  0 siblings, 1 reply; 3+ messages in thread
From: Ben Gardon @ 2023-01-10 22:19 UTC (permalink / raw)
  To: Vipin Sharma; +Cc: seanjc, pbonzini, kvm, linux-kernel

On Tue, Jan 10, 2023 at 1:52 PM Vipin Sharma <vipinsh@google.com> wrote:
>
> reclaim_period_ms used to be positive only but the commit 0001725d0f9b
> ("KVM: selftests: Add atoi_positive() and atoi_non_negative() for input
> validation") incorrectly changed it to non-negative validation.
>
> Change validation to allow only positive input.
>
> Signed-off-by: Vipin Sharma <vipinsh@google.com>
> Reported-by: Ben Gardon <bgardon@google.com>

Please add a Fixes: tag:
Fixes: 0001725d0f9b ("KVM: selftests: Add atoi_positive() and
atoi_non_negative() for input validation")

But otherwise,
Reviewed-by: Ben Gardon <bgardon@google.com>

> ---
>  tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> index ea0978f22db8..251794f83719 100644
> --- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> +++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> @@ -241,7 +241,7 @@ int main(int argc, char **argv)
>         while ((opt = getopt(argc, argv, "hp:t:r")) != -1) {
>                 switch (opt) {
>                 case 'p':
> -                       reclaim_period_ms = atoi_non_negative("Reclaim period", optarg);
> +                       reclaim_period_ms = atoi_positive("Reclaim period", optarg);
>                         break;
>                 case 't':
>                         token = atoi_paranoid(optarg);
> --
> 2.39.0.314.g84b9a713c41-goog
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch] KVM: selftests: Make reclaim_period_ms input always be positive
  2023-01-10 22:19 ` Ben Gardon
@ 2023-01-11  0:45   ` Vipin Sharma
  0 siblings, 0 replies; 3+ messages in thread
From: Vipin Sharma @ 2023-01-11  0:45 UTC (permalink / raw)
  To: Ben Gardon; +Cc: seanjc, pbonzini, kvm, linux-kernel

On Tue, Jan 10, 2023 at 2:19 PM Ben Gardon <bgardon@google.com> wrote:
>
> On Tue, Jan 10, 2023 at 1:52 PM Vipin Sharma <vipinsh@google.com> wrote:
> >
> > reclaim_period_ms used to be positive only but the commit 0001725d0f9b
> > ("KVM: selftests: Add atoi_positive() and atoi_non_negative() for input
> > validation") incorrectly changed it to non-negative validation.
> >
> > Change validation to allow only positive input.
> >
> > Signed-off-by: Vipin Sharma <vipinsh@google.com>
> > Reported-by: Ben Gardon <bgardon@google.com>
>
> Please add a Fixes: tag:
> Fixes: 0001725d0f9b ("KVM: selftests: Add atoi_positive() and
> atoi_non_negative() for input validation")

Forgot this, I will send v2. Thanks.

>
> But otherwise,
> Reviewed-by: Ben Gardon <bgardon@google.com>
>
> > ---
> >  tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> > index ea0978f22db8..251794f83719 100644
> > --- a/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> > +++ b/tools/testing/selftests/kvm/x86_64/nx_huge_pages_test.c
> > @@ -241,7 +241,7 @@ int main(int argc, char **argv)
> >         while ((opt = getopt(argc, argv, "hp:t:r")) != -1) {
> >                 switch (opt) {
> >                 case 'p':
> > -                       reclaim_period_ms = atoi_non_negative("Reclaim period", optarg);
> > +                       reclaim_period_ms = atoi_positive("Reclaim period", optarg);
> >                         break;
> >                 case 't':
> >                         token = atoi_paranoid(optarg);
> > --
> > 2.39.0.314.g84b9a713c41-goog
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-11  0:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 21:52 [Patch] KVM: selftests: Make reclaim_period_ms input always be positive Vipin Sharma
2023-01-10 22:19 ` Ben Gardon
2023-01-11  0:45   ` Vipin Sharma

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®