From: Cyril Hrubis <chrubis@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it, nstange@suse.de
Subject: Re: [LTP] [PATCH 3/5] KVM: Fix infinite loop in ptr2hex()
Date: Wed, 26 Apr 2023 09:57:38 +0200 [thread overview]
Message-ID: <ZEjZcgJMluP0eEie@yuki> (raw)
In-Reply-To: <20230421145746.5704-3-mdoucha@suse.cz>
Hi!
> Contrary to the C standard, (x >> 64) is equivalent to (x >> 0) on x86.
As far as I can tell right shift larger than the left operand size are
undefined, at least in C99.
Other than that the patch looks good.
Reviewed-by: Cyril Hrubis <chrubis@suse.cz>
> This can cause infinite loop in ptr2hex() if the highest nibble
> in the second argument is non-zero. Use temporary variable to avoid
> bit-shifting by large values.
>
> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---
> testcases/kernel/kvm/lib_guest.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/kvm/lib_guest.c b/testcases/kernel/kvm/lib_guest.c
> index d237293fc..d3b2ac3d5 100644
> --- a/testcases/kernel/kvm/lib_guest.c
> +++ b/testcases/kernel/kvm/lib_guest.c
> @@ -82,7 +82,7 @@ char *ptr2hex(char *dest, uintptr_t val)
> uintptr_t tmp;
> char *ret = dest;
>
> - for (i = 4; val >> i; i += 4)
> + for (i = 4, tmp = val >> 4; tmp; i += 4, tmp >>= 4)
> ;
>
> do {
> --
> 2.40.0
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-04-26 7:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-21 14:57 [LTP] [PATCH 1/5] KVM: Add helper functions for accessing GDT/LDT Martin Doucha
2023-04-21 14:57 ` [LTP] [PATCH 2/5] KVM: Add helper function for reading x86 segment registers Martin Doucha
2023-05-02 14:24 ` Petr Vorel
2023-04-21 14:57 ` [LTP] [PATCH 3/5] KVM: Fix infinite loop in ptr2hex() Martin Doucha
2023-04-26 7:57 ` Cyril Hrubis [this message]
2023-04-26 8:09 ` Martin Doucha
2023-05-02 14:26 ` Petr Vorel
2023-05-02 19:46 ` Petr Vorel
2023-04-21 14:57 ` [LTP] [PATCH 4/5] Add KVM helper functions for AMD SVM Martin Doucha
2023-05-02 14:29 ` Petr Vorel
2023-04-21 14:57 ` [LTP] [PATCH 5/5] Add test for CVE 2021-3653 Martin Doucha
2023-04-24 9:09 ` Martin Doucha
2023-05-02 14:32 ` Petr Vorel
2023-05-03 12:42 ` Petr Vorel
2023-04-25 12:48 ` Petr Vorel
2023-04-26 8:08 ` [LTP] [PATCH 1/5] KVM: Add helper functions for accessing GDT/LDT Cyril Hrubis
2023-04-26 9:19 ` Martin Doucha
2023-04-26 9:20 ` Cyril Hrubis
2023-05-02 14:24 ` Petr Vorel
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=ZEjZcgJMluP0eEie@yuki \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=mdoucha@suse.cz \
--cc=nstange@suse.de \
/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