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-netlink: fix deep recursion in message destruction #3455

Merged
merged 1 commit into from
Jun 7, 2016

Conversation

dvdhrm
Copy link
Contributor

@dvdhrm dvdhrm commented Jun 7, 2016

On larger systems we might very well see messages with thousands of parts.
When we free them, we must avoid recursing into each part, otherwise we
very likely get stack overflows.

Fix sd_netlink_message_unref() to use an iterative approach rather than
recursion (also avoid tail-recursion in case it is not optimized by the
compiler).

On larger systems we might very well see messages with thousands of parts.
When we free them, we must avoid recursing into each part, otherwise we
very likely get stack overflows.

Fix sd_netlink_message_unref() to use an iterative approach rather than
recursion (also avoid tail-recursion in case it is not optimized by the
compiler).
@dvdhrm
Copy link
Contributor Author

dvdhrm commented Jun 7, 2016

@teg, This was acutally hit by @jsynacek on a system with >300k routes.

if (m && REFCNT_DEC(m->n_ref) == 0) {
sd_netlink_message *t;

while (m && REFCNT_DEC(m->n_ref) == 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Why not declare t inside the while block? sd_netlink_message *t = m;

@poettering
Copy link
Member

lgtm. I agree with @zonque's point though, but then again, it sounds good enough too just merge it and save @dvdhrm work.

@poettering poettering merged commit 82e4eda into systemd:master Jun 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

3 participants