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-next>] [day] [month] [year] [list]
Message-ID: <20190521132200.2b45c029@imladris.surriel.com>
Date:   Tue, 21 May 2019 13:22:00 -0400
From:   Rik van Riel <riel@...riel.com>
To:     "Paolo Bonzini" <pbonzini@...hat.com>
Cc:     kernel-team@...com, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        "Radim Krčmář" <rkrcmar@...hat.com>
Subject: [PATCH] kvm: change KVM_REQUEST_MASK to reflect vcpu.requests size

The code using KVM_REQUEST_MASK uses a pattern reminiscent of a bitmask:

	set_bit(req & KVM_REQUEST_MASK, &vcpu->requests);

However, the first argument passed to set_bit, test_bit, and clear_bit
is a bit number, not a bitmask. That means the current definition would
allow users of kvm_make_request to overflow the vcpu.requests bitmask,
and is confusing to developers examining the code.

Redefine KVM_REQUEST_MASK to reflect the number of bits that actually
fit inside an unsigned long, and add a comment explaining set_bit and
friends take bit numbers, not a bitmask.

Signed-off-by: Rik van Riel <riel@...riel.com>
---
 include/linux/kvm_host.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
index 79fa4426509c..d15fb43d7796 100644
--- a/include/linux/kvm_host.h
+++ b/include/linux/kvm_host.h
@@ -138,7 +138,8 @@ static inline bool is_error_page(struct page *page)
 	return IS_ERR(page);
 }
 
-#define KVM_REQUEST_MASK           GENMASK(7,0)
+/* Limit the bit numbers for set_bit etc to fit unsigned long vcpu.requests. */
+#define KVM_REQUEST_MASK           (BITS_PER_LONG-1)
 #define KVM_REQUEST_NO_WAKEUP      BIT(8)
 #define KVM_REQUEST_WAIT           BIT(9)
 /*

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ