From 6de32b653c0b435dfce343b40226fc4fdffd5c35 Mon Sep 17 00:00:00 2001 From: baiguo Date: Wed, 12 Jun 2024 08:44:48 +0800 Subject: [PATCH] Fix domain socket handling (cherry picked from commit 62ef24b391923b9a14cc66c17f5ac4224b932a3b) --- backport-Fix-CVE-2024-35235.patch | 95 +++++++++++++++++++++++++++++++ cups.spec | 6 +- 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 backport-Fix-CVE-2024-35235.patch diff --git a/backport-Fix-CVE-2024-35235.patch b/backport-Fix-CVE-2024-35235.patch new file mode 100644 index 0000000..9a41790 --- /dev/null +++ b/backport-Fix-CVE-2024-35235.patch @@ -0,0 +1,95 @@ +From a436956f374b0fd7f5da9df482e4f5840fa1c0d2 Mon Sep 17 00:00:00 2001 +From: Zdenek Dohnal +Date: Mon, 3 Jun 2024 18:53:58 +020 +Subject: [PATCH] Fix domain socket handling +Reference: https://github.com/OpenPrinting/cups/commit/a436956f374b0fd7f5da9df482e4f5840fa1c0d2 + +--- + cups/http-addr.c | 37 +++++++++++++++++++------------------ + scheduler/conf.c | 19 +++++++++++++++++++ + 2 files changed, 38 insertions(+), 18 deletions(-) + +diff --git a/cups/http-addr.c b/cups/http-addr.c +index 254857c..29a821f 100644 +--- a/cups/http-addr.c ++++ b/cups/http-addr.c +@@ -210,27 +210,28 @@ httpAddrListen(http_addr_t *addr, /* I - Address to bind to */ + * Remove any existing domain socket file... + */ + +- unlink(addr->un.sun_path); +- +- /* +- * Save the current umask and set it to 0 so that all users can access +- * the domain socket... +- */ +- +- mask = umask(0); +- +- /* +- * Bind the domain socket... +- */ ++ if ((status = unlink(addr->un.sun_path)) < 0) ++ { ++ DEBUG_printf(("1httpAddrListen: Unable to unlink \"%s\": %s", addr->un.sun_path, strerror(errno))); + +- status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr)); ++ if (errno == ENOENT) ++ status = 0; ++ } + +- /* +- * Restore the umask and fix permissions... +- */ ++ if (!status) ++ { ++ // Save the current umask and set it to 0 so that all users can access ++ // the domain socket... ++ mask = umask(0); ++ // Bind the domain socket... ++ if ((status = bind(fd, (struct sockaddr *)addr, (socklen_t)httpAddrLength(addr))) < 0) ++ { ++ DEBUG_printf(("1httpAddrListen: Unable to bind domain socket \"%s\": %s", addr->un.sun_path, strerror(errno))); ++ } + +- umask(mask); +- chmod(addr->un.sun_path, 0140777); ++ // Restore the umask... ++ umask(mask); ++ } + } + else + #endif /* AF_LOCAL */ +diff --git a/scheduler/conf.c b/scheduler/conf.c +index 4fa7eb1..8e54c47 100644 +--- a/scheduler/conf.c ++++ b/scheduler/conf.c +@@ -3082,6 +3082,25 @@ read_cupsd_conf(cups_file_t *fp) /* I - File to read from */ + + cupsd_listener_t *lis; /* New listeners array */ + ++ /* ++ * If we are launched on-demand, do not use domain sockets from the config ++ * file. Also check that the domain socket path is not too long... ++ */ ++ ++#ifdef HAVE_ONDEMAND ++ if (*value == '/' && OnDemand) ++ { ++ if (strcmp(value, CUPS_DEFAULT_DOMAINSOCKET)) ++ cupsdLogMessage(CUPSD_LOG_INFO, "Ignoring %s address %s at line %d - only using domain socket from launchd/systemd.", line, value, linenum); ++ continue; ++ } ++#endif // HAVE_ONDEMAND ++ ++ if (*value == '/' && strlen(value) > (sizeof(addr->addr.un.sun_path) - 1)) ++ { ++ cupsdLogMessage(CUPSD_LOG_INFO, "Ignoring %s address %s at line %d - too long.", line, value, linenum); ++ continue; ++ } + + /* + * Get the address list... +-- +2.27.0 + diff --git a/cups.spec b/cups.spec index 1e79d16..87edc03 100644 --- a/cups.spec +++ b/cups.spec @@ -3,7 +3,7 @@ Name: cups Epoch: 1 Version: 2.4.7 -Release: 2 +Release: 3 Summary: CUPS is the standards-based, open source printing system for linux operating systems. License: Apache-2.0 Url: https://openprinting.github.io/cups/ @@ -25,6 +25,7 @@ Patch9: cups-ipp-multifile.patch Patch10: cups-web-devices-timeout.patch Patch6004: fix-httpAddrGetList-test-case-fail.patch +Patch6005: backport-Fix-CVE-2024-35235.patch BuildRequires: pam-devel pkgconf-pkg-config pkgconfig(gnutls) libacl-devel openldap-devel pkgconfig(libusb-1.0) BuildRequires: krb5-devel pkgconfig(avahi-client) systemd pkgconfig(libsystemd) pkgconfig(dbus-1) python3-cups @@ -447,6 +448,9 @@ rm -f %{_exec_prefix}/lib/cups/backend/smb %doc %{_datadir}/%{name}/www/apple-touch-icon.png %changelog +* Wed Jun 12 2024 baiguo - 1:2.4.7-3 +- fix CVE-2024-35235 + * Tue Mar 26 2024 zhaojunfei - 1:2.4.7-2 - fix pkgconfig file generating - eliminate deprecated configure parameters -- Gitee