new file mode 100644
@@ -0,0 +1,61 @@
+From b45a29badd76b3cbca4a5e6682adad1d887de92e Mon Sep 17 00:00:00 2001
+From: Brandon <breakouttradersc@gmail.com>
+Date: Fri, 25 Sep 2026 03:39:06 -0400
+Subject: [PATCH] Prefer getentropy() over arc4random() to seed the string hash
+ (#3629)
+
+glibc's arc4random() aborts with "Fatal glibc error: cannot get entropy
+for arc4random" when the kernel lacks getrandom(2), so jq died on
+startup on older kernels once 0c7d133 began seeding the hash on every
+run. getentropy() merely returns -1/ENOSYS there, so prefer it, and
+route its failure through the existing `/dev/urandom` path - which works
+on precisely those kernels -- instead of a guessable `getpid() ^ time()`.
+
+CVE: CVE-2026-40164
+Upstream-Status: Backport [https://github.com/jqlang/jq/commit/32580f5d83f4321588a1ebf8e3893f7fbecefe4e]
+
+Signed-off-by: Devansh Patel <devanshp@cisco.com>
+---
+ src/jv.c | 19 ++++++++++++-------
+ 1 file changed, 12 insertions(+), 7 deletions(-)
+
+diff --git a/src/jv.c b/src/jv.c
+index fdb2c72d53e8be74eb0e7013552fdfb4f90adf59..3211e8eaa9df75a278733c69ae8481b304070e31 100644
+--- a/src/jv.c
++++ b/src/jv.c
+@@ -1230,12 +1230,18 @@ static pthread_once_t hash_seed_once = PTHREAD_ONCE_INIT;
+
+ static void jvp_hash_seed_init(void) {
+ uint32_t seed;
+-#if defined(HAVE_ARC4RANDOM)
+- seed = arc4random();
+-#elif defined(HAVE_GETENTROPY)
+- if (getentropy(&seed, sizeof(seed)) != 0)
+- seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
+-#else
++ /* Prefer getentropy() over arc4random(): glibc's arc4random() aborts the
++ * process when the kernel lacks getrandom(2) (#3584), while getentropy()
++ * merely fails, letting us fall back to /dev/urandom. */
++#if defined(HAVE_GETENTROPY)
++ if (getentropy(&seed, sizeof(seed)) == 0) {
++ hash_seed = seed;
++ return;
++ }
++#elif defined(HAVE_ARC4RANDOM)
++ hash_seed = arc4random();
++ return;
++#endif
+ int fd = open("/dev/urandom", O_RDONLY);
+ if (fd >= 0) {
+ if (read(fd, &seed, sizeof(seed)) != 4)
+@@ -1244,7 +1250,6 @@ static void jvp_hash_seed_init(void) {
+ } else {
+ seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
+ }
+-#endif
+ hash_seed = seed;
+ }
+
+--
+2.35.6
+
new file mode 100644
@@ -0,0 +1,91 @@
+From 48386cda5636fbf51c9cc77ffbc29948e22d225a Mon Sep 17 00:00:00 2001
+From: itchyny <itchyny@cybozu.co.jp>
+Date: Mon, 13 Apr 2026 08:53:26 +0900
+Subject: [PATCH] Randomize hash seed to mitigate hash collision DoS attacks
+
+The hash function used a fixed seed, allowing attackers to craft colliding keys
+and cause O(n^2) object parsing performance. Initialize the seed from a random
+source at process startup to prevent the attack. This fixes CVE-2026-40164.
+
+CVE: CVE-2026-40164
+Upstream-Status: Backport [https://github.com/jqlang/jq/commit/0c7d133c3c7e37c00b6d46b658a02244fdd3c784]
+
+Co-authored-by: Asaf Meizner <asafmeizner@gmail.com>
+Signed-off-by: Devansh Patel <devanshp@cisco.com>
+---
+ configure.ac | 2 ++
+ src/jv.c | 34 ++++++++++++++++++++++++++++++++--
+ 2 files changed, 34 insertions(+), 2 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index bc1d273..c0bc5d6 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -143,6 +143,8 @@ AC_CHECK_MEMBER([struct tm.tm_gmtoff], [AC_DEFINE([HAVE_TM_TM_GMT_OFF],1,[Define
+ AC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])],
+ [], [[#include <time.h>]])
+ AC_FIND_FUNC([setlocale], [c], [#include <locale.h>], [0,0])
++AC_FIND_FUNC([arc4random], [c], [#include <stdlib.h>], [])
++AC_FIND_FUNC([getentropy], [c], [#include <unistd.h>], [0, 0])
+
+ dnl Figure out if we have the pthread functions we actually need
+ AC_FIND_FUNC_NO_LIBS([pthread_key_create], [], [#include <pthread.h>], [NULL, NULL])
+diff --git a/src/jv.c b/src/jv.c
+index 76c70c2..fdb2c72 100644
+--- a/src/jv.c
++++ b/src/jv.c
+@@ -40,6 +40,10 @@
+ #include <limits.h>
+ #include <math.h>
+ #include <float.h>
++#include <time.h>
++#include <unistd.h>
++#include <fcntl.h>
++#include <pthread.h>
+
+ #include "jv_alloc.h"
+ #include "jv.h"
+@@ -1221,7 +1225,33 @@ static jv jvp_string_append(jv string, const char* data, uint32_t len) {
+ }
+ }
+
+-static const uint32_t HASH_SEED = 0x432A9843;
++static uint32_t hash_seed;
++static pthread_once_t hash_seed_once = PTHREAD_ONCE_INIT;
++
++static void jvp_hash_seed_init(void) {
++ uint32_t seed;
++#if defined(HAVE_ARC4RANDOM)
++ seed = arc4random();
++#elif defined(HAVE_GETENTROPY)
++ if (getentropy(&seed, sizeof(seed)) != 0)
++ seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
++#else
++ int fd = open("/dev/urandom", O_RDONLY);
++ if (fd >= 0) {
++ if (read(fd, &seed, sizeof(seed)) != 4)
++ seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
++ close(fd);
++ } else {
++ seed = (uint32_t)getpid() ^ (uint32_t)time(NULL);
++ }
++#endif
++ hash_seed = seed;
++}
++
++static uint32_t jvp_hash_seed(void) {
++ pthread_once(&hash_seed_once, jvp_hash_seed_init);
++ return hash_seed;
++}
+
+ static uint32_t rotl32 (uint32_t x, int8_t r){
+ return (x << r) | (x >> (32 - r));
+@@ -1240,7 +1270,7 @@ static uint32_t jvp_string_hash(jv jstr) {
+ int len = (int)jvp_string_length(str);
+ const int nblocks = len / 4;
+
+- uint32_t h1 = HASH_SEED;
++ uint32_t h1 = jvp_hash_seed();
+
+ const uint32_t c1 = 0xcc9e2d51;
+ const uint32_t c2 = 0x1b873593;
@@ -28,6 +28,8 @@ SRC_URI = "git://github.com/jqlang/jq.git;protocol=https;branch=master;tag=jq-${
file://CVE-2026-49839.patch \
file://CVE-2026-54679.patch \
file://CVE-2026-39956.patch \
+ file://CVE-2026-40164.patch \
+ file://CVE-2026-40164-follow-up.patch \
"
CVE_STATUS[CVE-2025-49014] = "fixed-version: fixed in v1.8.1"