Skip to content

Bug: DBus resolved resolver uses context.Background() with no timeout, can block indefinitely #4160

@hklcf

Description

@hklcf

Description

In \dns/transport/local/local_resolved_linux.go, the \checkResolved\ method is called with \context.Background()\ from both:

  • \Exchange()\ at line 141
  • \updateStatus()\ at line 186

These calls pass \context.Background()\ into \CallWithContext()\ at line 234, meaning there is no application-level timeout or cancellation for the DBus \GetLink\ call.

Impact

If \systemd-resolved\ or the DBus daemon becomes unresponsive, the \CallWithContext\ call will block indefinitely. In the \Exchange()\ path, this blocks DNS resolution. In the \updateStatus()\ path (called from the signal processing goroutine \loopUpdateStatus), this stalls ALL DBus signal processing, preventing the resolver from reacting to network changes.

Location

\dns/transport/local/local_resolved_linux.go:141,186,234\

Suggested Fix

Use a context with a reasonable timeout (e.g., \context.WithTimeout(context.Background(), 10*time.Second)) instead of bare \context.Background(). The timeout should be long enough for normal DBus operations but short enough to prevent indefinite blocking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions