Note that you can create a test printer for this with the following
command. After a successful print, you should see the job sitting in the
queue. After a crash, it's not visible in the queue because it crashes
before submission.
```
# Create the test queue (no sudo needed if you're in the lpadmin group)
lpadmin -p gtk-authtest -E -v ipp://127.0.0.1:1/ipp/print \
-o auth-info-required=username,password
# Check
lpoptions -p gtk-authtest | tr ' ' '\n' | grep auth-info-required
```
** Description changed:
[ Impact ]
Printing to a CUPS printer that requires a username and password, with
the "Remember password" box ticked in the authentication dialog, crashes
- the process that shows the dialog. When printing from a GTK 4 app
- through the system print dialog, that is xdg-desktop-portal-gnome, and
- the print job is lost.
+ the process that shows the dialog. This loses the print job.
This is the follow-up to LP: #2168749. That bug's fix (upstream
8eec1cb8af, in 4.22.4+ds-0ubuntu0.2) removed the extra reference drop in
the lookup callback. The same mistake remains in the callback that runs
after the credentials have been stored, store_done_cb() in
gtk/print/backends/gtkcupssecretsutils.c. It also unrefs a GTask it
doesn't own. The task is freed while GTask is still returning it, and
create_item_cb() then unrefs freed memory. The credentials are saved
before the crash.
With 4.22.4+ds-0ubuntu0.1 this crash wasn't reachable, because the
lookup crash from LP: #2168749 happened first. With 0ubuntu0.2 it is the
next crash users hit, as soon as they tick "Remember password".
Upstream fix: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/10720
(merged to main as 0b51358529, "cups: Fix task ownership in store
callback"). It removes the single g_object_unref() call from
store_done_cb(). Stable backports:
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/10736 (gtk-4-24) and
https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/10737 (gtk-4-22,
together with 8eec1cb8af).
[ Test Plan ]
1. Log in to Ubuntu Desktop.
2. Configure a CUPS printer that advertises
auth-info-required=username,password (for example an SMB printer that needs
credentials). Make sure no credentials for it are stored in the login keyring
("Passwords and Keys", or the Secret Service).
3. Print a document from a GTK 4 app through the system dialog (for example
Papers).
4. In the authentication dialog, enter the username and password, tick
"Remember password", and press OK.
5. Verify that the document is printed and that you received no crash
notification.
6. Verify that the credentials are stored in the login keyring, under the
printer's ipp://localhost:631/printers/<name> URI.
7. Print again. Verify that no authentication dialog appears, the stored
credentials are used, and the document is printed.
Without the fix, step 4 crashes xdg-desktop-portal-gnome (SIGSEGV) and
the document is not printed. The credentials are stored before the
crash, so going by the code the next print should use them and work. In
practice users see a crash and a lost job right after asking to remember
their password.
[ Where problems could occur ]
The patch removes one call that decreases the reference count of a
GTask. If the change were wrong, the effect would be a leak of that
GTask once per credential store, not a crash. The patch only touches the
code path that runs after credentials have been stored in the Secret
Service.
[ Other Info ]
Tested on Ubuntu 26.04 with gtk-4-22 plus 8eec1cb8af plus this fix:
- Under AddressSanitizer with a test CUPS queue: credentials stored, stored
credentials used on the next print, no ASan errors.
- End to end: Papers, through xdg-desktop-portal-gnome running against that
build, printing to a university SMB printer that needs authentication. The
password was stored and the page printed; the next print used the stored
credentials without asking and printed too.
- The crash itself (without the fix) is confirmed under AddressSanitizer on
GTK main and gtk-4-24, which have the same code:
- ERROR: AddressSanitizer: heap-use-after-free
- #1 g_object_unref gobject/gobject.c:4749
- #2 create_item_cb gtkcupssecretsutils.c:273
- freed by thread T0 here:
- #3 g_object_unref gobject/gobject.c:4926
- #4 g_task_return gio/gtask.c:1437
- #5 g_task_return_pointer gio/gtask.c:1878
- #6 create_item_cb gtkcupssecretsutils.c:272
+ ERROR: AddressSanitizer: heap-use-after-free
+ #1 g_object_unref gobject/gobject.c:4749
+ #2 create_item_cb gtkcupssecretsutils.c:273
+ freed by thread T0 here:
+ #3 g_object_unref gobject/gobject.c:4926
+ #4 g_task_return gio/gtask.c:1437
+ #5 g_task_return_pointer gio/gtask.c:1878
+ #6 create_item_cb gtkcupssecretsutils.c:272
Note: I used AI to help investigate this bug and write this report; I
ran the tests myself.
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2174771
Title:
Crash when saving credentials for a printer ("Remember password")
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gtk4/+bug/2174771/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs