Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sd-bus: deal with cookie overruns #11818

Merged
merged 1 commit into from Feb 28, 2019

Conversation

poettering
Copy link
Member

Apparently this happens IRL. Let's carefully deal with issues like this:
when we overrun, let's not go back to zero but instead leave the highest
cookie bit set. We use that as indication that we are in "overrun
territory", and then are particularly careful with checking cookies,
i.e. that they haven't been used for still outstanding replies yet. This
should retain the quick cookie generation behaviour we used to have, but
permits dealing with overruns.

Replaces: #11804

Apparently this happens IRL. Let's carefully deal with issues like this:
when we overrun, let's not go back to zero but instead leave the highest
cookie bit set. We use that as indication that we are in "overrun
territory", and then are particularly careful with checking cookies,
i.e. that they haven't been used for still outstanding replies yet. This
should retain the quick cookie generation behaviour we used to have, but
permits dealing with overruns.

Replaces: systemd#11804
Fixes: systemd#11809
goto good;

new_cookie = cookie_inc(new_cookie);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so if get to the for loop, new_cookie must be COOKIE_CYCLED, and it is never increased again. So this is an "infinite" loop, in the sense that we'll always do full 2**31 iterations.

Can we please have a unittest for this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it goes like this:

1 → 2 → 3 → … → CC-2 → CC-1 → CC → CC+1 → CC+2 → … → UM-2 → UM-1 → UM
                              ↑                                     ↓
                               ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ← ←

Were CC is COOKIE_CYCLED is 2^31 and UM is UINT32_MAX-1, i.e. 2^32-1

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I misunderstood the code.

So this looks OK, and I think we can merge it. A test would still be very welcome.
Maybe also add your comment above as a comment in the code.

@keszybz keszybz added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Feb 26, 2019
@poettering poettering added the downstream/rhel Tracking bugs for RHEL label Feb 27, 2019
goto good;

new_cookie = cookie_inc(new_cookie);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. I misunderstood the code.

So this looks OK, and I think we can merge it. A test would still be very welcome.
Maybe also add your comment above as a comment in the code.

@keszybz keszybz removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Feb 28, 2019
@keszybz keszybz merged commit 1f82f5b into systemd:master Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
downstream/rhel Tracking bugs for RHEL sd-bus
Development

Successfully merging this pull request may close these issues.

None yet

2 participants