[AUTO-CHERRYPICK] grpc: Address CVE-2023-32067 - branch main (#11605)

Co-authored-by: Ankita Pareek <56152556+Ankita13-code@users.noreply.github.com>
This commit is contained in:
nicolas guibourge 2024-12-20 21:35:34 +01:00 коммит произвёл GitHub
Родитель fbb226eed6
Коммит 4703a43086
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 86 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,79 @@
From b9b8413cfdb70a3f99e1573333b23052d57ec1ae Mon Sep 17 00:00:00 2001
From: Brad House <brad@brad-house.com>
Date: Mon, 22 May 2023 06:51:49 -0400
Subject: [PATCH] Merge pull request from GHSA-9g78-jv2r-p7vc
---
third_party/cares/cares/ares_process.c | 41 +++++++++++++++++++++++++----------------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/third_party/cares/cares/ares_process.c b/third_party/cares/cares/ares_process.c
index bf0cde4646..6cac0a99fd 100644
--- a/third_party/cares/cares/ares_process.c
+++ b/third_party/cares/cares/ares_process.c
@@ -470,7 +470,7 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
{
struct server_state *server;
int i;
- ares_ssize_t count;
+ ares_ssize_t read_len;
unsigned char buf[MAXENDSSZ + 1];
#ifdef HAVE_RECVFROM
ares_socklen_t fromlen;
@@ -513,32 +513,41 @@ static void read_udp_packets(ares_channel channel, fd_set *read_fds,
/* To reduce event loop overhead, read and process as many
* packets as we can. */
do {
- if (server->udp_socket == ARES_SOCKET_BAD)
- count = 0;
-
- else {
- if (server->addr.family == AF_INET)
+ if (server->udp_socket == ARES_SOCKET_BAD) {
+ read_len = -1;
+ } else {
+ if (server->addr.family == AF_INET) {
fromlen = sizeof(from.sa4);
- else
+ } else {
fromlen = sizeof(from.sa6);
- count = socket_recvfrom(channel, server->udp_socket, (void *)buf,
- sizeof(buf), 0, &from.sa, &fromlen);
+ }
+ read_len = socket_recvfrom(channel, server->udp_socket, (void *)buf,
+ sizeof(buf), 0, &from.sa, &fromlen);
}
- if (count == -1 && try_again(SOCKERRNO))
+ if (read_len == 0) {
+ /* UDP is connectionless, so result code of 0 is a 0-length UDP
+ * packet, and not an indication the connection is closed like on
+ * tcp */
continue;
- else if (count <= 0)
+ } else if (read_len < 0) {
+ if (try_again(SOCKERRNO))
+ continue;
+
handle_error(channel, i, now);
+
#ifdef HAVE_RECVFROM
- else if (!same_address(&from.sa, &server->addr))
+ } else if (!same_address(&from.sa, &server->addr)) {
/* The address the response comes from does not match the address we
* sent the request to. Someone may be attempting to perform a cache
* poisoning attack. */
- break;
+ continue;
#endif
- else
- process_answer(channel, buf, (int)count, i, 0, now);
- } while (count > 0);
+
+ } else {
+ process_answer(channel, buf, (int)read_len, i, 0, now);
+ }
+ } while (read_len >= 0);
}
}

Просмотреть файл

@ -1,7 +1,7 @@
Summary: Open source remote procedure call (RPC) framework
Name: grpc
Version: 1.42.0
Release: 7%{?dist}
Release: 8%{?dist}
License: ASL 2.0
Vendor: Microsoft Corporation
Distribution: Mariner
@ -9,6 +9,8 @@ Group: Applications/System
URL: https://www.grpc.io
Source0: https://github.com/grpc/grpc/archive/v%{version}/%{name}-%{version}.tar.gz
Source1: %{name}-%{version}-submodules.tar.gz
Patch0: CVE-2023-32067.patch
BuildRequires: abseil-cpp-devel
BuildRequires: c-ares-devel
BuildRequires: cmake
@ -69,6 +71,7 @@ Python language bindings for gRPC.
%prep
%setup -q -n %{name}-%{version}
%setup -T -D -a 1
%autopatch -p1
%build
# Updating used C++ version to be compatible with the build dependencies.
@ -148,6 +151,9 @@ export GRPC_PYTHON_BUILD_SYSTEM_ABSL=True
%changelog
* Mon Dec 10 2024 Ankita Pareek <ankitapareek@microsoft.com> - 1.42.0-8
- Address CVE-2023-32067 in the grpc submodules package
* Thu Oct 19 2023 Dan Streetman <ddstreet@ieee.org> - 1.42.0-7
- Bump release to rebuild with updated version of Go.