lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <da8581c8-3d56-454b-bddb-e523a983cb44@moroto.mountain>
Date: Thu, 23 May 2024 18:35:02 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: Colin Ian King <colin.i.king@...il.com>
Cc: Sean Christopherson <seanjc@...gle.com>,
	Paolo Bonzini <pbonzini@...hat.com>, Shuah Khan <shuah@...nel.org>,
	kvm@...r.kernel.org, linux-kselftest@...r.kernel.org,
	kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] selftests: kvm: fix shift of 32 bit unsigned int
 more than 32 bits

On Thu, May 23, 2024 at 12:38:02PM +0100, Colin Ian King wrote:
> Currrentl a 32 bit 1u value is being shifted more than 32 bits causing
> overflow and incorrect checking of bits 32-63. Fix this by using the
> BIT_ULL macro for shifting bits.
> 
> Detected by cppcheck:
> sev_init2_tests.c:108:34: error: Shifting 32-bit value by 63 bits is
> undefined behaviour [shiftTooManyBits]
> 
> Fixes: dfc083a181ba ("selftests: kvm: add tests for KVM_SEV_INIT2")
> Signed-off-by: Colin Ian King <colin.i.king@...il.com>
> ---
>  tools/testing/selftests/kvm/x86_64/sev_init2_tests.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c b/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c
> index 7a4a61be119b..ea09f7a06aa4 100644
> --- a/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c
> +++ b/tools/testing/selftests/kvm/x86_64/sev_init2_tests.c
> @@ -105,11 +105,11 @@ void test_features(uint32_t vm_type, uint64_t supported_features)
>  	int i;
>  
>  	for (i = 0; i < 64; i++) {
> -		if (!(supported_features & (1u << i)))
> +		if (!(supported_features & BIT_ULL(i)))
>  			test_init2_invalid(vm_type,
>  				&(struct kvm_sev_init){ .vmsa_features = BIT_ULL(i) },
>  				"unknown feature");
> -		else if (KNOWN_FEATURES & (1u << i))
> +		else if (KNOWN_FEATURES & BIT_ULL(u))
                                                  ^
Should be i.  How does this build?  :P

regards,
dan carpenter


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ