After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 751038 - luks_delete_passphrase_cb(): gvfs-udisks2-volume-monitor killed by SIGSEGV
luks_delete_passphrase_cb(): gvfs-udisks2-volume-monitor killed by SIGSEGV
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: udisks2 volume monitor
git master
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2015-06-16 12:22 UTC by Ondrej Holy
Modified: 2015-08-06 06:15 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Do not clear passphrase if cancelled (1.29 KB, patch)
2015-06-16 12:37 UTC, Ondrej Holy
none Details | Review
udisks: Handle libsecret error properly (1.10 KB, patch)
2015-06-22 07:06 UTC, Ross Lagerwall
committed Details | Review
udisks2: Do not call secret_password_clear_if_cancelled (1.30 KB, patch)
2015-06-24 07:31 UTC, Ondrej Holy
none Details | Review

Description Ondrej Holy 2015-06-16 12:22:38 UTC
Backtrace:
 #0 luks_delete_passphrase_cb at gvfsudisks2volume.c:1132
 #1 g_simple_async_result_complete at gsimpleasyncresult.c:763
 #2 on_delete_searched at libsecret/secret-methods.c:1641
 #3 g_simple_async_result_complete at gsimpleasyncresult.c:763
 #4 on_search_items_complete at libsecret/secret-paths.c:316
 #5 g_simple_async_result_complete at gsimpleasyncresult.c:763
 #6 reply_cb at gdbusproxy.c:2623
 #7 g_simple_async_result_complete at gsimpleasyncresult.c:763
 #8 g_dbus_connection_call_done at gdbusconnection.c:5508
 #9 g_simple_async_result_complete at gsimpleasyncresult.c:763

See downstream bugreport for more details:
https://bugzilla.redhat.com/show_bug.cgi?id=1206966

See two probably related bugs:
- accidental deletion of luks password Bug 730759
- similar crash when locking Bug 678555
Comment 1 Ondrej Holy 2015-06-16 12:37:03 UTC
Created attachment 305384 [details] [review]
Do not clear passphrase if cancelled

I can't reproduce this issue, but I have found out that secret_password_clear is called whenever udisks_encrypted_call_unlock fails. This is wrong, the password should be cleared only if obsolete passphrase is in keyring. It would be best to add special error code in udisks if passphrase is invalid. There is comment in the code: "TODO: ideally check against something like UDISKS_ERROR_PASSPHRASE_INVALID when such a thing is available in udisks"

We can improve the behavioral and do not clear the passphrase if G_IO_ERROR_CANCELLED is returned at least. The G_IO_ERROR_CANCELLED is returned when you unplug the encrypted device in the meantime.
Comment 2 Ondrej Holy 2015-06-16 12:42:42 UTC
Unfortunately also I see two other error messages if the device is unplugged:
Error unlocking /dev/sdb1: Command-line `cryptsetup luksOpen "/dev/sdb1" "luks-90c34690-5f6f-4adf-9333-7651ccfa0a29" ' exited with non-zero exit status 4: Device /dev/sdb1 doesn't exist or access denied.
Error unlocking /dev/sdb1: Command-line `cryptsetup luksOpen "/dev/sdb1" "luks-90c34690-5f6f-4adf-9333-7651ccfa0a29" ' exited with non-zero exit status 1: IO error while decrypting keyslot.

We should to clear the password only if "Error unlocking /dev/sdb1: Command-line `cryptsetup luksOpen "/dev/sdb1" "luks-90c34690-5f6f-4adf-9333-7651ccfa0a29" ' exited with non-zero exit status 2: No key available with this passphrase." is returned. But only way how to distinguish the errors is string comparing, which isn't really best idea...
Comment 3 Ondrej Holy 2015-06-16 12:47:13 UTC
The attached patch will definitely reduce number of crashes, but I'm not really sure if it fixes the root of the problem. Otherwise the code looks good to me, however private data structures are passed a lot there and might be freed too early...
Comment 4 Ondrej Holy 2015-06-17 08:54:32 UTC
(In reply to Ondrej Holy from comment #1)
> Created attachment 305384 [details] [review] [review]
> Do not clear passphrase if cancelled
> 
> I can't reproduce this issue, but I have found out that
> secret_password_clear is called whenever udisks_encrypted_call_unlock fails.
> This is wrong, the password should be cleared only if obsolete passphrase is
> in keyring. It would be best to add special error code in udisks if
> passphrase is invalid. There is comment in the code: "TODO: ideally check
> against something like UDISKS_ERROR_PASSPHRASE_INVALID when such a thing is
> available in udisks"
> 
> We can improve the behavioral and do not clear the passphrase if
> G_IO_ERROR_CANCELLED is returned at least. The G_IO_ERROR_CANCELLED is
> returned when you unplug the encrypted device in the meantime.

Actually the passphrase isn't cleared if G_IO_ERROR_CANCELLED is returned, because g_secret_password_clear takes cancellable as a parameter and fails immediately. But still this patch can be useful to safe one additional call.
Comment 5 Ross Lagerwall 2015-06-22 07:06:33 UTC
Created attachment 305806 [details] [review]
udisks: Handle libsecret error properly

secret_password_clear_finish() returns whether any passwords are
removed, so it may return FALSE without setting error. Handle this
properly (in this case all we care about is that there wasn't an error).
Comment 6 Ross Lagerwall 2015-06-22 07:11:37 UTC
Review of attachment 305384 [details] [review]:

Probably OK, but the commit message should be: "but this definitely isn't a reason for clearing the passphrase."

Also, you should also include the GNOME bugzilla link.
Comment 7 Ondrej Holy 2015-06-24 07:31:57 UTC
Created attachment 305984 [details] [review]
udisks2: Do not call secret_password_clear_if_cancelled

Thanks for the review! Wrong link replaced. Commit message was changed, but as per Comment 4...
Comment 8 Ondrej Holy 2015-06-24 07:37:11 UTC
Review of attachment 305806 [details] [review]:

That's it probably! I realized this also in the meantime...

Just a nitpick, the commit message should begin with "udisks2:".
Comment 9 Ross Lagerwall 2015-06-24 07:48:34 UTC
Pushed to master as 5c2ac3f1ac452755df1c08480a0ee944138b42ec. Thanks!
Comment 10 Ross Lagerwall 2015-08-06 06:15:52 UTC
I also pushed this to gnome-3-14 and gnome-3-16.