flatpak / xdg-dbus-proxy

GNU Lesser General Public License v2.1
57 stars 21 forks source link

Split proxy/client serials based on lower bit #57

Closed sophie-h closed 5 months ago

sophie-h commented 6 months ago

Separation between messages created by client and proxy was ensured by requiring the client to use monotonically increasing serials and adding an offset to distinguish the client message from proxy messages.

The requirement to only send messages with increasing serials cannot be ensured by libraries godbus or zbus.

This commit instead reserves the lower_bit=0 space for client messages and the lower_bit=1 for messages created by the proxy. This gets rid of any serial translation mechanism and the requirement for increasing serials. However, it limits the possible values of serials available to the client to about half of the usual maximum value.

Closes #46

sophie-h commented 5 months ago

What changes with this is that clients can re-use serials. I can't guarantee that this doesn't has potential security implications since I'm not familiar enough with the codebase.

matthiasclasen commented 5 months ago

Thanks for writing a patch!

swick commented 5 months ago

LGTM but we should definitely get another review in.

sophie-h commented 5 months ago

Rebased due to merge conflict.

alexlarsson commented 5 months ago

Some minor comments from me, but otherwise this looks good to me.

alexlarsson commented 5 months ago

Well, one more comment: Maybe MAX_CLIENT_SERIAL can be made much much larger. We're only emitting "fake" requests at the beginning of the session when setting up the view of bus names, so thre is never going to be 2^31 of them.

I think MAX_CLIIENT_SERIAL should be set to something like G_MAXUINT32 - 65536, which would allow more end-user serial numbers.

sophie-h commented 5 months ago

I have changed the code to

#define MAX_CLIENT_SERIAL (G_MAXUINT32 - 65536)
alexlarsson commented 5 months ago

lgtm