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 631023 - gvfsd-dnssd crashed with signal 7 in avahi_service_resolver_event()
gvfsd-dnssd crashed with signal 7 in avahi_service_resolver_event()
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: dns-sd backend
1.6.x
Other Linux
: Normal critical
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2010-09-30 15:57 UTC by Pedro Villavicencio
Modified: 2016-11-18 15:27 UTC
See Also:
GNOME target: ---
GNOME version: 2.31/2.32


Attachments
dnssd: Fix crashes when mount failed (2.97 KB, patch)
2016-07-29 12:01 UTC, Ondrej Holy
committed Details | Review
dnssd: Free client object on finalize (1.03 KB, patch)
2016-10-13 12:09 UTC, Ondrej Holy
none Details | Review
dnssd: Use only one daemon process (1.38 KB, patch)
2016-10-13 12:09 UTC, Ondrej Holy
none Details | Review
dnssd: Free resolvers also on client failure (2.09 KB, patch)
2016-10-13 12:09 UTC, Ondrej Holy
committed Details | Review
dnssd: Free browser objects properly (957 bytes, patch)
2016-10-13 12:09 UTC, Ondrej Holy
committed Details | Review
dnssd: Use only one daemon process (1.21 KB, patch)
2016-11-11 10:09 UTC, Ondrej Holy
committed Details | Review
dnssd: Free client object on finalize (1.04 KB, patch)
2016-11-18 15:24 UTC, Ondrej Holy
committed Details | Review

Description Pedro Villavicencio 2010-09-30 15:57:14 UTC
this report has been filed here:

https://bugs.edge.launchpad.net/ubuntu/+source/gvfs/+bug/647236

".

Thread 1 (process 13819)

  • #0 lookup_link_file_by_name_and_type
    at gvfsbackenddnssd.c line 353
  • #1 resolve_callback
    at gvfsbackenddnssd.c line 542
  • #2 avahi_service_resolver_event
    at resolver.c line 146
  • #3 filter_func
    at client.c line 256
  • #4 dbus_connection_dispatch
    at dbus-connection.c line 4451
  • #5 dispatch_timeout_callback
    at ../avahi-common/dbus-watch-glue.c line 105
  • #6 dispatch_func
    at glib-watch.c line 252
  • #7 g_main_context_dispatch
    at /build/buildd/glib2.0-2.25.15/glib/gmain.c line 2119
  • #8 g_main_context_iterate
    at /build/buildd/glib2.0-2.25.15/glib/gmain.c line 2750
  • #9 g_main_loop_run
    at /build/buildd/glib2.0-2.25.15/glib/gmain.c line 2958
  • #10 daemon_main
    at daemon-main.c line 294
  • #11 main
    at daemon-main-generic.c line 39

Comment 2 Ondrej Holy 2015-11-26 13:12:50 UTC
It looks like backend->files contains invalid LinkFile structs, but I have no idea, how this happened. It would crash earlier if name/type would be NULL. Concurrent access for backend->files is not possible also, because all functions should be executed on daemon main loop...
Comment 3 Ondrej Holy 2016-07-29 11:51:22 UTC
Ah, I've finally managed what is wrong. It is similar to Bug 712235. This happens, when multiple mount operations are executed concurrently...
Comment 4 Ondrej Holy 2016-07-29 12:01:12 UTC
Created attachment 332348 [details] [review]
dnssd: Fix crashes when mount failed

Pushed fix to master as commit 8398c16, gnome-3-20 as commit 6c1124d, and gnome-3-18 as commit 4fd1a8f.
Comment 5 Jan Alexander Steffens (heftig) 2016-10-09 21:45:15 UTC
I think this fix actually causes a use-after-free when avahi searches through the client's service resolvers in avahi_service_resolver_event, but I'm not quite sure how this is possible.

  • #0 __strcmp_sse2_unaligned
  • #1 0x00000000004030ff in
  • #2 0x0000000000403536 in
  • #3 avahi_service_resolver_event
  • #4 0x00007f8988c382dc in
  • #5 dbus_connection_dispatch
  • #6 0x00007f8988c3e8e6 in
  • #7 0x00007f8989052680 in
  • #8 g_main_dispatch
    at gmain.c line 3203
  • #9 g_main_context_dispatch
    at gmain.c line 3856
  • #10 g_main_context_iterate
    at gmain.c line 3929
  • #11 g_main_loop_run
    at gmain.c line 4125
  • #12 0x0000000000404aaf in
  • #13 0x0000000000402e7e in
  • #14 __libc_start_main
  • #15 0x0000000000402eba in

Two gvfsd-dnssd instances with similar PIDs (3566, 3568) crashed at the same time with the same backtrace.
Comment 6 Ondrej Holy 2016-10-13 10:23:47 UTC
You are right, I see other crashes on retrace server on versions including this fix :-/ It would be really nice to have a reproducer, because it seems I am not able to reproduce it with the latest fix. 

However, I see some other issues, which might cause the crashes. I will attach patches for them soon...
Comment 7 Ondrej Holy 2016-10-13 12:09:28 UTC
Created attachment 337589 [details] [review]
dnssd: Free client object on finalize

Client object is not freed even if there isn't more backends.
Free the client in order to avoid potential use-after-free crashes
caused by some avahi client activity.
Comment 8 Ondrej Holy 2016-10-13 12:09:33 UTC
Created attachment 337590 [details] [review]
dnssd: Use only one daemon process

The dnssd backend was designed to run under one common daemon
process, however, new daemon is always spawn for each host
(i.e. backend) currently. Set common dbus mountpoint in order
to use one daemon process for all backends.
Comment 9 Ondrej Holy 2016-10-13 12:09:38 UTC
Created attachment 337591 [details] [review]
dnssd: Free resolvers also on client failure

Resolvers are not currently removed on client failure. It might
potentialy lead to some use-after-free crashes. Remove resolver
objects also on client failures.
Comment 10 Ondrej Holy 2016-10-13 12:09:44 UTC
Created attachment 337592 [details] [review]
dnssd: Free browser objects properly

Browser objects are not currently freed by remove_browsers call,
just the list is emptied. Free the browser objects for sure in order
to avoid some use-after-free crashes.
Comment 11 Ondrej Holy 2016-10-13 12:10:33 UTC
I hope the attached patches fix the crashes and do not cause another once, however, it would be nice if somebody could test those patches before pushing also...
Comment 12 Ondrej Holy 2016-11-11 10:09:42 UTC
Created attachment 339601 [details] [review]
dnssd: Use only one daemon process

The dnssd backend was designed to run under one common daemon
process, however, new daemon is always spawn for each host
(i.e. backend) currently. Set common dbus mountpoint in order
to use one daemon process for all backends.
Comment 13 Ondrej Holy 2016-11-18 15:24:14 UTC
Created attachment 340241 [details] [review]
dnssd: Free client object on finalize

Client object is not freed even if there isn't more backends.
Free the client in order to avoid potential use-after-free crashes
caused by some avahi client activity.
Comment 14 Ondrej Holy 2016-11-18 15:24:49 UTC
Attachment 337591 [details] pushed as 7368e48 - dnssd: Free resolvers also on client failure
Attachment 337592 [details] pushed as 9fcbd14 - dnssd: Free browser objects properly
Attachment 339601 [details] pushed as 28e06fb - dnssd: Use only one daemon process
Attachment 340241 [details] pushed as ccf7b91 - dnssd: Free client object on finalize
Comment 15 Ondrej Holy 2016-11-18 15:27:53 UTC
Pushed also for gnome-3-22.