Mark SetBrightness D-Bus calls as no-reply to prevent a reply leak that exhausts the user's bus quota#170
Merged
Merged
Conversation
The logind brightness path sends SetBrightness method calls on a
blocking Connection that is never drained (process()/read_write() are
never called). Each call is a normal method call expecting a reply, so
logind returns a method-return that nobody reads. These replies queue up
in the bus daemon's outgoing buffer to wluma without bound.
Because dbus-broker accounts message memory per user, this slowly
consumes the user's entire quota. Once exhausted, the bus daemon starts
disconnecting that user's other clients when they request any sizable
reply ("...does not have the resources to receive a reply it
requested"), breaking nm-applet, nmcli and similar tools with a
misleading "NetworkManager is not running" even though it is running.
SetBrightness has no meaningful return value, so flag the message as
no-reply. logind then never generates a reply and nothing accumulates.
Owner
|
Thanks! It looks like the default value is already false ( if you follow the chain starting from https://docs.rs/dbus/latest/dbus/message/struct.Message.html#method.Set_no_reply ), do you have some evidence that this PR in fact is not a noop? |
Contributor
Author
|
Hi @max-baz, the |
Owner
|
Thanks, and apologies! My bad, I started going down the docs and confused myself in the negations 😅 I think the lints are unrelated to your changes, I'll address them later. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On the logind D-Bus brightness path (
src/brightness/backlight.rs, used when wluma lacks direct write permission to the sysfsbrightnessfile), wluma sendsSetBrightnessmethod calls on adbus::blocking::Connectionbut never drains the connection —process()/read_write()are never called anywhere in the codebase.A normal method call expects a reply, so logind returns a
method_returnfor everySetBrightness. Nobody ever reads those replies, so they accumulate without bound in the bus daemon's outgoing queue toward wluma. Becausedbus-brokeraccounts message memory per user, this slowly consumes the user's entire quota. Once it's exhausted, the bus daemon starts disconnecting that user's other clients whenever they request a sizable reply:In practice this manifests as unrelated tools breaking — e.g.
nm-applet/nmclireporting "NetworkManager is not running" even though it is, becauselibnm'sGetManagedObjects()reply can no longer be received. Killing wluma (or here, fixing it) immediately frees the quota and the other clients recover. The backed-up socket is directly observable viass -xp | grep system_bus_socket— wluma's connection shows a large, growingSend-Q.Fix
SetBrightnesshas no meaningful return value, so flag the message as no-reply (Message::set_no_reply(true)). logind then never generates a reply and nothing accumulates. Minimal, and keeps the existing fire-and-forgetsend()model.(An alternative would be to pump the connection with
connection.process(Duration::ZERO)after each send, but suppressing the reply at the source is cleaner and cheaper.)Testing
cargo buildsucceeds againstdbus 0.9.11(confirmsset_no_replyAPI usage).cargo fmt --checkclean.SetBrightnessis unchanged; only the now-unused reply is suppressed.