Attaching the stonking debdiff: cups 2.4.16-1ubuntu3 -> 2.4.16-1ubuntu3.1.
** Attachment added: "stonking debdiff (2.4.16-1ubuntu3.1)" https://bugs.launchpad.net/bugs/2042397/+attachment/6022826/+files/debdiff-stonking.txt ** Tags added: desktop-needs-sru noble resolute stonking ** Description changed: The Ubuntu Error Tracker has been receiving reports about a problem regarding cups. This problem was most recently seen with package version 2.4.6-0ubuntu3, the problem page at https://errors.ubuntu.com/problem/a8a50d83f4b4d9621dd706ee4b339b096aa86a70 contains more details, including versions of packages affected, stacktrace or traceback, and individual crash reports. If you do not have access to the Ubuntu Error Tracker and are a software developer, you can request it at http://forms.canonical.com/reports/. -------- [ Impact ] cupsd aborts with "corrupted double-linked list" when a driverless (IPP Everywhere) queue is deleted while its PPD is still being generated in the background. This is one of the most frequent crashes reported to errors.ubuntu.com (thousands of reports since 2023). A user on a network with printers sees cupsd restart, and because cups.service is required by cups-browsed, printing is unavailable for about 90 seconds while cups-browsed times out, plus an "Ubuntu has experienced an internal error" dialog. Root cause: create_local_bg_thread() keeps using the printer for the whole run of the thread. cupsdDeletePrinter() (explicit CUPS-Delete-Printer, as cups-browsed issues when it replaces a discovered queue) and cupsdDeleteTemporaryPrinters() (idle temporary-queue timeout) freed the printer without checking that the thread still referenced it. The thread then takes printer->lock, which sits at the start of the freed allocation and overlaps the malloc free-list pointers; the next allocation anywhere in cupsd aborts the process. The fix is a printer reference count: cupsdAddPrinter() starts with one reference, the code that spawns the background thread takes another, the thread drops it on every exit path, and cupsdDeletePrinter() defers the free while references remain. This is the upstream fix (CUPS commits 807e99c3dc, eb06fe2bf2c and 2074ceb2a93, first released in 2.4.20). The development release (27.04) already has CUPS 2.4.20 and is fixed. [ Test Plan ] 1. Install the proposed cups-daemon from -proposed (or the PPA). - 2. Reproduce the race on the stock (pre-fix) package: - - Create a queue for an unreachable driverless device, for example: - lpadmin -p crashy -E -v ipp://10.255.255.1/ipp/print -m everywhere - - The scheduler starts "Generating PPD file ..." in the background and - waits on the connection (30 s timeout). - - Delete the queue while that message is in /var/log/cups/error_log: + 2. Reproduce the race on the stock (pre-fix) package. Run a listener that + accepts the IPP request and closes the connection after a delay, so the + background PPD thread is still running when the queue is deleted: + python3 -c 'import socket, time + s = socket.socket() + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.bind(("127.0.0.1", 8631)) + s.listen(1) + c, _ = s.accept() + c.recv(65536) + time.sleep(5) + c.close()' + Then create the queue and delete it while the request is pending: + lpadmin -p crashy -E -v ipp://127.0.0.1:8631/ipp/print -m everywhere + # wait for "Generating PPD file" in /var/log/cups/error_log lpadmin -p crashy -x - (equivalently, let cups-browsed replace a discovered queue). - - Stock cupsd aborts with "corrupted double-linked list" (SIGABRT). + Stock cupsd aborts with "corrupted double-linked list" when the + connection closes and the background thread takes the freed printer's + lock (SIGABRT). The same sequence happens when cups-browsed replaces a + discovered queue. 3. Repeat the same sequence with the proposed package. cupsd must stay running, the queue must be gone after the delete (or reaped once the thread exits), and error_log must not contain an abort. 4. Functional check with a real or emulated printer: - Run ippeveprinter (or use a real IPP Everywhere printer) and add a queue with "lpadmin -p test -E -v ipp://... -m everywhere". - Confirm the PPD is generated and the printer reaches idle. - Print a file (lp -d test) and confirm the job completes. - Delete the queue and confirm cupsd stays up. 5. With cups-browsed enabled on a network with a discovered printer, leave the system running and confirm there are no cupsd aborts. [ Where problems could occur ] - Printer reference counting is central scheduler bookkeeping. An incorrect count can leak a queue (it never expires or cannot be deleted) or free it early (the original crash). The backport keeps the upstream structure and releases the reference on every exit path of the background thread. - cupsdDeletePrinter() can now return without freeing the printer when another reference remains. The deferred queue is reaped by the next cupsdDeleteTemporaryPrinters() pass, which now also collects any printer whose reference count reached zero. Callers that delete a queue they just created (error paths in add_printer) still hold only the base reference and are deleted immediately as before. - The jammy version uses a small helper (local_bg_thread_done()) because its thread has several return points instead of a common finish label; future exit paths must use the helper. - No changes to job submission, filters or PPD parsing. Risk is limited to driverless queue creation and deletion. [ Other Info ] - Upstream issues: https://github.com/OpenPrinting/cups/issues/1655 and https://github.com/OpenPrinting/cups/issues/1722 - Upstream commits (2.4.x): 807e99c3dc, eb06fe2bf2c, 2074ceb2a93; released in CUPS 2.4.20. - The development release (27.04) has cups 2.4.20-1ubuntu1 and is fixed. - The fix is d/p/9200-fix-printer-use-after-free-background-ppd.patch in all four source packages. Per-series debdiffs are attached. - No CVE was assigned; this is an availability bug. The explicit-delete path requires print admin rights (cups-browsed runs as root) and CUPS-Create-Local-Printer is limited to local clients, so it is not treated as a security vulnerability. - Related crash report with the same assertion: https://bugs.launchpad.net/ubuntu/+source/cups/+bug/2085091 -- You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. https://bugs.launchpad.net/bugs/2042397 Title: /usr/sbin/cupsd:corrupted double-linked list To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/cups/+bug/2042397/+subscriptions -- ubuntu-bugs mailing list [email protected] https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs
