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: <55dd1b47ef7c8dd5518878fc682290825570225d.1743250122.git.houwenlong.hwl@antgroup.com>
Date: Sat, 29 Mar 2025 21:05:26 +0800
From: "Hou Wenlong" <houwenlong.hwl@...group.com>
To: linux-kernel@...r.kernel.org
Cc: "Hou Wenlong" <houwenlong.hwl@...group.com>,
  "Dave Hansen" <dave.hansen@...ux.intel.com>,
  "Andy Lutomirski" <luto@...nel.org>,
  "Peter Zijlstra" <peterz@...radead.org>,
  "Thomas Gleixner" <tglx@...utronix.de>,
  "Ingo Molnar" <mingo@...hat.com>,
  "Borislav Petkov" <bp@...en8.de>,
   <x86@...nel.org>,
  "H. Peter Anvin" <hpa@...or.com>
Subject: [PATCH 3/3] x86/mm: Fix wrong usage of 'MAX_ASID_AVAILABLE' in global ASID allocation

'MAX_ASID_AVAILABLE' represents the maximum valid ASID in the current
definetion, meaning that the available ASID range is [0,
MAX_ASID_AVAILABLE]. So the actual count of available ASIDs is
'MAX_ASID_AVAIABLE + 1'. However, global ASID allocation use this value
as the size of the bitmap, which results in the maximum ASID number
being excluded from global ASID allocation. To address this issue,
redefine the 'MAX_ASID_AVAILABLE' as the count of available ASIDs.

Signed-off-by: Hou Wenlong <houwenlong.hwl@...group.com>
---
 arch/x86/mm/tlb.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
index e9eda296fb0e..0f86c3140fdc 100644
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -102,18 +102,17 @@
 #define CR3_AVAIL_PCID_BITS (X86_CR3_PCID_BITS - PTI_CONSUMED_PCID_BITS)

 /*
- * ASIDs are zero-based: 0->MAX_AVAIL_ASID are valid.  -1 below to account
- * for them being zero-based.  Another -1 is because PCID 0 is reserved for
- * use by non-PCID-aware users.
+ * ASIDs are zero-based: 0->MAX_ASID_AVAILABLE-1 are valid.  -1 is because PCID
+ * 0 is reserved for use by non-PCID-aware users.
  */
-#define MAX_ASID_AVAILABLE ((1 << CR3_AVAIL_PCID_BITS) - 2)
+#define MAX_ASID_AVAILABLE ((1 << CR3_AVAIL_PCID_BITS) - 1)

 /*
  * Given @asid, compute kPCID
  */
 static inline u16 kern_pcid(u16 asid)
 {
-	VM_WARN_ON_ONCE(asid > MAX_ASID_AVAILABLE);
+	VM_WARN_ON_ONCE(asid >= MAX_ASID_AVAILABLE);

 #ifdef CONFIG_MITIGATION_PAGE_TABLE_ISOLATION
 	/*
--
2.31.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ