** Changed in: cups (Ubuntu Jammy)
   Importance: Undecided => Medium

** Changed in: cups (Ubuntu Jammy)
       Status: New => In Progress

** Changed in: cups (Ubuntu Jammy)
     Assignee: (unassigned) => Chris Bainbridge (chris-bainbridge)

** Changed in: cups (Ubuntu Noble)
   Importance: Undecided => Medium

** Changed in: cups (Ubuntu Noble)
       Status: New => In Progress

** Changed in: cups (Ubuntu Noble)
     Assignee: (unassigned) => Chris Bainbridge (chris-bainbridge)

** Changed in: cups (Ubuntu Resolute)
   Importance: Undecided => Medium

** Changed in: cups (Ubuntu Resolute)
       Status: New => In Progress

** Changed in: cups (Ubuntu Resolute)
     Assignee: (unassigned) => Chris Bainbridge (chris-bainbridge)

** Changed in: cups (Ubuntu Stonking)
   Importance: Undecided => Medium

** Changed in: cups (Ubuntu Stonking)
       Status: New => In Progress

** Changed in: cups (Ubuntu Stonking)
     Assignee: (unassigned) => Chris Bainbridge (chris-bainbridge)

** 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:
+        lpadmin -p crashy -x
+      (equivalently, let cups-browsed replace a discovered queue).
+    - Stock cupsd aborts with "corrupted double-linked list" (SIGABRT).
+ 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

** Attachment added: "jammy debdiff (2.4.1op1-1ubuntu4.22)"
   
https://bugs.launchpad.net/bugs/2042397/+attachment/6022823/+files/debdiff-jammy.txt

-- 
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

Reply via email to