diff options
| author | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-10-07 21:49:36 +0200 |
|---|---|---|
| committer | Gyorgy Sarvari <skandigraun@gmail.com> | 2025-10-13 09:21:31 +0200 |
| commit | 97cd359c296ca0086184c4019f170ac23faf99bd (patch) | |
| tree | eb5e5956b72b7f8ce617d68f66399f2916138163 | |
| parent | 1e7af79e70bc688a842fb0e6621f194c05ffcf68 (diff) | |
| download | meta-openembedded-97cd359c296ca0086184c4019f170ac23faf99bd.tar.gz | |
redis: patch CVE-2025-48367
Details: https://nvd.nist.gov/vuln/detail/CVE-2025-48367
Backport the patch mentioned in the details.
Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com>
4 files changed, 226 insertions, 0 deletions
diff --git a/meta-oe/recipes-extended/redis/redis-7.2.8/0001-Retry-accept-even-if-accepted-connection-reports-an-.patch b/meta-oe/recipes-extended/redis/redis-7.2.8/0001-Retry-accept-even-if-accepted-connection-reports-an-.patch new file mode 100644 index 0000000000..8017345913 --- /dev/null +++ b/meta-oe/recipes-extended/redis/redis-7.2.8/0001-Retry-accept-even-if-accepted-connection-reports-an-.patch | |||
| @@ -0,0 +1,117 @@ | |||
| 1 | From 05524dbadb1acc3d8d75905108fea39cdf43832c Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Ozan Tezcan <ozantezcan@gmail.com> | ||
| 3 | Date: Wed, 14 May 2025 11:02:30 +0300 | ||
| 4 | Subject: [PATCH] Retry accept() even if accepted connection reports an error | ||
| 5 | (CVE-2025-48367) | ||
| 6 | |||
| 7 | In case of accept4() returns an error, we should check errno value and | ||
| 8 | decide if we should retry accept4() without waiting next event loop iteration. | ||
| 9 | |||
| 10 | CVE: CVE-2025-48367 | ||
| 11 | Upstream-Status: Backport [https://github.com/redis/redis/commit/c76d6182096cbe10bd3a1dc41095b5ab422e6a74] | ||
| 12 | |||
| 13 | Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> | ||
| 14 | --- | ||
| 15 | src/anet.c | 24 ++++++++++++++++++++++++ | ||
| 16 | src/anet.h | 1 + | ||
| 17 | src/cluster.c | 2 ++ | ||
| 18 | src/socket.c | 2 ++ | ||
| 19 | src/tls.c | 2 ++ | ||
| 20 | src/unix.c | 2 ++ | ||
| 21 | 6 files changed, 33 insertions(+) | ||
| 22 | |||
| 23 | diff --git a/src/anet.c b/src/anet.c | ||
| 24 | index 64824a2..6c539d5 100644 | ||
| 25 | --- a/src/anet.c | ||
| 26 | +++ b/src/anet.c | ||
| 27 | @@ -704,3 +704,27 @@ int anetIsFifo(char *filepath) { | ||
| 28 | if (stat(filepath, &sb) == -1) return 0; | ||
| 29 | return S_ISFIFO(sb.st_mode); | ||
| 30 | } | ||
| 31 | + | ||
| 32 | +/* This function must be called after accept4() fails. It returns 1 if 'err' | ||
| 33 | + * indicates accepted connection faced an error, and it's okay to continue | ||
| 34 | + * accepting next connection by calling accept4() again. Other errors either | ||
| 35 | + * indicate programming errors, e.g. calling accept() on a closed fd or indicate | ||
| 36 | + * a resource limit has been reached, e.g. -EMFILE, open fd limit has been | ||
| 37 | + * reached. In the latter case, caller might wait until resources are available. | ||
| 38 | + * See accept4() documentation for details. */ | ||
| 39 | +int anetAcceptFailureNeedsRetry(int err) { | ||
| 40 | + if (err == ECONNABORTED) | ||
| 41 | + return 1; | ||
| 42 | + | ||
| 43 | +#if defined(__linux__) | ||
| 44 | + /* For details, see 'Error Handling' section on | ||
| 45 | + * https://man7.org/linux/man-pages/man2/accept.2.html */ | ||
| 46 | + if (err == ENETDOWN || err == EPROTO || err == ENOPROTOOPT || | ||
| 47 | + err == EHOSTDOWN || err == ENONET || err == EHOSTUNREACH || | ||
| 48 | + err == EOPNOTSUPP || err == ENETUNREACH) | ||
| 49 | + { | ||
| 50 | + return 1; | ||
| 51 | + } | ||
| 52 | +#endif | ||
| 53 | + return 0; | ||
| 54 | +} | ||
| 55 | diff --git a/src/anet.h b/src/anet.h | ||
| 56 | index b13c14f..2319039 100644 | ||
| 57 | --- a/src/anet.h | ||
| 58 | +++ b/src/anet.h | ||
| 59 | @@ -71,5 +71,6 @@ int anetPipe(int fds[2], int read_flags, int write_flags); | ||
| 60 | int anetSetSockMarkId(char *err, int fd, uint32_t id); | ||
| 61 | int anetGetError(int fd); | ||
| 62 | int anetIsFifo(char *filepath); | ||
| 63 | +int anetAcceptFailureNeedsRetry(int err); | ||
| 64 | |||
| 65 | #endif | ||
| 66 | diff --git a/src/cluster.c b/src/cluster.c | ||
| 67 | index 765958a..2130ffd 100644 | ||
| 68 | --- a/src/cluster.c | ||
| 69 | +++ b/src/cluster.c | ||
| 70 | @@ -1309,6 +1309,8 @@ void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) { | ||
| 71 | while(max--) { | ||
| 72 | cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); | ||
| 73 | if (cfd == ANET_ERR) { | ||
| 74 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 75 | + continue; | ||
| 76 | if (errno != EWOULDBLOCK) | ||
| 77 | serverLog(LL_VERBOSE, | ||
| 78 | "Error accepting cluster node: %s", server.neterr); | ||
| 79 | diff --git a/src/socket.c b/src/socket.c | ||
| 80 | index dad8e93..09d87bc 100644 | ||
| 81 | --- a/src/socket.c | ||
| 82 | +++ b/src/socket.c | ||
| 83 | @@ -318,6 +318,8 @@ static void connSocketAcceptHandler(aeEventLoop *el, int fd, void *privdata, int | ||
| 84 | while(max--) { | ||
| 85 | cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); | ||
| 86 | if (cfd == ANET_ERR) { | ||
| 87 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 88 | + continue; | ||
| 89 | if (errno != EWOULDBLOCK) | ||
| 90 | serverLog(LL_WARNING, | ||
| 91 | "Accepting client connection: %s", server.neterr); | ||
| 92 | diff --git a/src/tls.c b/src/tls.c | ||
| 93 | index e709c99..9a66e81 100644 | ||
| 94 | --- a/src/tls.c | ||
| 95 | +++ b/src/tls.c | ||
| 96 | @@ -774,6 +774,8 @@ static void tlsAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) | ||
| 97 | while(max--) { | ||
| 98 | cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); | ||
| 99 | if (cfd == ANET_ERR) { | ||
| 100 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 101 | + continue; | ||
| 102 | if (errno != EWOULDBLOCK) | ||
| 103 | serverLog(LL_WARNING, | ||
| 104 | "Accepting client connection: %s", server.neterr); | ||
| 105 | diff --git a/src/unix.c b/src/unix.c | ||
| 106 | index bd146d0..8fdefe4 100644 | ||
| 107 | --- a/src/unix.c | ||
| 108 | +++ b/src/unix.c | ||
| 109 | @@ -100,6 +100,8 @@ static void connUnixAcceptHandler(aeEventLoop *el, int fd, void *privdata, int m | ||
| 110 | while(max--) { | ||
| 111 | cfd = anetUnixAccept(server.neterr, fd); | ||
| 112 | if (cfd == ANET_ERR) { | ||
| 113 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 114 | + continue; | ||
| 115 | if (errno != EWOULDBLOCK) | ||
| 116 | serverLog(LL_WARNING, | ||
| 117 | "Accepting client connection: %s", server.neterr); | ||
diff --git a/meta-oe/recipes-extended/redis/redis/0001-Retry-accept-even-if-accepted-connection-reports-an-.patch b/meta-oe/recipes-extended/redis/redis/0001-Retry-accept-even-if-accepted-connection-reports-an-.patch new file mode 100644 index 0000000000..e16ad07e3e --- /dev/null +++ b/meta-oe/recipes-extended/redis/redis/0001-Retry-accept-even-if-accepted-connection-reports-an-.patch | |||
| @@ -0,0 +1,107 @@ | |||
| 1 | From 5cb320f03b7d619499d2d69f4371096b5d6a9bdf Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Ozan Tezcan <ozantezcan@gmail.com> | ||
| 3 | Date: Wed, 14 May 2025 11:02:30 +0300 | ||
| 4 | Subject: [PATCH] Retry accept() even if accepted connection reports an error | ||
| 5 | (CVE-2025-48367) | ||
| 6 | |||
| 7 | In case of accept4() returns an error, we should check errno value and | ||
| 8 | decide if we should retry accept4() without waiting next event loop iteration. | ||
| 9 | |||
| 10 | CVE: CVE-2025-48367 | ||
| 11 | Upstream-Status: Backport [https://github.com/redis/redis/commit/0fe67435935cc5724ff6eb9c4ca4120c58a15765] | ||
| 12 | |||
| 13 | Signed-off-by: Gyorgy Sarvari <skandigraun@gmail.com> | ||
| 14 | --- | ||
| 15 | src/anet.c | 24 ++++++++++++++++++++++++ | ||
| 16 | src/anet.h | 2 +- | ||
| 17 | src/cluster.c | 2 ++ | ||
| 18 | src/networking.c | 6 ++++++ | ||
| 19 | 4 files changed, 33 insertions(+), 1 deletion(-) | ||
| 20 | |||
| 21 | diff --git a/src/anet.c b/src/anet.c | ||
| 22 | index 91f6171..2e42fc5 100644 | ||
| 23 | --- a/src/anet.c | ||
| 24 | +++ b/src/anet.c | ||
| 25 | @@ -594,3 +594,27 @@ int anetFormatFdAddr(int fd, char *buf, size_t buf_len, int fd_to_str_type) { | ||
| 26 | anetFdToString(fd,ip,sizeof(ip),&port,fd_to_str_type); | ||
| 27 | return anetFormatAddr(buf, buf_len, ip, port); | ||
| 28 | } | ||
| 29 | + | ||
| 30 | +/* This function must be called after accept4() fails. It returns 1 if 'err' | ||
| 31 | + * indicates accepted connection faced an error, and it's okay to continue | ||
| 32 | + * accepting next connection by calling accept4() again. Other errors either | ||
| 33 | + * indicate programming errors, e.g. calling accept() on a closed fd or indicate | ||
| 34 | + * a resource limit has been reached, e.g. -EMFILE, open fd limit has been | ||
| 35 | + * reached. In the latter case, caller might wait until resources are available. | ||
| 36 | + * See accept4() documentation for details. */ | ||
| 37 | +int anetAcceptFailureNeedsRetry(int err) { | ||
| 38 | + if (err == ECONNABORTED) | ||
| 39 | + return 1; | ||
| 40 | + | ||
| 41 | +#if defined(__linux__) | ||
| 42 | + /* For details, see 'Error Handling' section on | ||
| 43 | + * https://man7.org/linux/man-pages/man2/accept.2.html */ | ||
| 44 | + if (err == ENETDOWN || err == EPROTO || err == ENOPROTOOPT || | ||
| 45 | + err == EHOSTDOWN || err == ENONET || err == EHOSTUNREACH || | ||
| 46 | + err == EOPNOTSUPP || err == ENETUNREACH) | ||
| 47 | + { | ||
| 48 | + return 1; | ||
| 49 | + } | ||
| 50 | +#endif | ||
| 51 | + return 0; | ||
| 52 | +} | ||
| 53 | diff --git a/src/anet.h b/src/anet.h | ||
| 54 | index 2a685cc..adedaf3 100644 | ||
| 55 | --- a/src/anet.h | ||
| 56 | +++ b/src/anet.h | ||
| 57 | @@ -72,5 +72,5 @@ int anetFdToString(int fd, char *ip, size_t ip_len, int *port, int fd_to_str_typ | ||
| 58 | int anetKeepAlive(char *err, int fd, int interval); | ||
| 59 | int anetFormatAddr(char *fmt, size_t fmt_len, char *ip, int port); | ||
| 60 | int anetFormatFdAddr(int fd, char *buf, size_t buf_len, int fd_to_str_type); | ||
| 61 | - | ||
| 62 | +int anetAcceptFailureNeedsRetry(int err); | ||
| 63 | #endif | ||
| 64 | diff --git a/src/cluster.c b/src/cluster.c | ||
| 65 | index 8807fe2..030897c 100644 | ||
| 66 | --- a/src/cluster.c | ||
| 67 | +++ b/src/cluster.c | ||
| 68 | @@ -691,6 +691,8 @@ void clusterAcceptHandler(aeEventLoop *el, int fd, void *privdata, int mask) { | ||
| 69 | while(max--) { | ||
| 70 | cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); | ||
| 71 | if (cfd == ANET_ERR) { | ||
| 72 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 73 | + continue; | ||
| 74 | if (errno != EWOULDBLOCK) | ||
| 75 | serverLog(LL_VERBOSE, | ||
| 76 | "Error accepting cluster node: %s", server.neterr); | ||
| 77 | diff --git a/src/networking.c b/src/networking.c | ||
| 78 | index 11891d3..2598a58 100644 | ||
| 79 | --- a/src/networking.c | ||
| 80 | +++ b/src/networking.c | ||
| 81 | @@ -1190,6 +1190,8 @@ void acceptTcpHandler(aeEventLoop *el, int fd, void *privdata, int mask) { | ||
| 82 | while(max--) { | ||
| 83 | cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); | ||
| 84 | if (cfd == ANET_ERR) { | ||
| 85 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 86 | + continue; | ||
| 87 | if (errno != EWOULDBLOCK) | ||
| 88 | serverLog(LL_WARNING, | ||
| 89 | "Accepting client connection: %s", server.neterr); | ||
| 90 | @@ -1211,6 +1213,8 @@ void acceptTLSHandler(aeEventLoop *el, int fd, void *privdata, int mask) { | ||
| 91 | while(max--) { | ||
| 92 | cfd = anetTcpAccept(server.neterr, fd, cip, sizeof(cip), &cport); | ||
| 93 | if (cfd == ANET_ERR) { | ||
| 94 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 95 | + continue; | ||
| 96 | if (errno != EWOULDBLOCK) | ||
| 97 | serverLog(LL_WARNING, | ||
| 98 | "Accepting client connection: %s", server.neterr); | ||
| 99 | @@ -1231,6 +1235,8 @@ void acceptUnixHandler(aeEventLoop *el, int fd, void *privdata, int mask) { | ||
| 100 | while(max--) { | ||
| 101 | cfd = anetUnixAccept(server.neterr, fd); | ||
| 102 | if (cfd == ANET_ERR) { | ||
| 103 | + if (anetAcceptFailureNeedsRetry(errno)) | ||
| 104 | + continue; | ||
| 105 | if (errno != EWOULDBLOCK) | ||
| 106 | serverLog(LL_WARNING, | ||
| 107 | "Accepting client connection: %s", server.neterr); | ||
diff --git a/meta-oe/recipes-extended/redis/redis_6.2.18.bb b/meta-oe/recipes-extended/redis/redis_6.2.18.bb index 9ce476e14e..5e3b8d4430 100644 --- a/meta-oe/recipes-extended/redis/redis_6.2.18.bb +++ b/meta-oe/recipes-extended/redis/redis_6.2.18.bb | |||
| @@ -18,6 +18,7 @@ SRC_URI = "http://download.redis.io/releases/${BP}.tar.gz \ | |||
| 18 | file://0006-Define-correct-gregs-for-RISCV32.patch \ | 18 | file://0006-Define-correct-gregs-for-RISCV32.patch \ |
| 19 | file://0001-CVE-2025-27151.patch \ | 19 | file://0001-CVE-2025-27151.patch \ |
| 20 | file://0001-Fix-out-of-bounds-write-in-hyperloglog-commands-CVE-.patch \ | 20 | file://0001-Fix-out-of-bounds-write-in-hyperloglog-commands-CVE-.patch \ |
| 21 | file://0001-Retry-accept-even-if-accepted-connection-reports-an-.patch \ | ||
| 21 | " | 22 | " |
| 22 | 23 | ||
| 23 | SRC_URI[sha256sum] = "470c75bac73d7390be4dd66479c6f29e86371c5d380ce0c7efb4ba2bbda3612d" | 24 | SRC_URI[sha256sum] = "470c75bac73d7390be4dd66479c6f29e86371c5d380ce0c7efb4ba2bbda3612d" |
diff --git a/meta-oe/recipes-extended/redis/redis_7.2.8.bb b/meta-oe/recipes-extended/redis/redis_7.2.8.bb index f5ea3eaf5b..22f48afd17 100644 --- a/meta-oe/recipes-extended/redis/redis_7.2.8.bb +++ b/meta-oe/recipes-extended/redis/redis_7.2.8.bb | |||
| @@ -18,6 +18,7 @@ SRC_URI = "http://download.redis.io/releases/${BP}.tar.gz \ | |||
| 18 | file://0006-Define-correct-gregs-for-RISCV32.patch \ | 18 | file://0006-Define-correct-gregs-for-RISCV32.patch \ |
| 19 | file://0001-Check-length-of-AOF-file-name-in-redis-check-aof-CVE.patch \ | 19 | file://0001-Check-length-of-AOF-file-name-in-redis-check-aof-CVE.patch \ |
| 20 | file://0001-Fix-out-of-bounds-write-in-hyperloglog-commands-CVE-.patch \ | 20 | file://0001-Fix-out-of-bounds-write-in-hyperloglog-commands-CVE-.patch \ |
| 21 | file://0001-Retry-accept-even-if-accepted-connection-reports-an-.patch \ | ||
| 21 | " | 22 | " |
| 22 | 23 | ||
| 23 | SRC_URI[sha256sum] = "6be4fdfcdb2e5ac91454438246d00842d2671f792673390e742dfcaf1bf01574" | 24 | SRC_URI[sha256sum] = "6be4fdfcdb2e5ac91454438246d00842d2671f792673390e742dfcaf1bf01574" |
