⬢ DragonFlyBSD Kernel Audit
DF-4747 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/include/linux/hash.h	2026-06-29 12:51:19.000000000 +0000
+++ b/sys/dev/drm/include/linux/hash.h	2026-10-26 03:34:17.841256251 +0000
@@ -31,9 +31,15 @@
 
 static inline u64 hash_64(u64 val, unsigned int bits)
 {
+	uint32_t h1, h2;
 	u64 ret;
 
-	ret = (uint64_t)hash32_buf(&val, sizeof(val), bits);
+	/* two independent 32-bit hashes concatenated: the old code shifted
+	 * a single 32-bit result right by (64-bits) >= 32, collapsing to
+	 * zero for every bits <= 32 (all chash consumers probe slot 0) */
+	h1 = hash32_buf(&val, sizeof(val), bits);
+	h2 = hash32_buf(&val, sizeof(val), ~bits);
+	ret = ((uint64_t)h1 << 32) | h2;
 
 	return ret >> (64 - bits);
 }